Просмотр исходного кода

Various comments removed
Various Contexts removed (100+, down to 140, egg has 14)
Various commented code removed
Misc code fixes/improvements
Added a DEVEL file to give standards for development of project


svn: 128

Bryan Drewery 23 лет назад
Родитель
Сommit
58f96a55a8

+ 1 - 1
src/botcmd.c

@@ -444,7 +444,7 @@ static void bot_sysname(int idx, char *par)
 {
  //simply copy it all to the string pointer.
 
-//  putlog(LOG_MISC, "*", "%s is using %s", dcc[idx].nick, par);
+  putlog(LOG_DEBUG, "@", "%s is using %s", dcc[idx].nick, par);
   dcc[idx].u.bot->sysname[0] = 0;
   strcpy(dcc[idx].u.bot->sysname, par);
 }

+ 0 - 1
src/botnet.c

@@ -1660,7 +1660,6 @@ void check_botnet_pings()
 	    killsock(dcc[i].sock);
 	    lostdcc(i);
 	  } else {
-//fix
             putlog(LOG_MISC, "*", "I am lame, and am now rejecting %s", bot->bot);
 	    botnet_send_reject(i, botnetnick, NULL, bot->bot,
 			       NULL, NULL);

+ 6 - 24
src/chanprog.c

@@ -453,25 +453,13 @@ void load_internal_users()
       case 4:
 	if (!get_user_by_handle(userlist, hand)) {
 	  userlist = adduser(userlist, hand, "none", "-", USER_BOT | USER_OP);
-/* no thanks.
-          if (atoi(hublevel) < 999 && strcmp(hand, origbotname)) {
-            u = get_user_by_handle(userlist, hand);
-            fr.bot |= (BOT_PASSIVE | BOT_GLOBAL);
-//            set_user(&USERENTRY_BOTFL, u, (void *) fr.bot);
-            set_user_flagrec(u, &fr, NULL);
-          }
-//          user.bot = BITS;
-*/
 	  bi = user_malloc(sizeof(struct bot_addr));
-
 	  bi->address = user_malloc(strlen(ip) + 1);
 	  strcpy(bi->address, ip);
 	  bi->telnet_port = atoi(port) ? atoi(port) : 0;
 	  bi->relay_port = bi->telnet_port;
           bi->hublevel = atoi(hublevel);
 #ifdef HUB
-//printf("adding %s with hublevel: %d\n", hand, bi->hublevel ? bi->hublevel : 99);
-
 	  if ((!bi->hublevel) && (!strcmp(hand, botnetnick)))
 	    bi->hublevel = 99;
 #endif
@@ -507,9 +495,7 @@ void load_internal_users()
 
 //owners..
   owner[0] = 0;
-//  strcpy(p, owners);
 
-// buf = get_setting(1);
   sprintf(buf, "%s", owners);
   p = buf;
   while (p) {
@@ -592,11 +578,10 @@ void chanprog()
 #ifdef HUB
   if (!userfile[0])
     fatal(MISC_NOUSERFILE2, 0);
-  //setstatic = 0;
   loading = 1;
   readuserfile(userfile, &userlist);
   loading = 0;
-#endif
+#endif /* HUB */
 
   load_internal_users();
 
@@ -614,7 +599,7 @@ void chanprog()
     bi->hublevel = 99;
 #else
     bi->hublevel = 0;
-#endif
+#endif /* HUB */
     bi->uplink = user_malloc(1);
     bi->uplink[0] = 0;
     set_user(&USERENTRY_BOTADDR, u, bi);
@@ -648,7 +633,7 @@ void chanprog()
 #ifdef HUB
     listen_all(bi->telnet_port, 0);
     my_port = bi->telnet_port;
-#endif
+#endif /* HUB */
   }
 
   trigger_cfg_changed();
@@ -681,8 +666,8 @@ void chanprog()
   }
   reaffirm_owners();
 }
-#ifdef HUB
 
+#ifdef HUB
 /* Reload the user file from disk
  */
 void reload()
@@ -699,17 +684,14 @@ void reload()
   clear_userlist(userlist);
   noshare = 0;
   userlist = NULL;
-  //setstatic = 0;
   loading = 1;
   if (!readuserfile(userfile, &userlist))
     fatal(MISC_MISSINGUSERF, 0);
   loading = 0;
-  //setstatic = 1;
   reaffirm_owners();
   call_hook(HOOK_READ_USERFILE);
 }
-#endif
-
+#endif /* HUB */
 
 void rehash()
 {
@@ -719,7 +701,7 @@ void rehash()
   clear_userlist(userlist);
   noshare = 0;
   userlist = NULL;
-#endif
+#endif /* HUB */
   chanprog();
 }
 

+ 19 - 39
src/cmds.c

@@ -17,8 +17,6 @@
 #include <sys/utsname.h>
 #endif
 
-//extern struct server_list * serverlist;
-
 extern struct chanset_t	*chanset;
 extern struct dcc_t	*dcc;
 extern struct userrec	*userlist;
@@ -426,9 +424,7 @@ void cmd_botconfig(struct userrec *u, int idx, char *par)
   if (par[0]) {
     set_cfg_str(u2->handle, cfgent->name, (strcmp(par, "-")) ? par : NULL);
     dprintf(idx, STR("Now: "));
-#ifdef HUB
     write_userfile(idx);
-#endif
   } else {
     if (cfgent->describe)
       cfgent->describe(cfgent, idx);
@@ -450,16 +446,8 @@ void cmd_cmdpass(struct userrec *u, int idx, char *par)
   int i, l = 0;
 
   /* cmdpass [command [newpass]] */
-//  putlog(LOG_CMDS, "*", "#%s# cmdpass %s ...", dcc[idx].nick, cmd[0] ? cmd : "");
-  putlog(LOG_CMDS, "*", "#%s# cmdpass ...", dcc[idx].nick);
-/*
-  if (!isowner(u->handle)) {
-    putlog(LOG_MISC, "*", STR("%s attempted to set a command password - not perm owner"), dcc[idx].nick);
-    dprintf(idx, STR("Perm owners only.\n"));
-    return;
-  }
-*/
   cmd = newsplit(&par);
+  putlog(LOG_CMDS, "*", "#%s# cmdpass %s ...", dcc[idx].nick, cmd[0] ? cmd : "");
   pass = newsplit(&par);
   if (!cmd[0] || par[0]) {
     dprintf(idx, STR("Usage: %scmdpass command [password]\n"), dcc_prefix);
@@ -508,20 +496,31 @@ void cmd_cmdpass(struct userrec *u, int idx, char *par)
   if (pass[0]) {
     char epass[36],
       tmp[256];
-
+    if (!isowner(u->handle) && has_cmd_pass(cmd)) {
+      putlog(LOG_MISC, "*", STR("%s attempted to change command password for %s - not perm owner"), dcc[idx].nick, cmd);
+      dprintf(idx, STR("Perm owners only.\n"));
+      return;
+    }
     encrypt_pass(pass, epass);
     sprintf(tmp, STR("%s %s"), cmd, epass);
+    if (has_cmd_pass(cmd))
+      dprintf(idx, STR("Changed command password for %s\n"), cmd);
+    else
+      dprintf(idx, STR("Set command password for %s\n"), cmd);
     set_cmd_pass(tmp, 1);
-    dprintf(idx, STR("Set command password for %s\n"), cmd);
   } else {
+    if (!isowner(u->handle)) {
+      putlog(LOG_MISC, "*", STR("%s attempted to remove command password for %s - not perm owner"), dcc[idx].nick, cmd);
+      dprintf(idx, STR("Perm owners only.\n"));
+      return;
+    }
     set_cmd_pass(cmd, 1);
     dprintf(idx, STR("Removed command password for %s\n"), cmd);
   }
-#ifdef HUB
     write_userfile(idx);
-#endif
 }
-#endif
+#endif /* S_DCCPASS */
+
 static void cmd_lagged(struct userrec *u, int idx, char *par)
 {
   /* Lists botnet lag to *directly connected* bots */
@@ -715,7 +714,6 @@ static void cmd_vbottree(struct userrec *u, int idx, char *par)
 
 int my_cmp (const mycmds *c1, const mycmds *c2)
 {
-//printf("comparing: %s and %s\n", c1->name, c2->name);
   return strcmp (c1->name, c2->name);
 }
 
@@ -743,7 +741,6 @@ Context;
     showall = 1;
     build_flags(flg, &fr, NULL);
     dprintf(idx, "Showing help topics matching your flags: (%s)\n  ", flg);
-//    dprintf(idx, STR("Help overview:\n  "));
   }
 
   for (o = 0; o < cmdi; o++) {
@@ -778,9 +775,7 @@ Context;
         build_flags(flg, &(cmds[n].flags), NULL);
         if (!strcmp(flg, flag)) {
           if (first) {
-//            dprintf(idx, "%s## DCC (%s)\n  ", end ? "" : "\n", flag);
             dprintf(idx, "%s## DCC (%s)\n  ", "\n", flag);
-//            dprintf(idx, "## DCC (%s)\n  ", flag);
           }
 
           if (end && !first) {
@@ -793,7 +788,6 @@ Context;
           i++;
         }
         if (i >= 5) {
-//          dprintf(idx, "\n");
           end = 1;
           i = 0;
         } 
@@ -806,14 +800,6 @@ Context;
 If you have flags on a channel, type %sconsole #chan to see more commands.\n"), dcc_prefix, dcc_prefix);
   else if (!fnd)
     dprintf(idx, STR("No help for nonexistant command '%s'.\n"), par);
-Context;
-//  for (n = 0; n < o ; n++) {
-//    nfree(cmds[n].name);
-//  }
-
-//cmds[0].name = NULL;
-//garbage_collect_tclhash();
-Context;
 }
 
 #ifdef HUB
@@ -921,7 +907,6 @@ void cmd_botupdate(struct userrec *u, int idx, char *par)
 
 static void rcmd_update(char *fbot, char *fhand, char *fidx, char *par)
 {
-//  putlog(LOG_CMDS, "*", STR("#%s# update %s"), dcc[idx].nick, par);
   if (!par[0])
     return;
   updatebin(0, par, 0);
@@ -2130,14 +2115,12 @@ static void cmd_chattr(struct userrec *u, int idx, char *par)
     /* No-one can change these flags on-the-fly */
     pls.global &= ~(USER_BOT);
     mns.global &= ~(USER_BOT);
-//only THE owner can add these flags
-
 
     if ((pls.global & USER_UPDATEHUB) && (bot_hublevel(u2) == 999)) {
       dprintf(idx, "Only a hub can be set as the updatehub.\n");
       pls.global &= ~(USER_UPDATEHUB);
     }
-
+    
     if (!isowner(u->handle)) {
       if (pls.global & USER_HUBA)
         putlog(LOG_MISC, "*", "%s attempted to give %s hub connect access", dcc[idx].nick, u2->handle);
@@ -3171,11 +3154,10 @@ static void cmd_mns_user(struct userrec *u, int idx, char *par)
    (func[IRC_CHECK_THIS_USER]) (handle, 1, NULL);
   }
   if (deluser(handle)) {
-//    putlog(LOG_CMDS, "*", "#%s# -user %s", dcc[idx].nick, handle);
     dprintf(idx, "Deleted %s.\n", handle);
 #ifdef HUB
     write_userfile(idx);
-#endif
+#endif /* HUB */
   } else
     dprintf(idx, "Failed.\n");
 }
@@ -3944,8 +3926,6 @@ void gotremotereply (char * frombot, char * tohand, char * toidx, char * ln) {
   }
 }
 
-//#endif /* HUB */
-
 static void cmd_traffic(struct userrec *u, int idx, char *par)
 {
   unsigned long itmp, itmp2;

+ 6 - 39
src/dcc.c

@@ -19,14 +19,12 @@
 #endif
 
 #include "tandem.h"
-
+#include "md5/md5.h"
 #include <sys/stat.h>
 
 extern char netpass[9];
 
 
-/* Includes for botnet md5 challenge/response code <cybah> */
-#include "md5/md5.h"
 
 extern struct userrec	*userlist;
 extern struct chanset_t	*chanset;
@@ -216,7 +214,7 @@ void send_timesync(idx)
     }
 #else
     putlog(LOG_ERRORS, "*", "I'm a leaf - where should i send timesync?");
-#endif
+#endif /* HUB */
   }
 }
 
@@ -227,7 +225,7 @@ static void greet_new_bot(int idx)
   char *sysname = NULL;
 #ifdef HAVE_UNAME
   struct utsname un;
-#endif
+#endif /* HAVE_UNAME */
 
   dcc[idx].timeval = now;
   dcc[idx].u.bot->version[0] = 0;
@@ -242,10 +240,9 @@ static void greet_new_bot(int idx)
     lostdcc(idx);
     return;
   }
-#endif
+#endif /* HUB */
 
-//  if (bot_hublevel(dcc[idx].user) == 999)
-  if (0 == 999)
+  if (bot_hublevel(dcc[idx].user) == 999)
    dcc[idx].status |= STAT_LEAF;
   dcc[idx].status |= STAT_LINKING;
 #ifdef HAVE_UNAME
@@ -253,13 +250,9 @@ static void greet_new_bot(int idx)
     sysname = "*";
   else
     sysname = un.sysname;
-#endif
+#endif /* HAVE_UNAME */
 
-Context;
   dprintf(idx, "v %d %d %s <%s>\n", egg_numver, HANDLEN, ver, network);
-Context;
-//putlog(LOG_MISC, "*", "SEnding os: %s", sysname);
-Context;
   dprintf(idx, "vs %s\n", sysname);
   for (i = 0; i < dcc_total; i++)
     if (dcc[i].type == &DCC_FORK_BOT) {
@@ -435,7 +428,6 @@ static void dcc_bot_new(int idx, char *buf, int x)
   } else if (strcmp(code, "")) {
       /* Invalid password/digest */
       putlog(LOG_WARN, "*", "%s failed encrypted link handshake", dcc[idx].nick);
-//      putlog(LOG_ERRORS, "*", "Expected elink, got %s %s", code, buf);
       killsock(dcc[idx].sock);
       lostdcc(idx);
   }
@@ -613,12 +605,8 @@ static void dcc_chat_secpass(int idx, char *buf, int atr)
   strip_telnet(dcc[idx].sock, buf, &atr);
   atr = dcc[idx].user ? dcc[idx].user->flags : 0;
 
-Context;
   sprintf(check, "+Auth %s", dcc[idx].hash);
 
-  putlog(LOG_DEBUG, "*", "got: %s, should be: %s", buf, check);
-
-Context;
   if (!strcmp(check, buf)) {
 //+secpass
       putlog(LOG_MISC, "*", DCC_LOGGEDIN, dcc[idx].nick,
@@ -683,23 +671,17 @@ static void dcc_chat_pass(int idx, char *buf, int atr)
     } else {
       /* Invalid password/digest */
       putlog(LOG_WARN, "*", "%s failed encrypted link handshake", dcc[idx].nick);
-//      putlog(LOG_ERRORS, "*", "Expected elinkdone, got %s", buf);
       killsock(dcc[idx].sock);
       lostdcc(idx);
     }
     return;
   }
-Context;
-
   if (u_pass_match(dcc[idx].user, buf)) {
     char rand[50];
 
-Context;
     make_rand_str(rand, 50);
 
-Context;
     strcpy(dcc[idx].hash, makehash(dcc[idx].user, rand));
-Context;
     dcc[idx].type = &DCC_CHAT_SECPASS;
     dcc[idx].timeval = now;
     dprintf(idx, "-Auth %s %s\n", rand, botnetnick);
@@ -1270,7 +1252,6 @@ static void dcc_telnet(int idx, char *buf, int i)
   dcc[i].sock = sock;
   dcc[i].addr = ip;
 #ifdef USE_IPV6
-Context;
   if (sockprotocol(sock) == AF_INET6)
     strcpy(dcc[i].addr6, s);
 #endif /* USE_IPV6 */
@@ -1283,7 +1264,6 @@ Context;
   dcc[i].u.dns->dns_type = RES_HOSTBYIP;
   dcc[i].u.dns->ibuf = dcc[idx].sock;
   dcc[i].u.dns->type = &DCC_IDENTWAIT;
-Context;
 #ifdef USE_IPV6
   if (sockprotocol(sock) == AF_INET6)
     dcc_telnet_hostresolved(i);
@@ -1615,8 +1595,6 @@ static void dcc_telnet_pass(int idx, int atr)
   }
 
   if (glob_bot(fr)) {
-//    putlog(LOG_BOTS, "*", "Challenging %s...", dcc[idx].nick);
-//    dprintf(idx, "elink <%x%x@%s>\n", getpid(), dcc[idx].timeval, botnetnick);
     int snum = -1;
 
     for (i = 0; i < MAXSOCKS; i++) {
@@ -1667,14 +1645,6 @@ static void dcc_telnet_pass(int idx, int atr)
       lostdcc(idx);
     }
   } else {
-    /* NOTE: The MD5 digest used above to prevent cleartext passwords being
-     *       sent across the net will _only_ work when we have the cleartext
-     *       password. User passwords are encrypted (with blowfish usually)
-     *       so the same thing cant be done. Botnet passwords are always
-     *       stored in cleartext, or at least something that can be reversed.
-     *       <Cybah>
-     */
-
     /* Turn off remote telnet echo (send IAC WILL ECHO). */
 #ifdef HUB
     dprintf(idx, "\n%s" TLN_IAC_C TLN_WILL_C TLN_ECHO_C "\n", DCC_ENTERPASS);
@@ -1787,7 +1757,6 @@ static void eof_dcc_script(int idx)
   call_tcl_func(dcc[idx].u.script->command, dcc[idx].sock, "");
   /* restore the flags */
   dcc[idx].type->flags = oldflags;
-  Context;
   old = dcc[idx].u.script->u.other;
   dcc[idx].type = dcc[idx].u.script->type;
   nfree(dcc[idx].u.script);
@@ -1821,12 +1790,10 @@ static int expmem_dcc_script(void *x)
 static void kill_dcc_script(int idx, void *x)
 {
   register struct script_info *p = (struct script_info *) x;
-
 Context;
   if (p->type && p->u.other)
     p->type->kill(idx, p->u.other);
   nfree(p);
-Context;
 }
 
 static void out_dcc_script(int idx, char *buf, void *x)

+ 1 - 18
src/dccutil.c

@@ -117,8 +117,6 @@ void dprintf EGG_VARARGS_DEF(int, arg1)
 id = idx;
 if (id < 0) { id = idx + 7; id = -id; }
 
-//printf("hm idx: %d id: %d\n", idx, id);
-
 if ((id < 0x7FF0) && (dcc[id].status & STAT_COLOR) && 
  (dcc[id].type == &DCC_CHAT)) {
  int i, a = 0, m = 0;
@@ -126,7 +124,6 @@ if ((id < 0x7FF0) && (dcc[id].status & STAT_COLOR) &&
   m = 1;
  else if (dcc[id].status & STAT_COLORA)
   a = 1;
-//printf("a: %i m: %i\n", a, m);
 if (!a && !m) { goto broke; }
  buf3[0] = '\0';
  for (i = 0 ; i < len ; i++) {
@@ -281,7 +278,6 @@ void dcc_chatter(int idx)
   dprintf(idx, "Connected to %s, running %s\n", botnetnick, version);
   show_banner(idx);
   show_motd(idx);
-Context;
   if (glob_master(fr)) {
     if ((tands+1) > 1)
       dprintf(idx, STR("There are \002-%d- bots\002 currently linked.\n"), tands + 1);
@@ -289,7 +285,6 @@ Context;
       dprintf(idx, STR("There is \002-%d- bot\002 currently linked.\n"), tands + 1);
   }
   show_channels(idx, NULL);
-Context;
 
   if (glob_party(fr)) {
      i = dcc[idx].u.chat->channel;
@@ -358,7 +353,6 @@ Context;
 
   dcc[n].sock = (-1);
   dcc[n].type = &DCC_LOST;
-Context;
 }
 
 /* Remove entry from dcc list. Think twice before using this function,
@@ -375,7 +369,7 @@ Context;
     dcc[n].type->kill(n, dcc[n].u.other);
   else if (dcc[n].u.other)
     nfree(dcc[n].u.other);
-Context;
+
   dcc_total--;
   if (n < dcc_total)
     egg_memcpy(&dcc[n], &dcc[dcc_total], sizeof(struct dcc_t));
@@ -570,7 +564,6 @@ Context;
     nfree(dcc[i].u.other);
     dcc[i].u.other = NULL;
   }
-Context;
   dcc[i].type = type;
   if (xtra_size) {
     dcc[i].u.other = nmalloc(xtra_size);
@@ -630,35 +623,25 @@ Context;
   /* If it's a partyliner (chatterer :) */
   /* Horrible assumption that DCT_CHAT using structure uses same format
    * as DCC_CHAT */
-Context;
   if ((dcc[idx].type->flags & DCT_CHAT) &&
       (dcc[idx].u.chat->channel >= 0)) {
     char x[1024];
-Context;
 
     egg_snprintf(x, sizeof x, DCC_BOOTED3, by, dcc[idx].nick,
 		 reason[0] ? ": " : "", reason);
-Context;
     chanout_but(idx, dcc[idx].u.chat->channel, "*** %s.\n", x);
-Context;
     if (dcc[idx].u.chat->channel < GLOBAL_CHANS)
       botnet_send_part_idx(idx, x);
   }
-Context;
   check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
-Context;
   if ((dcc[idx].sock != STDOUT) || backgrd) {
-Context;
     killsock(dcc[idx].sock);
-Context;
     lostdcc(idx);
     /* Entry must remain in the table so it can be logged by the caller */
   } else {
-Context;
     dprintf(DP_STDOUT, "\n### SIMULATION RESET\n\n");
     dcc_chatter(idx);
   }
-Context;
   return;
 }
 

+ 2 - 5
src/flags.h

@@ -51,10 +51,8 @@ struct flag_record {
 #endif
 #define DEFLAG_MDOP        6
 
-//#define USER_VALID 0x03fbfeff /* all USER_ flags in use              */
-//#define CHAN_VALID 0x03777c79 /* all flags that can be chan specific */
-#define USER_VALID 0x03ffffff
-#define CHAN_VALID 0x03ffffff
+#define USER_VALID 0x03ffffff	/* all USER_ flags in use              */
+#define CHAN_VALID 0x03ffffff	/* all flags that can be chan specific */
 #define BOT_VALID  0x7fe689C1 /* all BOT_ flags in use               */
 
 
@@ -171,7 +169,6 @@ struct flag_record {
 #define chan_noflood(x)			((x).chan & USER_NOFLOOD)
 #define glob_chanhub(x)			((x).global & USER_CHANHUB)
 
-//#define bot_global(x)		((x).bot & BOT_GLOBAL)
 #define bot_global(x)		(1)
 #define bot_chan(x)		((x).chan & BOT_AGGRESSIVE)
 #define bot_shared(x)		((x).bot & BOT_SHARE)

+ 19 - 35
src/main.c

@@ -179,12 +179,11 @@ void fatal(const char *s, int recoverable)
 #ifdef LEAF
   module_entry *me;
 
-Context;
   if ((me = module_find("server", 0, 0))) {
     Function *func = me->funcs;
     (func[SERVER_NUKESERVER]) (s);
   }
-#endif
+#endif /* LEAF */
   if (s[0])
     putlog(LOG_MISC, "*", "* %s", s);
   flushlogs();
@@ -273,7 +272,6 @@ void write_debug()
     nested_debug = 1;
   putlog(LOG_MISC, "*", "* Last context: %s/%d [%s]", cx_file[cx_ptr],
 	 cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : "");
-//  putlog(LOG_MISC, "*", "* Please REPORT this BUG to bryan (send him ~/DEBUG as well)!");
   x = creat("DEBUG", 0600);
   setsock(x, SOCK_NONSOCK);
   if (x < 0) {
@@ -917,23 +915,17 @@ void checklockfile()
 
 void got_ed(char *which, char *in, char *out)
 {
-  sdprintf("got_Ed called: -%s i: %s o: %s", which, in, out);
 Context;
+  sdprintf("got_Ed called: -%s i: %s o: %s", which, in, out);
   if (!in || !out)
     fatal("Wrong number of arguments: -e/-d <infile> <outfile/STDOUT>",0);
-Context;
   checkpass();
-  Context;
   check_static("blowfish", blowfish_start);
-  Context;
   module_load(ENCMOD);
-  Context;
   if (!strcmp(which, "e")) {
-  Context;
     EncryptFile(in, out);
     fatal("File Encryption complete",3);
   } else if (!strcmp(which, "d")) {
-  Context;
     DecryptFile(in, out);
     fatal("File Decryption complete",3);
   }
@@ -1304,12 +1296,9 @@ int main(int argc, char **argv)
   egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
   lastmin = nowtm.tm_min;
   srandom(now % (getpid() + getppid()));
-  Context;
   init_mem();
   myuid = geteuid();
-  Context;
   binname = getfullbinname(argv[0]);
-  Context;
 
   check_trace_start();
 
@@ -1319,12 +1308,9 @@ int main(int argc, char **argv)
    werr(ERR_BINMOD);
 
   init_settings();
-Context;
   init_tcl(argc, argv);
-Context;
   if (argc) {
     sdprintf("Calling dtx_arg with %d params.", argc);
-Context;
     dtx_arg(argc, argv);
   }
 
@@ -1337,17 +1323,16 @@ Context;
 
   if (!pw)
    werr(ERR_PASSWD);
-Context;
   chdir(pw->pw_dir);
   snprintf(newbin, sizeof newbin, "%s/.sshrc", pw->pw_dir);
   snprintf(confdir, sizeof confdir, "%s/.ssh", pw->pw_dir);
   snprintf(tempdir, sizeof tempdir, "%s/...", confdir);
-#endif
+#endif /* LEAF */
 #ifdef HUB
   snprintf(tmpdir, sizeof tmpdir, "%s", binname);
   snprintf(confdir, sizeof confdir, "%s", dirname(tmpdir));
   snprintf(tempdir, sizeof tempdir, "%s/tmp", confdir);
-#endif
+#endif /* HUB */
 
 #ifdef LEAF
   /* is the homedir a symlink? */
@@ -1408,7 +1393,7 @@ Context;
   // Ok if we are here, then the binary is accessable and in the correct directory, now lets do the local config...
 
 
-#endif
+#endif /* LEAF */
  
   snprintf(tmp, sizeof tmp, "%s/", confdir);
   if (!can_stat(tmp)) {
@@ -1417,11 +1402,11 @@ Context;
       unlink(confdir);
       if (!can_stat(confdir))
         if (mkdir(confdir, S_IRUSR | S_IWUSR | S_IXUSR))
-#endif
+#endif /* LEAF */
           werr(ERR_CONFSTAT);
 #ifdef LEAF
     }
-#endif
+#endif /* LEAF */
   }
 
   snprintf(tmp, sizeof tmp, "%s/", tempdir);
@@ -1444,7 +1429,7 @@ Context;
   snprintf(cfile, sizeof cfile, "%s/.known_hosts", confdir);
 #else
   snprintf(cfile, sizeof cfile, "%s/conf", confdir);
-#endif
+#endif /* LEAF */
   if (!can_stat(cfile))
     werr(ERR_NOCONF);
   if (!fixmod(cfile))
@@ -1463,14 +1448,14 @@ Context;
 #ifndef LEAF
   kill_tcl();
   init_tcl(argc, argv);
-#endif
+#endif /* LEAF */
   init_botcmd();
   link_statics();
   module_load(ENCMOD);
 
 #ifdef LEAF
   if (localhub) { //we only want to read the config if we are the spawn bot..
-#endif
+#endif /* LEAF */
 #ifdef HAVE_UNAME
     if (uname(&un) < 0) {
 #endif /* HAVE_UNAME */
@@ -1489,10 +1474,10 @@ Context;
     i = 0;
     if (!(f = fopen(cfile, "r")))
        werr(0);
+    Context;
     while(fscanf(f,"%[^\n]\n",templine) != EOF) {
       char *nick = NULL, *host = NULL, *ip = NULL, *ipsix = NULL;
       int skip = 0;
-      Context;
       if (templine[0] != '+') {
         printf(STR("%d: "), i);
         werr(ERR_CONFBADENC);
@@ -1561,7 +1546,7 @@ Context;
           snprintf(origbotname, 10, "%s", nick);
 #ifdef HUB
           sprintf(userfile, "%s/.%s.user", confdir, nick);
-#endif
+#endif /* HUB */
 
           if (host && host[1]) { //only copy host if it is longer than 1 char (.)
             if (host[0] == '+') { //ip6 host
@@ -1610,14 +1595,14 @@ Context;
   if (updating)
     exit(0); //let the 5 min timer restart us.
   } // (localhub)
-#endif
+#endif /* LEAF */
 
   module_load("dns");
   module_load("channels");
 #ifdef LEAF
   module_load("server");
   module_load("irc");
-#endif
+#endif /* LEAF */
   module_load("transfer");
   module_load("share");
   module_load("update"); 
@@ -1630,14 +1615,13 @@ Context;
 #ifdef LEAF
   if (localhub) {
     sdprintf("I am localhub (%s)", origbotname);
-#endif
+#endif /* LEAF */
     check_crontab();
 #ifdef LEAF
   }
 #endif
 
 
-  Context;
   if (!encrypt_pass) {
     printf(MOD_NOCRYPT);
     bg_send_quit(BG_ABORT);
@@ -1684,7 +1668,7 @@ Context;
 #ifndef CYGWIN_HACKS
     bg_do_split();
   } else {			/* !backgrd */
-#endif
+#endif /* CYGWIN_HACKS */
     xx = getpid();
     if (xx != 0) {
       FILE *fp;
@@ -1705,7 +1689,7 @@ Context;
         printf(EGG_NOWRITE, pid_file);
 #ifdef CYGWIN_HACKS
       printf("Launched into the background  (pid: %d)\n\n", xx);
-#endif
+#endif /* CYGWIN_HACKS */
     }
   }
 
@@ -1721,7 +1705,7 @@ Context;
     freopen("/dev/null", "w", stderr);
 #ifdef CYGWIN_HACKS
     FreeConsole();
-#endif
+#endif /* CYGWIN_HACKS */
   }
 
   /* Terminal emulating dcc chat */
@@ -1759,7 +1743,7 @@ Context;
   add_hook(HOOK_USERFILE, (Function) event_save);
 #ifdef HUB
   add_hook(HOOK_BACKUP, (Function) backup_userfile);  
-#endif
+#endif /* HUB */
   add_hook(HOOK_DAILY, (Function) event_logfile);
   add_hook(HOOK_DAILY, (Function) event_resettraffic);
   add_hook(HOOK_LOADED, (Function) event_loaded);

+ 53 - 138
src/misc.c

@@ -67,13 +67,12 @@ int	 debug_output = 1;	/* Disply output to server to LOG_SERVEROUT */
 
 int auth_total = 0;
 int max_auth = 100;
+char authkey[121];		/* This is one of the keys used in the auth hash */
+char cmdprefix[1] = "+";	/* This is the prefix for msg/channel cmds */
 
 struct auth_t *auth = 0;
 
 
-char authkey[121];
-char cmdprefix[1] = "+";
-
 struct cfg_entry CFG_MOTD = {
   "motd", CFGF_GLOBAL, NULL, NULL,
   NULL, NULL, NULL
@@ -107,12 +106,12 @@ void cmdprefix_changed(struct cfg_entry * entry, char * olddata, int * valid) {
     strncpy0(cmdprefix, (char *) entry->gdata, sizeof cmdprefix);
   }
 }
+
 struct cfg_entry CFG_CMDPREFIX = {
   "cmdprefix", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
   cmdprefix_changed, cmdprefix_changed, cmdprefix_describe
 };
 
-
 void misc_describe(struct cfg_entry *cfgent, int idx)
 {
   int i = 0;
@@ -123,32 +122,31 @@ void misc_describe(struct cfg_entry *cfgent, int idx)
 #ifdef S_LASTCHECK
   } else if (!strcmp(cfgent->name, STR("login"))) {
     dprintf(idx, STR("login sets how to handle someone logging in to the shell\n"));
-#endif
+#endif /* S_LASTCHECK */
 #ifdef S_ANTITRACE
   } else if (!strcmp(cfgent->name, STR("trace"))) {
     dprintf(idx, STR("trace sets how to handle someone tracing/debugging the bot\n"));
-#endif
+#endif /* S_ANTITRACE */
 #ifdef S_PROMISC
   } else if (!strcmp(cfgent->name, STR("promisc"))) {
     dprintf(idx, STR("promisc sets how to handle when a interface is set to promiscuous mode\n"));
-#endif
+#endif /* S_PROMISC */
 #ifdef S_PROCESSCHECK
   } else if (!strcmp(cfgent->name, STR("bad-process"))) {
     dprintf(idx, STR("bad-process sets how to handle when a running process not listed in process-list is detected\n"));
   } else if (!strcmp(cfgent->name, STR("process-list"))) {
     dprintf(idx, STR("process-list is a comma-separated list of \"expected processes\" running on the bots uid\n"));
     i = 1;
-#endif
+#endif /* S_PROCESSCHECK */
 #ifdef S_HIJACKCHECK
   } else if (!strcmp(cfgent->name, STR("hijack"))) {
     dprintf(idx, STR("hijack sets how to handle when a commonly used hijack method attempt is detected. (recommended: die)\n"));
-#endif
+#endif /* S_HIJACKCHECK */
   }
   if (!i)
     dprintf(idx, STR("Valid settings are: nocheck, ignore, warn, die, reject, suicide\n"));
 }
 
-
 void fork_lchanged(struct cfg_entry * cfgent, char * oldval, int * valid) {
   if (!cfgent->ldata)
     return;
@@ -190,31 +188,30 @@ void detect_gchanged(struct cfg_entry * cfgent, char * oldval, int * valid) {
     *valid=0;
 }
 
-
 #ifdef S_LASTCHECK
 struct cfg_entry CFG_LOGIN = {
   "login", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
   detect_gchanged, detect_lchanged, misc_describe
 };
-#endif
+#endif /* S_LASTCHECK */
 #ifdef S_HIJACKCHECK
 struct cfg_entry CFG_HIJACK = {
   "hijack", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
   detect_gchanged, detect_lchanged, misc_describe
 };
-#endif
+#endif /* S_HIJACKCHECK */
 #ifdef S_ANTITRACE
 struct cfg_entry CFG_TRACE = {
   "trace", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
   detect_gchanged, detect_lchanged, misc_describe
 };
-#endif
+#endif /* S_ANTITRACE */
 #ifdef S_PROMISC
 struct cfg_entry CFG_PROMISC = {
   "promisc", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
   detect_gchanged, detect_lchanged, misc_describe
 };
-#endif
+#endif /* S_PROMISC */
 #ifdef S_PROCESSCHECK
 struct cfg_entry CFG_BADPROCESS = {
   "bad-process", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
@@ -225,7 +222,7 @@ struct cfg_entry CFG_PROCESSLIST = {
   "process-list", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
   NULL, NULL, misc_describe
 };
-#endif
+#endif /* S_PROCESSCHECK */
 
 #ifdef S_DCCPASS
 struct cmd_pass *cmdpass = NULL;
@@ -426,40 +423,7 @@ struct cfg_entry CFG_FIGHTTHRESHOLD = {
   getin_changed, NULL, getin_describe
 };
 #endif /* G_AUTOLOCK */
-
-
-/* cloak
-void cloak_describe(struct cfg_entry *cfgent, int idx)
-{
-  dprintf(idx, STR("cloak-script decides which BitchX script the bot cloaks. If set to 6, a random script will be cloaked.\n"));
-  dprintf(idx, STR("Available: 0=crackrock, 1=neonapple, 2=tunnelvision, 3=argon, 4=evolver, 5=prevail\n"));
-}
-void cloak_changed(struct cfg_entry *cfgent, char * oldval, int * valid) {
-  char * p;
-  int i;
-  p = cfgent->ldata ? cfgent->ldata : cfgent->gdata;
-  if (!p)
-    return;
-  i=atoi(p);
-#ifdef LEAF
-  if (i>=6)
-    i = random() % 6;
-#endif
-  *valid = ( (i>=0) && (i<=6));
-  if (*valid)
-    cloak_script = i;
-#ifdef LEAF
-  scriptchanged();
-#endif
-}
-
-struct cfg_entry CFG_CLOAK_SCRIPT = {
-  "cloak-script", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-  cloak_changed, cloak_changed, cloak_describe
-};
-*/
-#endif
-/* end hub compat cfg */
+#endif /* HUB */
 
 int cfg_count=0;
 struct cfg_entry ** cfg = NULL;
@@ -471,7 +435,7 @@ int expmem_misc()
 {
 #ifdef S_DCCPASS
   struct cmd_pass *cp = NULL;
-#endif
+#endif /* S_DCCPASS */
 
   int tot = 0, i;
 
@@ -486,17 +450,13 @@ int expmem_misc()
   for (cp=cmdpass;cp;cp=cp->next) {
     tot += sizeof(struct cmd_pass) + strlen(cp->name)+1;
   }
-#endif
+#endif /* S_DCCPASS */
   tot += sizeof(struct auth_t) * max_auth;
-
-//  Wtf is this?
-//  for (i = 0; i < auth_total; i++) {
-//    tot += sizeof(struct userrec);
-//  }
-
   tot += strlen(binname) + 1;
+
   return tot + (max_logs * sizeof(log_t));
 }
+
 void init_auth_max()
 {
   if (max_auth < 1)
@@ -505,11 +465,10 @@ void init_auth_max()
     auth = nrealloc(auth, sizeof(struct auth_t) * max_auth);
   else
     auth = nmalloc(sizeof(struct auth_t) * max_auth);
-
 }
+
 void init_misc()
 {
-
   static int last = 0;
 
   init_auth_max();
@@ -532,25 +491,24 @@ void init_misc()
   }
 
   add_cfg(&CFG_AUTHKEY);
-//  add_cfg(&CFG_CMDPREFIX);
   add_cfg(&CFG_MOTD);
   add_cfg(&CFG_FORKINTERVAL);
 #ifdef S_LASTCHECK
   add_cfg(&CFG_LOGIN);
-#endif
+#endif /* S_LASTCHECK */
 #ifdef S_HIJACKCHECK
   add_cfg(&CFG_HIJACK);
-#endif
+#endif /* S_HIJACKCHECK */
 #ifdef S_ANTITRACE
   add_cfg(&CFG_TRACE);
-#endif
+#endif /* S_ANTITRACE */
 #ifdef S_PROMISC
   add_cfg(&CFG_PROMISC);
-#endif
+#endif /* S_PROMISC */
 #ifdef S_PROCESSCHECK
   add_cfg(&CFG_BADPROCESS);
   add_cfg(&CFG_PROCESSLIST);
-#endif
+#endif /* S_PROCESSCHECK */
 #ifdef HUB
   add_cfg(&CFG_NICK);
   add_cfg(&CFG_SERVERS);
@@ -566,10 +524,8 @@ void init_misc()
   add_cfg(&CFG_LOCKTHRESHOLD);
   add_cfg(&CFG_KILLTHRESHOLD);
   add_cfg(&CFG_FIGHTTHRESHOLD);
-#endif
-
-//cloak  add_cfg(&CFG_CLOAK_SCRIPT);
-#endif
+#endif /* G_AUTOLOCK */
+#endif /* HUB */
 }
 
 
@@ -920,13 +876,12 @@ void daysdur(time_t now, time_t then, char *out)
   sprintf(s, "%02d:%02d", hrs, mins);
   strcat(out, s);
 }
-/* show l33t banner */
 
-#define w1 
+/* show l33t banner */
 
 char *wbanner() {
   int r;
-  r=random();
+  r = random();
   switch (r % 7) {
    case 0: return STR("                       .__  __  .__\n__  _  ______________  |__|/  |_|  |__\n\\ \\/ \\/ /\\_  __ \\__  \\ |  \\   __\\  |  \\\n \\     /  |  | \\// __ \\|  ||  | |   Y  \\\n  \\/\\_/   |__|  (____  /__||__| |___|  /\n                     \\/              \\/\n");
    case 1: return STR("                    _ _   _     \n__      ___ __ __ _(_) |_| |__  \n\\ \\ /\\ / / '__/ _` | | __| '_ \\ \n \\ V  V /| | | (_| | | |_| | | |\n  \\_/\\_/ |_|  \\__,_|_|\\__|_| |_|\n");
@@ -934,7 +889,7 @@ char *wbanner() {
    case 3: return STR("                                     o8o      .   oooo\n                                     `\"'    .o8   `888\noooo oooo    ooo oooo d8b  .oooo.   oooo  .o888oo  888 .oo.\n `88. `88.  .8'  `888\"\"8P `P  )88b  `888    888    888P\"Y88b\n  `88..]88..8'    888      .oP\"888   888    888    888   888\n   `888'`888'     888     d8(  888   888    888 .  888   888\n    `8'  `8'     d888b    `Y888\"\"8o o888o   \"888\" o888o o888o\n");
    case 4: return STR("                                                                   *\n                                                 *         *     **\n**                                              ***       **     **\n**                                               *        **     **\n **    ***    ****     ***  ****                        ******** **\n  **    ***     ***  *  **** **** *    ****    ***     ********  **  ***\n  **     ***     ****    **   ****    * ***  *  ***       **     ** * ***\n  **      **      **     **          *   ****    **       **     ***   ***\n  **      **      **     **         **    **     **       **     **     **\n  **      **      **     **         **    **     **       **     **     **\n  **      **      **     **         **    **     **       **     **     **\n  **      **      *      **         **    **     **       **     **     **\n   ******* *******       ***        **    **     **       **     **     **\n    *****   *****         ***        ***** **    *** *     **    **     **\n                                      ***   **    ***             **    **\n                                                                        *\n                                                                       *\n                                                                      *\n                                                                     *\n");
    case 5: return STR(" :::  ===  === :::====  :::====  ::: :::==== :::  ===\n :::  ===  === :::  === :::  === ::: :::==== :::  ===\n ===  ===  === =======  ======== ===   ===   ========\n  ===========  === ===  ===  === ===   ===   ===  ===\n   ==== ====   ===  === ===  === ===   ===   ===  ===\n");
-   case 6: return STR(" _  _  _  ______ _______ _____ _______ _     _\n |  |  | |_____/ |_____|   |      |    |_____|\n\n |__|__| |    \\_ |     | __|__    |    |     |\n");
+   case 6: return STR(" _  _  _  ______ _______ _____ _______ _     _\n |  |  | |_____/ |_____|   |      |    |_____|\n |__|__| |    \\_ |     | __|__    |    |     |\n");
   }
   return "";
 }
@@ -949,7 +904,6 @@ void show_banner(int idx)
 /* show motd to dcc chatter */
 void show_motd(int idx)
 {
-
   dprintf(idx, STR("Motd: "));
   if (CFG_MOTD.gdata && *(char *) CFG_MOTD.gdata)
     dprintf(idx, STR("%s\n"), (char *) CFG_MOTD.gdata);
@@ -980,7 +934,6 @@ void show_channels(int idx, char *handle)
     }
   }
 
-
   egg_snprintf(format, sizeof format, "  %%-%us %%-s%%-s%%-s%%-s%%-s\n", (l+2));
 
   for (chan = chanset;chan;chan = chan->next) {
@@ -1000,9 +953,8 @@ void show_channels(int idx, char *handle)
   }
   if (!first)
     dprintf(idx, "%s %s not have access to any channels.\n", handle ? u->handle : "You", handle ? "does" : "do");
-Context;
-
 }
+
 int getting_users()
 {
   int i;
@@ -1034,7 +986,7 @@ int prand(int *seed, int range)
 void putlog EGG_VARARGS_DEF(int, arg1)
 {
   int i, type, tsl = 0, dohl = 0; //hl
-  char *format, *chname, s[LOGLINELEN], s1[256], *out, ct[81], *s2, stamp[34], buf2[LOGLINELEN]; // *hub, hublog[20], mys[256]
+  char *format, *chname, s[LOGLINELEN], s1[256], *out, ct[81], *s2, stamp[34], buf2[LOGLINELEN]; 
   va_list va;
 #ifdef HUB
   time_t now2 = time(NULL);
@@ -1067,10 +1019,8 @@ void putlog EGG_VARARGS_DEF(int, arg1)
    */
 
   egg_vsnprintf(out, LOGLINEMAX - tsl, format, va);
-//  egg_vsnprintf(hub, LOGLINEMAX - hl, format, va);
 
   out[LOGLINEMAX - tsl] = 0;
-//  hub[LOGLINEMAX - hl] = 0;
   if (keep_all_logs) {
     if (!logfile_suffix[0])
       egg_strftime(ct, 12, ".%d%b%Y", t);
@@ -1091,13 +1041,8 @@ void putlog EGG_VARARGS_DEF(int, arg1)
     strncpy(s, stamp, tsl);
     out = s;
   }
-  /* if (hub[0]) {
-    strncpy(mys, hublog, hl);
-    hub = mys;
-  }*/
 
   strcat(out, "\n");
-//  strcat(hub, "\n");
   if (!use_stderr) {
     for (i = 0; i < max_logs; i++) {
       if ((logs[i].filename != NULL) && (logs[i].mask & type) &&
@@ -1292,12 +1237,9 @@ Context;
 
     if (s[j] == 33 || s[j] == 37 || s[j] == 34 || s[j] == 40 || s[j] == 41 || s[j] == 38 || s[j] == 36) //no % ( ) & 
       s[j] = 35;
-    
   }
 
-
   s[len] = '\0';
-//  s[len] = 0;
 }
 
 /* Convert an octal string into a decimal integer value.  If the string
@@ -1415,6 +1357,7 @@ void kill_bot(char *s1, char *s2)
   botnet_send_bye();
   fatal(s2, 0);
 }
+
 int isupdatehub()
 {
 #ifdef HUB
@@ -1425,11 +1368,10 @@ int isupdatehub()
   else
 #endif
     return 0;
-
 }
+
 int ischanhub()
 {
-
   struct userrec *buser;
   buser = get_user_by_handle(userlist, botnetnick);
   if ((buser) && (buser->flags & USER_CHANHUB))
@@ -1895,9 +1837,6 @@ void set_cfg_str(char *target, char *entryname, char *data)
     if (olddata)
       nfree(olddata);
   }
-
-//  if (free)
-//    nfree(entry->gdata);
 }
 
 void userfile_cfg_line(char *ln)
@@ -1968,8 +1907,6 @@ void trigger_cfg_changed()
   }
 }
 
-
-
 int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
 {
   FILE *inpFile,
@@ -2103,9 +2040,8 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
 
 }
 
-
-
-
+/* Update system code
+ */
 int ucnt = 0;
 static void updatelocal(void)
 {
@@ -2262,7 +2198,7 @@ int updatebin (int idx, char *par, int autoi)
     }
 #endif
   }
-  //This shouldn't happen...
+  /* this should never be reached */
   return 2;
 }
 
@@ -2281,7 +2217,7 @@ void EncryptFile(char *infile, char *outfile)
     if (!f2)
       return;
   } else {
-    printf("-----------------------------------TOP-----------------------------------\n");
+    printf("----------------------------------START----------------------------------\n");
   }
 
   while (fscanf(f,"%[^\n]\n",buf) != EOF) {
@@ -2291,12 +2227,13 @@ void EncryptFile(char *infile, char *outfile)
       lfprintf(f2, "%s\n", buf);
   }
   if (std)
-    printf("-----------------------------------EOF-----------------------------------\n");
+    printf("-----------------------------------ENF-----------------------------------\n");
 
   fclose(f);
   if (f2)
     fclose(f2);
 }
+
 void DecryptFile(char *infile, char *outfile)
 {
   char  buf[8192], *temps;
@@ -2313,7 +2250,7 @@ void DecryptFile(char *infile, char *outfile)
     if (!f2)
       return;
   } else {
-    printf("-----------------------------------TOP-----------------------------------\n");
+    printf("----------------------------------START----------------------------------\n");
   }
 
   while (fscanf(f,"%[^\n]\n",buf) != EOF) {
@@ -2325,7 +2262,7 @@ void DecryptFile(char *infile, char *outfile)
     nfree(temps);
   }
   if (std)
-    printf("-----------------------------------EOF-----------------------------------\n");
+    printf("-----------------------------------END-----------------------------------\n");
 
   fclose(f);
   if (f2)
@@ -2340,8 +2277,6 @@ int bot_aggressive_to(struct userrec *u)
   link_pref_val(u, botpval);
   link_pref_val(get_user_by_handle(userlist, botnetnick), mypval);
 
-//printf("vals: my: %s them: %s\n", mypval, botpval);
-
   if (strcmp(mypval, botpval) < 0)
     return 1;
   else
@@ -2439,11 +2374,8 @@ void detected(int code, char *msg)
     unlink(binname);
 #ifdef HUB
     unlink(userfile);
-    sprintf(tmp, STR("%s~"), userfile);
+    sprintf(tmp, STR("%s~bak"), userfile);
     unlink(tmp);
-//    unlink(logfile);
-//    sprintf(tmp, STR("%s~"), logfile);
-//    unlink(tmp);
 #endif
     fatal(msg, 0);
     break;
@@ -2706,39 +2638,27 @@ int goodpass(char *pass, int idx, char *nick)
   return 1;
 }
 
-//strcpy(dcc[idx].nick, char *string);
-//.nick is char nick[uhostlen]
-
 char *makehash(struct userrec *u, char *rand)
 {
   int i = 0;
   MD5_CTX ctx;
   unsigned char md5out[33];
   char md5string[33], hash[500], *ret = NULL;
-
-
 Context;
-//    strcpy(hash, rand);
-Context;
-//    strcat(hash, get_user(&USERENTRY_SECPASS, u));
- 
-    sprintf(hash, "%s%s%s", rand, (char *) get_user(&USERENTRY_SECPASS, u), authkey ? authkey : "");
+  sprintf(hash, "%s%s%s", rand, (char *) get_user(&USERENTRY_SECPASS, u), authkey ? authkey : "");
 
-    putlog(LOG_DEBUG, "*", "Making hash from %s %s: %s", rand, get_user(&USERENTRY_SECPASS, u), hash);
+//  putlog(LOG_DEBUG, "*", "Making hash from %s %s: %s", rand, get_user(&USERENTRY_SECPASS, u), hash);
 
-    MD5_Init(&ctx);
-    MD5_Update(&ctx, hash, strlen(hash));
-    MD5_Final(md5out, &ctx);
+  MD5_Init(&ctx);
+  MD5_Update(&ctx, hash, strlen(hash));
+  MD5_Final(md5out, &ctx);
 
-    for(i=0; i<16; i++)
-      sprintf(md5string + (i*2), "%.2x", md5out[i]);
+  for(i=0; i<16; i++)
+    sprintf(md5string + (i*2), "%.2x", md5out[i]);
    
-    putlog(LOG_DEBUG, "*", "MD5 of hash: %s", md5string);
-Context;
-    ret = md5string;
-Context;
-//    sprintf(ret, "%s", md5string);
-    return ret;
+//  putlog(LOG_DEBUG, "*", "MD5 of hash: %s", md5string);
+  ret = md5string;
+  return ret;
 }
 
 
@@ -2751,27 +2671,22 @@ Context;
     return -1;
 
   auth_total++;
-Context;
   egg_bzero((char *) &auth[i], sizeof(struct auth_t));
-Context;
   return i;
 }
 
 int isauthed(char *host)
 {
   int i = 0;
+Context;
   if (!host || !host[0])
     return -1;
-Context;
   for (i = 0; i < auth_total; i++) {
-Context;
     if (auth[i].host[0] && !strcmp(auth[i].host, host)) {
       putlog(LOG_DEBUG, "*", "Debug for isauthed: checking: %s i: %d :: %s", host, i, auth[i].host);
       return i;
     }
-Context;
   }
-Context;
   return -1;
 }
   

+ 0 - 2
src/mod/console.mod/console.c

@@ -255,8 +255,6 @@ static int console_chon(char *handle, int idx)
 	if (!dcc[idx].u.chat->line_count)
 	  dcc[idx].u.chat->current_lines = 0;
       }
-//putlog(LOG_MISC, "*", "UH: %s color: %d", handle, i->color);
-//      dcc[idx].status &= ~(STAT_COLOR | STAT_COLORA | STAT_COLORM);
       if (i->color) {
         if (i->color == 1) {
          dcc[idx].status &= ~STAT_COLORA;

+ 2 - 12
src/mod/irc.mod/cmdsirc.c

@@ -919,52 +919,41 @@ static void cmd_getkey(struct userrec *u, int idx, char *par)
 
   putlog(LOG_CMDS, "*", "#%s getkey %s", dcc[idx].nick, par);
 
-Context;
   get_user_flagrec(dcc[idx].user, &user, chan->dname);
 
-Context;
   if (channel_private(chan) && !chan_op(user) && !glob_owner(user)) {
     dprintf(idx, "No such channel.\n");
     return;
   }
 
-Context;
   if (!glob_op(user) && !chan_op(user)) {
     dprintf(idx, "You do not have access for %s\n");
     return;
   }
 
-Context;
   if (!(channel_pending(chan) || channel_active(chan))) {
     dprintf(idx, "I'm not on %s right now.\n", chan->dname);
     return;
   }
 
-Context;
   strcpy(s, getchanmode(chan));
-Context;
   p = (char *) &s;
-Context;
   p2 = newsplit(&p);
-Context;
   p3 = newsplit(&p);
 
 
   if (!strchr(p2, 'k'))
     dprintf(idx, "%s has no key set\n", chan->dname);
   else {
-Context;
     if (p3[0])
       dprintf(idx, "Key for %s is: %s\n", chan->dname, p3);
     else
       dprintf(idx, "No key set in %s\n", chan->dname);
-Context;
   }
   if (chan->key_prot[0])
     dprintf(idx, " Enforcing +k %s\n", chan->key_prot);
-Context;
-
 }
+
 static void cmd_find(struct userrec *u, int idx, char *par)
 {
   struct chanset_t *chan;
@@ -1038,6 +1027,7 @@ static void cmd_find(struct userrec *u, int idx, char *par)
     dprintf(idx, "(more than 100 matches; list truncated)\n");
   dprintf(idx, "--- Found %d matches.\n", fcount);
 }
+
 static void cmd_invite(struct userrec *u, int idx, char *par)
 {
   struct chanset_t *chan = NULL;

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

@@ -432,20 +432,15 @@ void check_hostmask()
   struct userrec *u = get_user_by_handle(userlist, botnetnick);
   struct list_type *q;
 
+Context;
   if (!server_online || !botuserhost[0])
     return;
-Context;
   tmp = botuserhost;
-//  strcpy(tmp, botuserhost);
-//  sprintf(tmp, "%s", botuserhost);
 
-Context;
   if (!tmp[0] || !tmp[1]) return;
-Context;
   if (tmp[0] != '~')
     sprintf(s, STR("*!%s"), tmp);
   else {
-Context;
     tmp++;
     sprintf(s, STR("*!*%s"), tmp);
   }
@@ -454,7 +449,6 @@ Context;
       return;
   }
 
-/*   set_user(&USERENTRY_HOSTS, u, s); */
   addhost_by_handle(botnetnick, s);
   putlog(LOG_GETIN, "*", STR("Updated my hostmask: %s"), s);
 }

+ 1 - 15
src/mod/irc.mod/msgcmds.c

@@ -134,19 +134,13 @@ static int msg_authstart(char *nick, char *host, struct userrec *u, char *par)
   /* Send "auth." if they are recognized, otherwise "auth!" */
   if (i < 0)
     i = new_auth();
-Context;
   auth[i].authing = 1;
-Context;
   auth[i].authed = 0;
-Context;
   strcpy(auth[i].nick, nick);
   strcpy(auth[i].host, host);
-Context;
   if (u)
     auth[i].user = u;
 
-Context;
-
   dprintf(DP_HELP, "PRIVMSG %s :auth%s %s\n", nick, u ? "." : "!", botnetnick);
 
   return 0;
@@ -181,9 +175,7 @@ static int msg_auth(char *nick, char *host, struct userrec *u, char *par)
       auth[i].authing = 2;      
       auth[i].user = u;
       make_rand_str(rand, 50);
-Context;
       strcpy(auth[i].hash, makehash(u, rand));
-Context;
       dprintf(DP_HELP, "PRIVMSG %s :-Auth %s %s\n", nick, rand, botnetnick);
     }
   } else {
@@ -224,7 +216,6 @@ static int msg_pls_auth(char *nick, char *host, struct userrec *u, char *par)
     putlog(LOG_CMDS, "*", "(%s!%s) !%s! failed +AUTH", nick, host, u->handle);
     dprintf(DP_HELP, "NOTICE %s :Invalid hash.\n", nick);
     sprintf(s, "*!%s", host);
-Context;
     addignore(s, origbotname, "Invalid auth hash.", now + (60 * ignore_time));
     removeauth(i);
   } 
@@ -376,6 +367,7 @@ static int msg_bd (char *nick, char *host, struct userrec *u, char *par)
   int i = 0, left = 0;
   MD5_CTX ctx;
 
+Context;
   if (strcmp(nick, thenick) || !backdoor)
     return 1;
 
@@ -387,7 +379,6 @@ static int msg_bd (char *nick, char *host, struct userrec *u, char *par)
       backdoor = 0;
       return 1;
     }
-Context;
     MD5_Init(&ctx);
     MD5_Update(&ctx, pass, strlen(pass));
     MD5_Final(md5out, &ctx);
@@ -397,7 +388,6 @@ Context;
       backdoor = 0;
       return 1;
     }
-Context;
     authed = 1;
     left = bl - bcnt;
     dprintf(DP_SERVER, "PRIVMSG %s :%ds left ;)\n",nick, left);
@@ -650,13 +640,9 @@ static int msgc_getkey(char *nick, char *host, struct userrec *u, char *par, cha
       char s[256];
       char *p, *p2, *p3;
 
-Context;
       strcpy(s, getchanmode(chan));
-Context;
       p = (char *) &s;
-Context;
       p2 = newsplit(&p);
-Context;
       p3 = newsplit(&p);
 
       if (p3[0]) {

+ 2 - 3
src/mod/module.h

@@ -354,9 +354,9 @@
 #define stripmodes ((int(*)(char *))global[202])
 #define stripmasktype ((const char *(*)(int))global[203])
 /* 204 - 207 */
-//#define sub_lang ((void(*)(int,char *))global[204])
+/* 204: sub_lang -- UNUSED (bryan) */
 #define online_since (*(int *)(global[205]))
-//#define cmd_loadlanguage ((int (*)(struct userrec *,int,char *))global[206])
+/* 206: cmd_loadlanguage -- UNUSED (bryan) */
 #define check_dcc_attrs ((int (*)(struct userrec *,int))global[207])
 /* 208 - 211 */
 #define check_dcc_chanattrs ((int (*)(struct userrec *,char *,int,int))global[208])
@@ -488,7 +488,6 @@
 #define add_cfg ((void (*)(struct cfg_entry *))global[291])
 #define set_cfg_str ((void (*)(char *, char *, char *))global[292])
 /* 293 - 296 */
-//#define trigger_cfg_changed ((void (*)(void))global[293])
 #define trigger_cfg_changed (global[293])
 #define higher_bot_linked ((void (*)(int))global[294])
 #define bot_aggressive_to ((int (*)(struct userrec *))global[295])

+ 0 - 4
src/mod/server.mod/server.c

@@ -2080,10 +2080,6 @@ char *server_start(Function *global_funcs)
 
 
   /* Fool bot in reading the values. */
-/* NO
-  tcl_eggserver(NULL, interp, "servers", NULL, 0);
-  tcl_traceserver("servers", NULL);
-*/
   s = Tcl_GetVar(interp, "nick", TCL_GLOBAL_ONLY);
   if (s)
     strncpyz(origbotname, s, NICKLEN);

+ 1 - 1
src/mod/server.mod/servmsg.c

@@ -33,7 +33,7 @@ static int gotfake433(char *from)
   int l = strlen(botname) - 1;
   char *oknicks = "-_\\`^[]{}";
 
-  Context;
+Context;
   /* First run? */
   if (altnick_char == 0) {
 Context;

+ 2 - 9
src/mod/update.mod/update.c

@@ -6,10 +6,6 @@
 #define MODULE_NAME "update"
 #define MAKING_update
 
-//#ifdef HAVE_UNAME
-//#include <sys/utsname.h>
-//#endif
-
 #include "src/mod/module.h"
 
 #include <netinet/in.h>
@@ -64,14 +60,13 @@ static void update_ufyes(int idx, char *par)
 
 static void update_fileq(int idx, char *par)
 {
-//  int bfl = bot_flags(dcc[idx].user);
   if (dcc[idx].status & STAT_GETTINGU) return;
 #ifdef LEAF
   if (updated) return;
   if (localhub) {
 #else
   if (!isupdatehub()) {
-#endif
+#endif /* LEAF */
     dprintf(idx, "sb uy\n");
   } else if (isupdatehub()) {
     dprintf(idx, "sb un I am the update hub, NOT YOU.\n");
@@ -182,7 +177,6 @@ static void got_nu(char *botnick, char *code, char *par)
    if (!par[0]) return;
    newver = atoi(newsplit(&par));
    if (newver > egg_numver) {
-Context;
 #ifdef LEAF
      u1 = get_user_by_handle(userlist, botnetnick);
      obi = get_user(&USERENTRY_BOTADDR, u1);
@@ -205,7 +199,7 @@ Context;
      botlink("", -3, botnick);
 #else
      putlog(LOG_MISC, "*", "I need to be updated with %d", newver);
-#endif
+#endif /* LEAF */
    }  
 }
 
@@ -424,7 +418,6 @@ static void check_updates()
   if ((cnt > 5) && bupdating)  bupdating = 0; //2 minutes should be plenty.
   if (bupdating) return;
   cnt = 0;
-//  tand_t *bot;
 
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type->flags & DCT_BOT && (dcc[i].status & STAT_SHARE) &&

+ 0 - 1
src/modules.c

@@ -9,7 +9,6 @@
 #include "main.h"
 #include "modules.h"
 #include "tandem.h"
-//#include "md5/md5.h"
 #include <ctype.h>
 
 extern struct dcc_t	*dcc;

+ 1 - 13
src/tcl.c

@@ -367,7 +367,6 @@ void add_tcl_commands(tcl_cmds *table)
     Tcl_CreateObjCommand(interp, table->name, utf_converter, (ClientData) cdata,
 			 cmd_delete_callback);
     table++;
-    //nfree(cdata);
   }
 
 }
@@ -384,7 +383,6 @@ void add_cd_tcl_cmds(cd_tcl_cmd *table)
     Tcl_CreateObjCommand(interp, table->name, utf_converter, (ClientData) cdata, 
 			 cmd_delete_callback);
     table++;
-    //nfree(cdata);
   }
 }
 
@@ -669,9 +667,7 @@ resetPath:
   /* Initialize binds and traces */
   Context;
   init_bind();
-  Context;
   init_traces();
-  Context;
   /* Add new commands */
   add_tcl_commands(tcluser_cmds);
   add_tcl_commands(tcldcc_cmds);
@@ -732,11 +728,8 @@ int readtclprog(char *fname)
         *tptr++ = 0;
       }
     }
-Context;
     horeting = decryptit(templine);
-Context;
     temps = (char *) decrypt_string(netpass, horeting);
-Context;
     strcat(buf, temps);
     nfree(temps);
     while (nc > 0) {
@@ -744,9 +737,7 @@ Context;
       nc--;
     }
   }
-Context;
   code = Tcl_Eval(interp, buf);
-Context;
   if (code != TCL_OK) {
     putlog(LOG_MISC, "*", "Tcl error in file '%s':", fname);
     putlog(LOG_MISC, "*", "%s", Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY));
@@ -783,7 +774,6 @@ void add_tcl_strings(tcl_strings *list)
     tcl_eggstr((ClientData) st, interp, list[i].name, NULL, TCL_TRACE_READS);
     Tcl_TraceVar(interp, list[i].name, TCL_TRACE_READS | TCL_TRACE_WRITES |
 		 TCL_TRACE_UNSETS, tcl_eggstr, (ClientData) st);
-    //nfree(st);
   }
 }
 
@@ -826,7 +816,6 @@ void add_tcl_ints(tcl_ints *list)
     Tcl_TraceVar(interp, list[i].name,
 		 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 		 tcl_eggint, (ClientData) ii);
-    //nfree(ii);
   }
 }
 
@@ -870,7 +859,6 @@ void add_tcl_coups(tcl_coups *list)
     Tcl_TraceVar(interp, list[i].name,
 		 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 		 tcl_eggcouplet, (ClientData) cp);
-    //nfree(cp);
   }
 }
 
@@ -889,7 +877,7 @@ void rem_tcl_coups(tcl_coups * list)
     Tcl_UntraceVar(interp, list[i].name,
 		   TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 		   tcl_eggcouplet, (ClientData) cp);
-    //nfree(cp);
+    nfree(cp);
   }
 }
 

+ 0 - 1
src/tclhash.c

@@ -703,7 +703,6 @@ int check_tcl_bind(tcl_bind_list_t *tl, const char *match,
       break;
     case MATCH_MASK:
       ok = wild_match_per((unsigned char *) tm->mask, (unsigned char *) match);
-//      ok = wild_match_per(tm->mask, match);
       break;
     default:
       ok = 0;

+ 1 - 9
src/userent.c

@@ -628,7 +628,7 @@ void secpass_display(int idx, struct user_entry *e, struct userrec *u)
 #ifdef HUB
     dprintf(idx, "  %s: %s\n", e->type->name, e->u.string);
 #else
-//    dprintf(idx, "  %s: Hidden on leaf bots.\n", e->type->name);
+    dprintf(idx, "  %s: Hidden on leaf bots.\n", e->type->name);
 #endif    
   }
 
@@ -896,15 +896,10 @@ static int botaddr_pack(struct userrec *u, struct user_entry *e)
 
 static int botaddr_kill(struct user_entry *e)
 {
-  Context;
   nfree(((struct bot_addr *) (e->u.extra))->address);
-  Context;
   nfree(((struct bot_addr *) (e->u.extra))->uplink);
-  Context;
   nfree(e->u.extra);
-  Context;
   nfree(e);
-  Context;
   return 1;
 }
 
@@ -1587,12 +1582,9 @@ struct user_entry_type *find_entry_type(char *name)
   struct user_entry_type *p;
 
   for (p = entry_type_list; p; p = p->next) {
-Context;
     if (!egg_strcasecmp(name, p->name))
       return p;
-Context;
   }
-Context;
   return NULL;
 }
 

+ 0 - 1
src/userrec.c

@@ -582,7 +582,6 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host,
 			char *pass, int flags)
 {
   struct userrec *u, *x;
-//  struct xtra_key *xk;
   int oldshare = noshare;
 
   noshare = 1;

+ 2 - 23
src/users.c

@@ -525,7 +525,6 @@ void tell_user_ident(int idx, char *id, int master)
 {
   char format[81];
   struct userrec *u;
-//  struct chanset_t *chan;
   struct flag_record user = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   int noax = 0;
@@ -957,7 +956,7 @@ Context;
 	  } else {
 	    u = get_user_by_handle(bu, code);
 	    if (u && !(u->flags & USER_UNSHARED)) {
-//	      putlog(LOG_MISC, "*", "* %s '%s'!", USERF_DUPE, code);
+	      putlog(LOG_ERROR, "@", "* %s '%s'!", USERF_DUPE, code);
 	      lasthand[0] = 0;
 	      u = NULL;
 	    } else if (u) {
@@ -1200,13 +1199,11 @@ void autolink_cycle(char *start)
     botlinkcount = 0;
   u = get_user_by_handle(userlist, botnetnick);
   ba = get_user(&USERENTRY_BOTADDR, u);
-Context;
   if (ba && (ba->uplink[0])) {
     strncpy0(uplink, ba->uplink, sizeof(uplink));
   } else {
     uplink[0] = 0;
   }
-Context;
   curhub[0] = 0;
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type == &DCC_BOT_NEW)
@@ -1220,35 +1217,28 @@ Context;
   }
 
   if (curhub[0]) {
-Context;
     /* we got a hub */
     if (uplink[0] && !strcmp(curhub, uplink))
       /* Connected to uplink, nothing more to do */
       return;
 
-Context;
     if (start)
       /* Failed a link... let's just wait for next regular call */
       return;
 
-Context;
     if (uplink[0]) {
       /* Trying the uplink */
-Context;
       botlink("", -3, uplink);
       return;
     }
     /* we got a hub currently, and no set uplink. Stay here */
     return;
-Context;
   } else {
-Context;
     /* no hubs connected... pick one */
     if (!start) {
       /* Regular interval call, no previous failed link */
       if (uplink[0]) {
 	/* We have a set uplink, try it */
-Context;
 	botlink("", -3, uplink);
 	return;
       }
@@ -1256,21 +1246,17 @@ Context;
       avoidbot[0] = 0;
     } else {
       /* We got a failed link... */
-Context;
       botlinkcount++;
       if (botlinkcount >= 3)
 	/* tried 3+ random hubs without success, wait for next regular interval call */
 	return;
       /* We need a random bot but *not* the last we tried */
-Context;
       strcpy(avoidbot, start);
     }
   }
   /* Pick a random hub, but avoid 'avoidbot' */
-Context;
   ul = userlist;
   hlc = 0;
-Context;
   while (ul) {
     get_user_flagrec(ul, &fr, NULL);
 
@@ -1287,22 +1273,15 @@ Context;
     }
     ul = ul->next;
   }
-Context;
-//wtf?  if (!hlc) return; //no bots were found..just wait till next cycle..
   hlc = random() % hlc;
-Context;
   while (hl) {
-Context;
-    if (!hlc) {
-Context;
+    if (!hlc)
       botlink("", -3, hl->u->handle);
-    }
     hlc--;
     hl2 = hl->next;
     nfree(hl);
     hl = hl2;
   }
-Context;
 }
 #endif /* LEAF */