Преглед изворни кода

* Fixed a bug in msg_invite, was checking what msgop was :\
* Added msg_ident with config option


svn: 516

Bryan Drewery пре 22 година
родитељ
комит
98fcce4f20
7 измењених фајлова са 82 додато и 8 уклоњено
  1. 2 0
      doc/UPDATES
  2. 9 1
      src/config.c
  3. 1 0
      src/mod/irc.mod/irc.c
  4. 55 0
      src/mod/irc.mod/msgcmds.c
  5. 1 0
      src/mod/module.h
  6. 10 5
      src/mod/server.mod/servmsg.c
  7. 4 2
      src/modules.c

+ 2 - 0
doc/UPDATES

@@ -25,6 +25,8 @@ This is a summary of ChangeLog basically.
 22.cmd_mop didn't check if the bot was opped before sending +o lines.
 23.Fixed several file descriptors that weren't closed.
 24.The bot will now wait until it is finished recieving the +e listing before enforcing bans.
+25.Fixed a bug with .config msginvite.
+26.Added a config option for msgident.
 
 1.0.13
 1.Fixed a fatal bug in console_gotshare()

+ 9 - 1
src/config.c

@@ -55,7 +55,7 @@ struct cfg_entry CFG_AUTHKEY = {
 #endif /* S_AUTH */
 
 #ifdef S_MSGCMDS
-struct cfg_entry CFG_MSGOP, CFG_MSGPASS, CFG_MSGINVITE;
+struct cfg_entry CFG_MSGOP, CFG_MSGPASS, CFG_MSGINVITE, CFG_MSGIDENT;
 void msgcmds_describe(struct cfg_entry *entry, int idx) {
   if (entry == &CFG_MSGOP)
     dprintf(idx, STR("msgop defines the cmd for opping via msging the bot (leave blank to disable)\n"));
@@ -63,6 +63,8 @@ void msgcmds_describe(struct cfg_entry *entry, int idx) {
     dprintf(idx, STR("msgpass defines the cmd for setting a pass via msging the bot (leave blank to disable)\n"));
   else if (entry == &CFG_MSGINVITE)
     dprintf(idx, STR("msginvite defines the cmd for requesting invite via msging the bot (leave blank to disable)\n"));
+  else if (entry == &CFG_MSGIDENT)
+    dprintf(idx, STR("msgident defines the cmd for identing via msging the bot (leave blank to disable)\n"));
 }
 
 void msgcmds_changed(struct cfg_entry * entry, char * olddata, int * valid) {
@@ -82,6 +84,11 @@ struct cfg_entry CFG_MSGINVITE = {
   "msginvite", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
   msgcmds_changed, msgcmds_changed, msgcmds_describe
 };
+
+struct cfg_entry CFG_MSGIDENT = {
+  "msgident", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+  msgcmds_changed, msgcmds_changed, msgcmds_describe
+};
 #endif /* S_MSGCMDS */
 
 void cmdprefix_describe(struct cfg_entry *entry, int idx) {
@@ -708,6 +715,7 @@ void init_config()
   add_cfg(&CFG_MSGOP);
   add_cfg(&CFG_MSGPASS);
   add_cfg(&CFG_MSGINVITE);
+  add_cfg(&CFG_MSGIDENT);
 #endif /* S_MSGCMDS */
 #ifdef HUB
   add_cfg(&CFG_NICK);

+ 1 - 0
src/mod/irc.mod/irc.c

@@ -27,6 +27,7 @@
 #define msgop CFG_MSGOP.ldata ? CFG_MSGOP.ldata : CFG_MSGOP.gdata ? CFG_MSGOP.gdata : ""
 #define msgpass CFG_MSGPASS.ldata ? CFG_MSGPASS.ldata : CFG_MSGPASS.gdata ? CFG_MSGPASS.gdata : ""
 #define msginvite CFG_MSGINVITE.ldata ? CFG_MSGINVITE.ldata : CFG_MSGINVITE.gdata ? CFG_MSGINVITE.gdata : ""
+#define msgident CFG_MSGIDENT.ldata ? CFG_MSGIDENT.ldata : CFG_MSGIDENT.gdata ? CFG_MSGIDENT.gdata : ""
 
 #define PRIO_DEOP 1
 #define PRIO_KICK 2

+ 55 - 0
src/mod/irc.mod/msgcmds.c

@@ -94,6 +94,60 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
   return 1;
 }
 
+static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
+{
+  char s[UHOSTLEN], s1[UHOSTLEN], *pass, who[NICKLEN];
+  struct userrec *u2;
+
+  if (match_my_nick(nick) || (u && (u->flags & USER_BOT)))
+    return 1;
+
+  pass = newsplit(&par);
+  if (!par[0])
+    strcpy(who, nick);
+  else {
+    strncpy(who, par, NICKMAX);
+    who[NICKMAX] = 0;
+  }
+  u2 = get_user_by_handle(userlist, who);
+  if (!u2) {
+    if (u && !quiet_reject)
+      dprintf(DP_HELP, IRC_MISIDENT, nick, nick, u->handle);
+  } else if (rfc_casecmp(who, origbotname) && !(u2->flags & USER_BOT)) {
+    /* This could be used as detection... */
+    if (u_pass_match(u2, "-")) {
+      putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
+      if (!quiet_reject)
+        dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_NOPASS);
+    } else if (!u_pass_match(u2, pass)) {
+      if (!quiet_reject)
+        dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_DENYACCESS);
+    } else if (u == u2) {
+      /*
+       * NOTE: Checking quiet_reject *after* u_pass_match()
+       * verifies the password makes NO sense!
+       * (Broken since 1.3.0+bel17)  Bad Beldin! No Cookie!
+       *   -Toth  [July 30, 2003]
+       */
+      dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_RECOGNIZED);
+      return 1;
+    } else if (u) {
+      dprintf(DP_HELP, IRC_MISIDENT, nick, who, u->handle);
+      return 1;
+    } else {
+      putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
+      egg_snprintf(s, sizeof s, "%s!%s", nick, host);
+      maskhost(s, s1);
+      dprintf(DP_HELP, "NOTICE %s :%s: %s\n", nick, IRC_ADDHOSTMASK, s1);
+      addhost_by_handle(who, s1);
+      check_this_user(who, 0, NULL);
+      return 1;
+    }
+  }
+  putlog(LOG_CMDS, "*", "(%s!%s) !*! failed IDENT %s", nick, host, who);
+  return 1;
+}
+
 static int msg_invite(char *nick, char *host, struct userrec *u, char *par)
 {
   char *pass;
@@ -358,6 +412,7 @@ static cmd_t C_msg[] =
 #endif /* S_AUTH */
   {"word",		"",	(Function) msg_word,		NULL},
 #ifdef S_MSGCMDS
+  {"ident",   		"",	(Function) msg_ident,		NULL},
   {"invite",		"o|o",	(Function) msg_invite,		NULL},
   {"op",		"",	(Function) msg_op,		NULL},
   {"pass",		"",	(Function) msg_pass,		NULL},

+ 1 - 0
src/mod/module.h

@@ -551,6 +551,7 @@
 #define CFG_MSGOP (*(struct cfg_entry *)(global[338]))
 #define CFG_MSGPASS (*(struct cfg_entry *)(global[339]))
 #define CFG_MSGINVITE (*(struct cfg_entry *)(global[340]))
+#define CFG_MSGIDENT (*(struct cfg_entry *)(global[341]))
 
 
 extern int lfprintf(FILE *, char *, ...);

+ 10 - 5
src/mod/server.mod/servmsg.c

@@ -11,6 +11,7 @@
 #define msgop CFG_MSGOP.ldata ? CFG_MSGOP.ldata : CFG_MSGOP.gdata ? CFG_MSGOP.gdata : ""
 #define msgpass CFG_MSGPASS.ldata ? CFG_MSGPASS.ldata : CFG_MSGPASS.gdata ? CFG_MSGPASS.gdata : ""
 #define msginvite CFG_MSGINVITE.ldata ? CFG_MSGINVITE.ldata : CFG_MSGINVITE.gdata ? CFG_MSGINVITE.gdata : ""
+#define msgident CFG_MSGIDENT.ldata ? CFG_MSGIDENT.ldata : CFG_MSGIDENT.gdata ? CFG_MSGIDENT.gdata : ""
 
 
 char cursrvname[120]="";
@@ -535,17 +536,21 @@ static int gotmsg(char *from, char *msg)
         if (!ignoring) {
           int doit = 1, result = 0;
 #ifdef S_MSGCMDS
-          if (!egg_strcasecmp(code, "op") || !egg_strcasecmp(code, "pass") || !egg_strcasecmp(code, "invite")
-             || !egg_strcasecmp(code, msgop) || !egg_strcasecmp(code, msgpass) || !egg_strcasecmp(code, msgop)) {
-/*             || !strcmp(code, msgop) || !strcmp(code, msgpass) || !strcmp(code, msgop)) { */
+          if (!egg_strcasecmp(code, "op") || !egg_strcasecmp(code, "pass") || !egg_strcasecmp(code, "invite") 
+              || !egg_strcasecmp(code, "ident")
+               || !egg_strcasecmp(code, msgop) || !egg_strcasecmp(code, msgpass) 
+               || !egg_strcasecmp(code, msginvite) || !egg_strcasecmp(code, msgident)) {
+/*           || !strcmp(code, msgop) || !strcmp(code, msgpass) || !strcmp(code, msgop)) { */
             char buf[10];
             doit = 0;
             if (!egg_strcasecmp(code, msgop))
               sprintf(buf, "op");
-            if (!egg_strcasecmp(code, msgpass))
+            else if (!egg_strcasecmp(code, msgpass))
               sprintf(buf, "pass");
-            if (!egg_strcasecmp(code, msginvite))
+            else if (!egg_strcasecmp(code, msginvite))
               sprintf(buf, "invite");
+            else if (!egg_strcasecmp(code, msgident))
+              sprintf(buf, "ident");
             if (buf[0])
               result = check_tcl_msg(buf, nick, uhost, u, msg);
           }

+ 4 - 2
src/modules.c

@@ -46,7 +46,7 @@ extern party_t *party;
 extern int parties;
 extern sock_list        *socklist;
 #ifdef S_MSGCMDS
-extern struct cfg_entry CFG_MSGOP, CFG_MSGPASS, CFG_MSGINVITE;
+extern struct cfg_entry CFG_MSGOP, CFG_MSGPASS, CFG_MSGINVITE, CFG_MSGIDENT;
 #endif /* S_MSGCMDS */
 int xtra_kill();
 int xtra_unpack();
@@ -595,8 +595,10 @@ Function global_table[] =
 #ifdef S_MSGCMDS
   (Function) & CFG_MSGOP,
   (Function) & CFG_MSGPASS,
-  (Function) & CFG_MSGINVITE
+  (Function) & CFG_MSGINVITE,
+  (Function) & CFG_MSGIDENT
 #else /* !S_MSGCMDS */
+  (Function) 0,
   (Function) 0,
   (Function) 0,
   (Function) 0