Procházet zdrojové kódy

* Fixed bots with '`' in nick not spawning correctly. (#88)

svn: 2130
Bryan Drewery před 21 roky
rodič
revize
a420f51753
3 změnil soubory, kde provedl 8 přidání a 4 odebrání
  1. 1 0
      doc/UPDATES
  2. 6 3
      src/conf.c
  3. 1 1
      src/misc.c

+ 1 - 0
doc/UPDATES

@@ -133,6 +133,7 @@ Lines prefixed with '-' were disabled before release and are not finishsed, or a
 * Possibly fixed a very rare userfile sharing desync (#58)
 * Fixed wrong spacing in cmd_status
 * Fixed cmd_boot attempting to boot a remote simulated dcc created by .botcmd. (#90)
+* Fixed bots with '`' in nick not spawning correctly. (#88)
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 6 - 3
src/conf.c

@@ -85,7 +85,7 @@ void spawnbot(const char *nick)
   char *run = (char *) my_calloc(1, size);
   int status = 0;
 
-  simple_snprintf(run, size, "%s -B %s", binname, nick);
+  simple_snprintf(run, size, "%s -B %s", binname, replace(nick, "`", "\\`"));
   sdprintf("Spawning '%s': %s", nick, run);
   status = system(run);
   if (status == -1 || WEXITSTATUS(status))
@@ -905,7 +905,7 @@ conf_bot *conf_bots_dup(conf_bot *src)
 
 void kill_removed_bots(conf_bot *oldlist, conf_bot *newlist)
 {
-  if (oldlist && newlist) {
+  if (oldlist) {
     conf_bot *botold = NULL, *botnew = NULL;
     bool found = 0;
     struct userrec *u = NULL;
@@ -922,11 +922,13 @@ void kill_removed_bots(conf_bot *oldlist, conf_bot *newlist)
         conf_killbot(NULL, botold, SIGKILL);
         if ((u = get_user_by_handle(userlist, botold->nick))) {
           putlog(LOG_MISC, "*", "Removing '%s' as it has been removed from the binary config.", botold->nick);
-          if (!conf.bot->hub)
+          if (server_online)
             check_this_user(botold->nick, 1, NULL);
           if (deluser(botold->nick)) {
+            /* there is likely NO conf[] 
             if (conf.bot->hub)
               write_userfile(-1);
+            */
           }
         }
       }
@@ -943,6 +945,7 @@ fill_conf_bot()
   char *mynick = NULL;
   conf_bot *me = NULL;
 
+  /* This first clause should actually be obsolete */
   if (!used_B && conf.bots && conf.bots->nick) {
     mynick = strdup(conf.bots->nick);
     strlcpy(origbotname, conf.bots->nick, NICKLEN + 1);

+ 1 - 1
src/misc.c

@@ -682,7 +682,7 @@ restart(int idx)
   argv[0] = strdup(binname);
   argv[1] = strdup(shit);
   argv[2] = strdup("-B");
-  argv[3] = strdup(conf.bot->nick);
+  argv[3] = strdup(replace(conf.bot->nick, "`", "\\`"));
   argv[4] = NULL;
 
   unlink(conf.bot->pid_file);