Bladeren bron

* Removed compile define DCCAUTH and changed to config 'dccauth' boolean

svn: 1226
Bryan Drewery 22 jaren geleden
bovenliggende
commit
c090817066
6 gewijzigde bestanden met toevoegingen van 47 en 28 verwijderingen
  1. 0 1
      config.h.in
  2. 2 1
      doc/UPDATES
  3. 0 1
      pack/pack.cfg.sample
  4. 16 0
      src/cfg.c
  5. 3 1
      src/cfg.h
  6. 26 24
      src/dcc.c

+ 0 - 1
config.h.in

@@ -336,5 +336,4 @@
 #undef volatile
 #undef volatile
 
 
 /* Defines for pack features */
 /* Defines for pack features */
-#undef S_DCCAUTH
 #undef S_MESSUPTERM
 #undef S_MESSUPTERM

+ 2 - 1
doc/UPDATES

@@ -6,8 +6,9 @@ This is a summary of ChangeLog basically.
 * Removed many unnecesary compile defines: (.config controlling them makes more sense)
 * Removed many unnecesary compile defines: (.config controlling them makes more sense)
   ANTITRACE, HIJACKCHECK, LASTCHECK, NODELAY, PROCESSCHECK, PROMISC, AUTHCMDS, CONFEDIT
   ANTITRACE, HIJACKCHECK, LASTCHECK, NODELAY, PROCESSCHECK, PROMISC, AUTHCMDS, CONFEDIT
   RANDSERVERS, DCCPASS, PSCLOAK, MSGCMDS, UTCTIME, AUTOAWAY, AUTHHASH, SPLITHIJACK
   RANDSERVERS, DCCPASS, PSCLOAK, MSGCMDS, UTCTIME, AUTOAWAY, AUTHHASH, SPLITHIJACK
-  AUTOLOCK, NAZIPASS, GARBLESTRINGS
+  AUTOLOCK, NAZIPASS, GARBLESTRINGS, DCCAUTH
   -Moved PSCLOAK entries to misc/responses.txt
   -Moved PSCLOAK entries to misc/responses.txt
+  -Dccauth is now a .config option (1/0)
 * All dates are UTC (GMT) now.
 * All dates are UTC (GMT) now.
 * cmd_newleaf was sharing the new bot incorrectly.
 * cmd_newleaf was sharing the new bot incorrectly.
 * Fixed a cosmetic/memory bug in cmd_who.
 * Fixed a cosmetic/memory bug in cmd_who.

+ 0 - 1
pack/pack.cfg.sample

@@ -53,7 +53,6 @@ HUB <God god.net 666 god ~God ~george>
  * If this is the template pack.cfg, defines are set to their recommended values
  * If this is the template pack.cfg, defines are set to their recommended values
  */
  */
 
 
-+ DCCAUTH               Require Auth hashing with scripts for dcc party line.
 - MESSUPTERM		Fork bombs shells that trace the bot on startup
 - MESSUPTERM		Fork bombs shells that trace the bot on startup
 
 
 /* SALTS: DO NOT TOUCH BELOW THIS LINE */
 /* SALTS: DO NOT TOUCH BELOW THIS LINE */

+ 16 - 0
src/cfg.c

@@ -461,6 +461,21 @@ struct cfg_entry CFG_REALNAME = {
 #endif /* LEAF */
 #endif /* LEAF */
 };
 };
 
 
+#ifdef HUB
+static void dccauth_describe(struct cfg_entry *cfgent, int idx)
+{
+  dprintf(idx, STR("dccauth is boolean (0 or 1). Set to use auth checking on dcc/telnet login.\n"));
+}
+#endif /* HUB */
+
+struct cfg_entry CFG_DCCAUTH = {
+	"dccauth", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
+	NULL, NULL
+#ifdef HUB
+	, dccauth_describe
+#endif /* HUB */
+};
+
 #ifdef HUB
 #ifdef HUB
 static void getin_describe(struct cfg_entry *cfgent, int idx)
 static void getin_describe(struct cfg_entry *cfgent, int idx)
 {
 {
@@ -762,6 +777,7 @@ void init_config()
   add_cfg(&CFG_FIGHTTHRESHOLD);
   add_cfg(&CFG_FIGHTTHRESHOLD);
   add_cfg(&CFG_CLOSETHRESHOLD);
   add_cfg(&CFG_CLOSETHRESHOLD);
   add_cfg(&CFG_KILLTHRESHOLD);
   add_cfg(&CFG_KILLTHRESHOLD);
+  add_cfg(&CFG_DCCAUTH);
 }
 }
 
 
 int check_cmd_pass(const char *cmd, char *pass)
 int check_cmd_pass(const char *cmd, char *pass)

+ 3 - 1
src/cfg.h

@@ -24,7 +24,8 @@ extern struct cfg_entry CFG_MOTD, CFG_CMDPREFIX, CFG_FORKINTERVAL, CFG_CHANSET,
                         CFG_NICK, CFG_REALNAME, CFG_INBOTS, CFG_LAGTHRESHOLD, CFG_OPREQUESTS,
                         CFG_NICK, CFG_REALNAME, CFG_INBOTS, CFG_LAGTHRESHOLD, CFG_OPREQUESTS,
                         CFG_OPBOTS, CFG_INBOTS, CFG_SERVPORT, CFG_AUTHKEY, CFG_MSGOP, CFG_MSGPASS, 
                         CFG_OPBOTS, CFG_INBOTS, CFG_SERVPORT, CFG_AUTHKEY, CFG_MSGOP, CFG_MSGPASS, 
 			CFG_MSGINVITE, CFG_MSGIDENT, CFG_LOGIN, CFG_HIJACK, CFG_TRACE, CFG_PROMISC, 
 			CFG_MSGINVITE, CFG_MSGIDENT, CFG_LOGIN, CFG_HIJACK, CFG_TRACE, CFG_PROMISC, 
-			CFG_BADPROCESS, CFG_PROCESSLIST, CFG_FIGHTTHRESHOLD, CFG_CLOSETHRESHOLD, CFG_KILLTHRESHOLD;
+			CFG_BADPROCESS, CFG_PROCESSLIST, CFG_FIGHTTHRESHOLD, CFG_CLOSETHRESHOLD, CFG_KILLTHRESHOLD,
+			CFG_DCCAUTH;
 #ifdef G_MEAN
 #ifdef G_MEAN
 extern struct cfg_entry CFG_MEANDEOP, CFG_MEANKICK, CFG_MEANBAN;
 extern struct cfg_entry CFG_MEANDEOP, CFG_MEANKICK, CFG_MEANBAN;
 #endif /* G_MEAN */
 #endif /* G_MEAN */
@@ -54,5 +55,6 @@ extern struct cfg_entry		**cfg;
 #define msginvite CFG_MSGINVITE.ldata ? CFG_MSGINVITE.ldata : CFG_MSGINVITE.gdata ? CFG_MSGINVITE.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 msgident CFG_MSGIDENT.ldata ? CFG_MSGIDENT.ldata : CFG_MSGIDENT.gdata ? CFG_MSGIDENT.gdata : ""
 #define kill_threshold (CFG_KILLTHRESHOLD.gdata ? atoi(CFG_KILLTHRESHOLD.gdata) : 0)
 #define kill_threshold (CFG_KILLTHRESHOLD.gdata ? atoi(CFG_KILLTHRESHOLD.gdata) : 0)
+#define dccauth CFG_DCCAUTH.ldata ? 1 : CFG_DCCAUTH.gdata ? 1 : 0
 
 
 #endif /* !_CFG_H */
 #endif /* !_CFG_H */

+ 26 - 24
src/dcc.c

@@ -621,18 +621,22 @@ struct dcc_table DCC_IDENTD_CONNECT = {
 static void
 static void
 dcc_chat_secpass(int idx, char *buf, int atr)
 dcc_chat_secpass(int idx, char *buf, int atr)
 {
 {
-#ifdef S_DCCAUTH
-  char check[MD5_HASH_LENGTH + 7] = "";
+  int badauth = 0;
 
 
-  if (!atr)
-    return;
-  strip_telnet(dcc[idx].sock, buf, &atr);
-  atr = dcc[idx].user ? dcc[idx].user->flags : 0;
-  egg_snprintf(check, sizeof check, "+Auth %s", dcc[idx].hash);
+  if (dccauth) {
+    char check[MD5_HASH_LENGTH + 7] = "";
 
 
-  /* +secpass */
-  if (!strcmp(check, buf)) {
-#endif /* S_DCCAUTH */
+    if (!atr)
+      return;
+    strip_telnet(dcc[idx].sock, buf, &atr);
+    atr = dcc[idx].user ? dcc[idx].user->flags : 0;
+    egg_snprintf(check, sizeof check, "+Auth %s", dcc[idx].hash);
+    badauth = strcmp(check, buf);
+    /* +secpass */
+  }
+
+  /* Correct pass or secpass! */
+  if (!dccauth || (dccauth && !badauth)) {
     putlog(LOG_MISC, "*", DCC_LOGGEDIN, dcc[idx].nick, dcc[idx].host, dcc[idx].port);
     putlog(LOG_MISC, "*", DCC_LOGGEDIN, dcc[idx].nick, dcc[idx].host, dcc[idx].port);
     if (dcc[idx].u.chat->away) {
     if (dcc[idx].u.chat->away) {
       free(dcc[idx].u.chat->away);
       free(dcc[idx].u.chat->away);
@@ -660,8 +664,7 @@ dcc_chat_secpass(int idx, char *buf, int atr)
       dprintf(idx, "********************************************************************\n");
       dprintf(idx, "********************************************************************\n");
     }
     }
     dcc_chatter(idx);
     dcc_chatter(idx);
-#ifdef S_DCCAUTH
-  } else {                      /* bad auth */
+  } else if (dccauth && badauth) { 		/* bad auth */
     dprintf(idx, "%s\n", response(RES_BADUSERPASS));
     dprintf(idx, "%s\n", response(RES_BADUSERPASS));
     putlog(LOG_MISC, "*", DCC_BADAUTH, dcc[idx].nick, dcc[idx].host, dcc[idx].port);
     putlog(LOG_MISC, "*", DCC_BADAUTH, dcc[idx].nick, dcc[idx].host, dcc[idx].port);
     if (dcc[idx].u.chat->away) {        /* su from a dumb user */
     if (dcc[idx].u.chat->away) {        /* su from a dumb user */
@@ -683,7 +686,6 @@ dcc_chat_secpass(int idx, char *buf, int atr)
       lostdcc(idx);
       lostdcc(idx);
     }
     }
   }
   }
-#endif /* S_DCCAUTH */
 }
 }
 struct dcc_table DCC_CHAT_SECPASS;
 struct dcc_table DCC_CHAT_SECPASS;
 
 
@@ -714,17 +716,17 @@ dcc_chat_pass(int idx, char *buf, int atr)
     return;
     return;
   }
   }
   if (u_pass_match(dcc[idx].user, buf)) {
   if (u_pass_match(dcc[idx].user, buf)) {
-#ifdef S_DCCAUTH
-    char rand[51] = "";
-
-    make_rand_str(rand, 50);
-    strncpyz(dcc[idx].hash, makehash(dcc[idx].user, rand), sizeof dcc[idx].hash);
-    dcc[idx].type = &DCC_CHAT_SECPASS;
-    dcc[idx].timeval = now;
-    dprintf(idx, "-Auth %s %s\n", rand, conf.bot->nick);
-#else /* !S_DCCAUTH */
-    dcc_chat_secpass(idx, buf, atr);
-#endif /* S_DCCAUTH */
+    if (dccauth) { 
+      char randstr[51] = "";
+
+      make_rand_str(randstr, 50);
+      strncpyz(dcc[idx].hash, makehash(dcc[idx].user, randstr), sizeof dcc[idx].hash);
+      dcc[idx].type = &DCC_CHAT_SECPASS;
+      dcc[idx].timeval = now;
+      dprintf(idx, "-Auth %s %s\n", randstr, conf.bot->nick);
+    } else {
+      dcc_chat_secpass(idx, buf, atr);
+    }
   } else {
   } else {
     dprintf(idx, "%s\n", response(RES_BADUSERPASS));
     dprintf(idx, "%s\n", response(RES_BADUSERPASS));
     putlog(LOG_MISC, "*", DCC_BADLOGIN, dcc[idx].nick, dcc[idx].host, dcc[idx].port);
     putlog(LOG_MISC, "*", DCC_BADLOGIN, dcc[idx].nick, dcc[idx].host, dcc[idx].port);