]> jfr.im git - irc/quakenet/newserv.git/blobdiff - noperserv/noperserv.c
NOPERSERV: fix silly hello bug.
[irc/quakenet/newserv.git] / noperserv / noperserv.c
index cd8f17dd44b4814acaa4ed83e7b56b0ca5f246a0..827850900268bed44b0e741daf64b07ae7ea2146 100644 (file)
@@ -8,6 +8,9 @@
 
 #include "../localuser/localuser.h"
 #include "../lib/irc_string.h"
+#include "../lib/strlfunc.h"
+#include "../lib/version.h"
+#include "../authext/authext.h"
 #include "noperserv.h"
 #include "noperserv_db.h"
 #include "noperserv_hooks.h"
@@ -17,6 +20,8 @@
 #include <string.h>
 #include <stdarg.h>
 
+MODULE_VERSION("");
+
 #define FLAGBUFLEN 100
 
 #define NO_FOUND_NICKNAME 1
@@ -32,6 +37,7 @@ const flag no_commandflags[] = {
     { 'O', __NO_OPERED },
     { 'r', __NO_AUTHED },
     { 'R', __NO_ACCOUNT },
+    { 'Y', __NO_RELAY },
     { '\0', 0 }
   }; 
 
@@ -41,14 +47,15 @@ const flag no_userflags[] = {
     { 's', __NO_STAFF },
     { 'S', __NO_SEC },
     { 'd', __NO_DEVELOPER },
+    { 'Y', __NO_RELAY },
     { '\0', 0 }
   }; 
 
 const flag no_noticeflags[] = {
     { 'm', NL_MANAGEMENT },   /* hello, password, userflags, noticeflags */
     { 't', NL_TRUSTS },       /* trust stuff... */
-    { 'k', NL_KICKS },        /* KICK command */
-    { 'K', NL_KILLS },        /* KILL command */
+    { 'k', NL_KICKKILLS },    /* KICK/KILL commands */
+    { 'I', NL_MISC },         /* misc commands */
     { 'g', NL_GLINES },       /* GLINE commands */
     { 'h', NL_HITS },         /* Where a gline or kill is set automatically by the bot */
     { 'c', NL_CLONING },      /* Clone detection */
@@ -67,39 +74,61 @@ int noperserv_noticeflags(void *sender, int cargc, char **cargv);
 int noperserv_userflags(void *sender, int cargc, char **cargv);
 int noperserv_deluser(void *sender, int cargc, char **cargv);
 void noperserv_oper_detection(int hooknum, void *arg);
-void noperserv_reply(nick *np, char *format, ...);
+void noperserv_reply(nick *np, char *format, ...) __attribute__ ((format (printf, 2, 3)));
+
+int init = 0;
 
 void _init() {
-  noperserv_ext = registernickext("noperserv");
+  if(!noperserv_load_db())
+    return;
 
-  noperserv_load_db();
+  noperserv_ext = registernickext("noperserv");
 
   noperserv_setup_hooks();
 
   registercontrolhelpcmd("hello", NO_OPERED | NO_AUTHED, 1, &noperserv_hello, "Syntax: HELLO ?nickname|#authname?\nCreates an account on the service for the specified nick, or if one isn't supplied, your nickname.");
-  registercontrolhelpcmd("userflags", NO_ACCOUNT, 2, &noperserv_userflags, "Syntax: USERFLAGS <nickname|#authname> ?modifications?\nViews and modifies user permissions.\nIf no nickname or authname is supplied, you are substituted for it.\nIf no flags are supplied, flags are just displayed instead of modified.");
+  registercontrolhelpcmd("userflags", NO_ACCOUNT, 2, &noperserv_userflags,
+    "Syntax: USERFLAGS <nickname|#authname> ?modifications?\n"
+    " Views and modifies user permissions.\n"
+    " If no nickname or authname is supplied, you are substituted for it.\n"
+    " If no flags are supplied, flags are just displayed instead of modified."
+    " Flags:\n"
+    "  +o: Operator\n"
+    "  +s: Staff member\n"
+    "  +S: Security team member\n"
+    "  +d: NOperserv developer\n"
+    "  +t: Trust queue worker\n"
+    "  +Y: Relay\n"
+    " Additional flags may show up in SHOWCOMMANDS but are not userflags as such:\n"
+    "  +r: Authed user\n"
+    "  +R: Registered NOperserv user\n"
+    "  +O: Must be /OPER'ed\n"
+    "  +L: Legacy command\n"
+  );
   registercontrolhelpcmd("noticeflags", NO_ACCOUNT, 1, &noperserv_noticeflags,
     "Syntax: NOTICEFLAGS ?(nickname|#authname)|flags?\n"
     " This command can view and modify your own notice flags, and view that of other users.\n"
     " Flags:\n"
     "  +m: Management (hello, password, userflags, noticeflags)\n"
     "  +t: Trusts\n"
-    "  +k: KICK command\n"
-    "  +K: KILL command\n"
+    "  +k: KICK/KILL commands\n"
     "  +g: GLINE commands\n"
     "  +h: Shows when glines are played automatically (hits)\n"
     "  +c: Clone information\n"
     "  +C: CLEARCHAN command\n"
-    "  +f: FAKEUSER command\n"
+    "  +f: FAKEUSER commands\n"
     "  +b: BROADCAST commands\n"
     "  +o: Operation commands, such as insmod, rmmod, die, etc\n"
     "  +O: /OPER\n"
+    "  +I: Misc commands (resync, etc)\n"
     "  +n: Sends notices instead of privmsgs\n"
-    "  +A: Every single command sent to the service\n"
+    "  +A: Every single command sent to the service (spammy)\n"
   );
 
   registercontrolhelpcmd("deluser", NO_OPERED | NO_ACCOUNT, 2, &noperserv_deluser, "Syntax: DELUSER <nickname|#authname>\nDeletes the specified user.");
   registerhook(HOOK_NICK_MODEOPER, &noperserv_oper_detection);
+
+  init = 1;
 }
 
 #ifdef BROKEN_DLCLOSE
@@ -107,11 +136,16 @@ void __fini() {
 #else
 void _fini() {
 #endif
+  if(!init)
+    return;
+
   deregisterhook(HOOK_NICK_MODEOPER, &noperserv_oper_detection);
 
   deregistercontrolcmd("noticeflags", &noperserv_noticeflags);
   deregistercontrolcmd("userflags", &noperserv_userflags);
   deregistercontrolcmd("noticeflags", &noperserv_noticeflags);
+  deregistercontrolcmd("hello", &noperserv_hello);
+  deregistercontrolcmd("deluser", &noperserv_deluser);
 
   noperserv_cleanup_hooks();
 
@@ -122,7 +156,7 @@ void _fini() {
 
 /* @test */
 int noperserv_hello(void *sender, int cargc, char **cargv) {
-  char *newaccount;
+  char *newaccount = NULL;
   no_autheduser *au;
   int i;
   nick *np = (nick *)sender, *np2, *target = NULL;
@@ -131,18 +165,13 @@ int noperserv_hello(void *sender, int cargc, char **cargv) {
     newaccount = np->authname;
   } else {
     if(cargv[0][0] == '#') {
-      nick *np2;
-      for(i=0;i<NICKHASHSIZE;i++)
-        for(np2=nicktable[i];np2;np2=np2->next)
-          if(IsAccount(np2) && !ircd_strcmp(cargv[0] + 1, np2->authname)) {
-            target = np2;
-            newaccount = target->authname;
-            break;
-          }
-      if(!target) {
+      authname *a = getauthbyname(cargv[0] + 1);
+      if(!a) {
         controlreply(np, "Cannot find anyone with that authname on the network.");
         return CMD_ERROR;
       }
+      newaccount = a->name;
+      target = a->nicks;
     } else {
       target = getnickbynick(cargv[0]);
       if(!target) {
@@ -456,17 +485,15 @@ int noperserv_userflags(void *sender, int cargc, char **cargv) {
 }
 
 void noperserv_oper_detection(int hooknum, void *arg) {
-  void **args = (void **)arg;
-  nick *np = args[0];
-  char *modestr = args[1];
-  flag_t after = np->umodes;
+  nick *np = (nick *)arg;
 
-  setflags(&after, UMODE_ALL, modestr, umodeflags, REJECT_NONE);
   if(np->umodes & UMODE_OPER) {
-    if(!(after & UMODE_OPER))
-      controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just DEOPERed", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"");
-  } else {
-    if(after & UMODE_OPER)
+    if(np->opername && strcmp(np->opername->content, "-")) {
+      controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just OPERed as %s", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"", np->opername->content);
+    } else {
       controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just OPERed", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"");
+    }
+  } else {
+    controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just DEOPERed", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"");
   }
 }