Pārlūkot izejas kodu

* Fixed some putlog()s with \n at the end.
* Added confedit() S_CONFEDIT (crontab -e style config editing)


svn: 709

Bryan Drewery 22 gadi atpakaļ
vecāks
revīzija
bb11526e00
17 mainītis faili ar 311 papildinājumiem un 89 dzēšanām
  1. 1 0
      config.h.in
  2. 3 0
      doc/UPDATES
  3. 1 0
      pack/pack.cfg.sample
  4. 1 1
      src/botcmd.c
  5. 1 6
      src/botmsg.c
  6. 4 4
      src/cfg.c
  7. 227 51
      src/conf.c
  8. 12 1
      src/conf.h
  9. 5 5
      src/log.c
  10. 30 16
      src/main.c
  11. 2 2
      src/misc.c
  12. 1 0
      src/misc.h
  13. 1 1
      src/mod/channels.mod/channels.c
  14. 1 1
      src/mod/irc.mod/irc.c
  15. 2 0
      src/modules.h
  16. 16 0
      src/shell.c
  17. 3 1
      src/shell.h

+ 1 - 0
config.h.in

@@ -351,6 +351,7 @@
 #undef S_AUTHHASH
 #undef S_AUTOAWAY
 #undef S_AUTOLOCK
+#undef S_CONFEDIT
 #undef S_DCCAUTH
 #undef S_DCCPASS
 #undef S_GARBLESTRINGS

+ 3 - 0
doc/UPDATES

@@ -14,6 +14,9 @@ This is a summary of ChangeLog basically.
 11.Added extort to CREDITS.
 12.Rewrote cmd_chanset to parse options correctly.
 13.Cmds that auto save userfile now alert you of that.
+14.binary -C now opens up a config editor, (crontab -e style).
+15.Invalid cmdline options are now silently ignored.
+16.Bad cmdline passwords now spoof an error.
 
 1.0.15 (Non-Release Version)
 1.cmd_randstring is now limited to 300.

+ 1 - 0
pack/pack.cfg.sample

@@ -58,6 +58,7 @@ HUB <God god.net 666 god ~God ~george>
 + AUTHHASH              Require a script to AUTH (using hashes)
 + AUTOAWAY		Random autoaway/return on IRC
 - AUTOLOCK		Will lock channels upon certain conditions
++ CONFEDIT              Crontab -e style config editor
 + DCCAUTH               Require Auth hashing with scripts for dcc party line.
 + DCCPASS		DCC command passwords
 + GARBLESTRINGS		Encrypt strings in binary

+ 1 - 1
src/botcmd.c

@@ -855,7 +855,7 @@ static void bot_buildts(int idx, char *par)
 
 static void bot_timesync(int idx, char *par)
 {
-  putlog(LOG_DEBUG, "@", "Got timesync from %s: %s\n", dcc[idx].nick, par);
+  putlog(LOG_DEBUG, "@", "Got timesync from %s: %s", dcc[idx].nick, par);
   timesync = atoi(par) - now;
 #ifdef HUB
   send_timesync(-1);

+ 1 - 6
src/botmsg.c

@@ -412,12 +412,7 @@ void botnet_send_reject(int idx, char *fromp, char *frombot, char *top, char *to
 
 void putallbots(char *par)
 { 
-  char msg[SGRAB - 110] = "";
-
-  if (!par || !par[0])
-    return;
-  strncpyz(msg, par, sizeof msg);
-  botnet_send_zapf_broad(-1, conf.bot->nick, NULL, msg);
+  botnet_send_zapf_broad(-1, conf.bot->nick, NULL, par);
 }
 
 void putbot(char *bot, char *par)

+ 4 - 4
src/cfg.c

@@ -244,7 +244,7 @@ void deflag_user(struct userrec *u, int why, char *msg, struct chanset_t *chan)
     sprintf(tmp, STR("Reason #%i"), why);
   }
   if (ent && ent->gdata && !strcmp(ent->gdata, STR("deop"))) {
-    putlog(LOG_WARN, "*",  STR("Setting %s +d (%s): %s\n"), u->handle, tmp, msg);
+    putlog(LOG_WARN, "*",  STR("Setting %s +d (%s): %s"), u->handle, tmp, msg);
     sprintf(tmp2, STR("+d: %s (%s)"), tmp, msg);
     set_user(&USERENTRY_COMMENT, u, tmp2);
     get_user_flagrec(u, &fr, chan->dname);
@@ -252,7 +252,7 @@ void deflag_user(struct userrec *u, int why, char *msg, struct chanset_t *chan)
     fr.chan = USER_DEOP;
     set_user_flagrec(u, &fr, chan->dname);
   } else if (ent && ent->gdata && !strcmp(ent->gdata, STR("kick"))) {
-    putlog(LOG_WARN, "*",  STR("Setting %s +dk (%s): %s\n"), u->handle, tmp, msg);
+    putlog(LOG_WARN, "*",  STR("Setting %s +dk (%s): %s"), u->handle, tmp, msg);
     sprintf(tmp2, STR("+dk: %s (%s)"), tmp, msg);
     set_user(&USERENTRY_COMMENT, u, tmp2);
     get_user_flagrec(u, &fr, chan->dname);
@@ -260,10 +260,10 @@ void deflag_user(struct userrec *u, int why, char *msg, struct chanset_t *chan)
     fr.chan = USER_DEOP | USER_KICK;
     set_user_flagrec(u, &fr, chan->dname);
   } else if (ent && ent->gdata && !strcmp(ent->gdata, STR("delete"))) {
-    putlog(LOG_WARN, "*",  STR("Deleting %s (%s): %s\n"), u->handle, tmp, msg);
+    putlog(LOG_WARN, "*",  STR("Deleting %s (%s): %s"), u->handle, tmp, msg);
     deluser(u->handle);
   } else {
-    putlog(LOG_WARN, "*",  STR("No user flag effects for %s (%s): %s\n"), u->handle, tmp, msg);
+    putlog(LOG_WARN, "*",  STR("No user flag effects for %s (%s): %s"), u->handle, tmp, msg);
     sprintf(tmp2, STR("Warning: %s (%s)"), tmp, msg);
     set_user(&USERENTRY_COMMENT, u, tmp2);
   }

+ 227 - 51
src/conf.c

@@ -12,10 +12,15 @@
 #include "main.h"
 #include "salt.h"
 #include "misc.h"
+#include "misc_file.h"
 
 #include <errno.h>
-#include <pwd.h>
+#include <paths.h>
 #include <sys/types.h>
+#ifdef S_CONFEDIT
+#include <sys/wait.h>
+#endif /* S_CONFEDIT */
+#include <sys/stat.h>
 #include <signal.h>
 
 extern char             origbotname[], tempdir[],
@@ -28,13 +33,135 @@ conf_t		conf;		/* global conf struct */
 
 static conf_t conffile;
 
+#ifdef S_CONFEDIT
+static uid_t save_euid, save_egid;
+static int swap_uids()
+{
+        save_euid = geteuid(); save_egid = getegid();
+        return (setegid(getgid()) || seteuid(getuid())) ? -1 : 0;
+}
+static int swap_uids_back()
+{
+        return (setegid(save_egid) || seteuid(save_euid)) ? -1 : 0;
+}
+
+
+void confedit(char *cfile) {
+    FILE *f = NULL;
+    char s[DIRMAX] = "", *editor = NULL;
+    int fd;
+    mode_t um;
+    int waiter;
+    pid_t pid, xpid;
+
+    egg_snprintf(s, sizeof s, STR("%s.conf-XXXXXX"), tempdir);
+    um = umask(077);
+
+    if ((fd = mkstemp(s)) == -1 || (f = fdopen(fd, "w")) == NULL) {
+      fatal(STR("Can't create temp conffile!"), 0);
+    }
+
+    writeconf(NULL, f, CONF_COMMENT);
+
+    (void) umask(um);
+
+    if (!can_stat(s)) 
+      fatal("Cannot stat tempfile", 0);
+
+    /* Okay, edit the file */
+
+    if ((!((editor = getenv("VISUAL")) && strlen(editor)))
+     && (!((editor = getenv("EDITOR")) && strlen(editor)))
+        ) {
+            editor = "vi";
+/*
+            #if defined(DEBIAN)
+              editor = "/usr/bin/editor";
+            #elif defined(_PATH_VI)
+              editor = _PATH_VI;
+            #else
+              editor = "/usr/ucb/vi";
+            #endif
+*/
+    }
+    fclose(f);
+
+    (void)signal(SIGINT, SIG_IGN);
+    (void)signal(SIGQUIT, SIG_IGN);
+
+    swap_uids();
+
+    switch (pid = fork()) {
+      case -1:
+              fatal("Cannot fork", 0);
+      case 0: 
+      {
+              char *run = NULL;
+              size_t size = strlen(s) + strlen(editor) + 5;
+
+              setgid(getgid());
+              setuid(getuid());
+              run = calloc(1, size);
+              /* child */
+              egg_snprintf(run, size, "%s %s", editor, s);
+              execlp("/bin/sh", "/bin/sh", "-c", run, NULL);
+              perror(editor);
+              exit(1);
+              /*NOTREACHED*/
+      }
+      default:
+              /* parent */
+              break;
+    }
+
+    /* parent */
+    while (1) {
+      xpid = waitpid(pid, &waiter, WUNTRACED);
+      if (xpid == -1) {
+        fprintf(stderr, "waitpid() failed waiting for PID %d from \"%s\": %s\n",
+                         pid, editor, strerror(errno));
+      } else if (xpid != pid) {
+        fprintf(stderr, "wrong PID (%d != %d) from \"%s\"\n", xpid, pid, editor);
+        goto fatal;
+      } else if (WIFSTOPPED(waiter)) {
+        /* raise(WSTOPSIG(waiter)); Not needed and breaks in job control shell*/
+      } else if (WIFEXITED(waiter) && WEXITSTATUS(waiter)) {
+        fprintf(stderr, "\"%s\" exited with status %d\n", editor, WEXITSTATUS(waiter));
+        goto fatal;
+      } else if (WIFSIGNALED(waiter)) {
+        fprintf(stderr, "\"%s\" killed; signal %d (%score dumped)\n",
+                        editor, WTERMSIG(waiter), WCOREDUMP(waiter) ?"" :"no ");
+        goto fatal;
+      } else {
+        break;
+      }
+    }
+
+    (void)signal(SIGINT, SIG_DFL);
+    (void)signal(SIGQUIT, SIG_DFL);
+
+    swap_uids_back();
+
+    if (!can_stat(s)) 
+      fatal("Error reading new config file", 0);
+
+    unlink(cfile);
+    EncryptFile(s, cfile);
+    unlink(s);
+    fatal("New config file saved, restart bot to use", 0);
+
+ fatal:
+      unlink(s);
+      exit(1);
+}
+#endif /* S_CONFEDIT */
+
 void init_conf() {
   conffile.bots = (conf_bot *) calloc(1, sizeof(conf_bot));
   conffile.bots->nick = NULL;
   conffile.bots->next = NULL;
   conffile.bot = NULL;
 
-  conffile.comments = calloc(1, 1);
   conffile.autocron = 1;
   conffile.autouname = 0;
   conffile.binpath = strdup(STR("~/"));
@@ -163,12 +290,9 @@ void free_conf() {
   free(conffile.homedir);
   free(conffile.binname);
   free(conffile.binpath);
-  free(conffile.comments);
 }
 
 int parseconf() {
-  struct passwd *pw = NULL;
-
   if (conffile.uid && conffile.uid != myuid) {
     sdprintf("wrong uid, conf: %d :: %d", conffile.uid, myuid);
     werr(ERR_WRONGUID);
@@ -186,23 +310,18 @@ int parseconf() {
     conffile.uname = strdup(my_uname());
   }
 
-  if ((pw = getpwuid(conffile.uid))) {
-
-    if (conffile.username) {
-      str_redup(&conffile.username, pw->pw_name);
-    } else {
-      conffile.username = strdup(pw->pw_name);
-    }
-
-    if (conffile.homedir) {
-      str_redup(&conffile.homedir, pw->pw_dir);
-    } else {
-      conffile.homedir = strdup(pw->pw_dir);
-    }
+  if (conffile.username) {
+    str_redup(&conffile.username, my_username());
+  } else {
+    conffile.username = strdup(my_username());
+  }
 
+  if (conffile.homedir) {
+    str_redup(&conffile.homedir, homedir());
   } else {
-    return 1;
+    conffile.homedir = strdup(homedir());
   }
+
   return 0;
 }
 
@@ -215,10 +334,16 @@ int readconf(char *cfile)
   Context;
   if (!(f = fopen(cfile, "r")))
     fatal("Cannot read config", 0);
+
   while (fgets(inbuf, sizeof inbuf, f) != NULL) {
     char *line = NULL, *temp_ptr = NULL;
-
     line = temp_ptr = decrypt_string(SALT1, inbuf);
+
+    if ((line && !line[0]) || line[0] == '\n') {
+      free(line);
+      continue;
+    }
+
     i++;
 
     sdprintf("CONF LINE: %s", line);
@@ -299,7 +424,7 @@ int readconf(char *cfile)
         conffile.portmax = atoi(line);
 
       /* now to parse nick/hosts */
-      } else if (line[0] != '#') {
+      } else if (line[0] != '#') { 
         char *nick = NULL, *host = NULL, *ip = NULL, *ipsix = NULL;
 
         nick = newsplit(&line);
@@ -314,10 +439,6 @@ int readconf(char *cfile)
           ipsix = newsplit(&line);
 
         conf_addbot(nick, ip, host, ipsix);
-      } else {
-        conffile.comments = realloc(conffile.comments, strlen(conffile.comments) + strlen(line) + 1 + 1);
-        strcat(conffile.comments, line);
-        strcat(conffile.comments, "\n");
       }
     }
     free(temp_ptr);
@@ -327,43 +448,98 @@ int readconf(char *cfile)
   return 0;
 }
 
-int writeconf(char *filename) {
+int writeconf(char *filename, FILE *stream, int bits) {
   FILE *f = NULL;
   conf_bot *bot = NULL;
-
-  if (!(f = fopen(filename, "w"))) {
-    return 1;
+  Function my_write = NULL;
+
+  if (bits & CONF_ENC)
+    my_write = (Function) lfprintf;
+  else if (!(bits & CONF_ENC))
+    my_write = (Function) fprintf;
+
+#define comment(text)			\
+	if (bits & CONF_COMMENT)	\
+	  my_write(f, "%s\n", text);
+
+  if (stream) {
+    f = stream;
+  } else if (filename) {
+    if (!(f = fopen(filename, "w")))
+      return 1;
   }
-/* old
-  lfprintf(f, "- %d\n", conffile.uid);
-  lfprintf(f, "+ %s\n", conffile.uname);
-*/
-  lfprintf(f, "! uid %d\n", conffile.uid);
-  lfprintf(f, "! uname %s\n", conffile.uname);
-  lfprintf(f, "! username %s\n", conffile.username);
-  lfprintf(f, "! homedir %s\n", conffile.homedir);
-  lfprintf(f, "! binname %s\n", conffile.binname);
-  lfprintf(f, "! binpath %s\n", conffile.binpath);
-/* old
-  lfprintf(f, "> %d\n", conffile.portmin);
-  lfprintf(f, "< %d\n", conffile.portmax);
-*/
-  lfprintf(f, "! portmin %d\n", conffile.portmin);
-  lfprintf(f, "! portmax %d\n", conffile.portmax);
-  lfprintf(f, "! pscloak %d\n", conffile.pscloak);
-  lfprintf(f, "! autocron %d\n", conffile.autocron);
-  lfprintf(f, "! autouname %d\n", conffile.autouname);
 
+  comment("# Lines beginning with # are what the preceeding line SHOULD be");
+  comment("# They are also ignored during parsing\n");
+
+  my_write(f, "! uid %d\n", conffile.uid);
+  if ((bits & CONF_COMMENT) && conffile.uid != myuid)
+    my_write(f, "#! uid %d\n\n", myuid);
+
+
+  if (!conffile.uname || (conffile.uname && conffile.autouname && strcmp(conffile.uname, my_uname()))) {
+    comment("# Automatic");
+    my_write(f, "! uname %s\n", my_uname());
+  } else if (conffile.uname && !conffile.autouname && strcmp(conffile.uname, my_uname())) {
+    my_write(f, "! uname %s\n", conffile.uname);
+    comment("# autouname is OFF");
+    my_write(f, "#! uname %s\n\n", my_uname());
+  } else 
+    my_write(f, "! uname %s\n", conffile.uname);
+
+  my_write(f, "! username %s\n", conffile.username ? conffile.username : my_username());
+  if (conffile.username && strcmp(conffile.username, my_username())) 
+    my_write(f, "#! username %s\n", my_username());
+
+  my_write(f, "! homedir %s\n", conffile.homedir ? conffile.homedir : homedir());
+  if (conffile.homedir && strcmp(conffile.homedir, homedir()))
+    my_write(f, "#! homedir %s\n", homedir());
+
+  comment("");
+
+  my_write(f, "! binpath %s\n", conffile.binpath);
+  comment("# binname is relative to binpath");
+  my_write(f, "! binname %s\n", conffile.binname);
+
+  comment("");
+
+  comment("# portmin/max are for incoming connections (DCC) [0 for any]");
+  my_write(f, "! portmin %d\n", conffile.portmin);
+  my_write(f, "! portmax %d\n", conffile.portmax);
+
+  comment("");
+  
+  comment("# Attempt to \"cloak\" the process name in `ps` for Linux?");
+  my_write(f, "! pscloak %d\n", conffile.pscloak);
+ 
+  comment("");
+  
+  comment("# Automatically add the bot to crontab?");
+  my_write(f, "! autocron %d\n", conffile.autocron);
+
+  comment("");
+ 
+  comment("# Automatically update 'uname' if it changes? (DANGEROUS)");
+  my_write(f, "! autouname %d\n", conffile.autouname);
+
+  comment("");
+
+  comment("# '|' means OR, [] means the enclosed is optional");
+  comment("# A '+' in front of HOST means the HOST is ipv6");
+  comment("# A '/' in front of BOT will disable that bot.");
+  comment("#[/]BOT IP|. [+]HOST|. [IPV6-IP]");
   for (bot = conffile.bots; bot && bot->nick; bot = bot->next) {
-    lfprintf(f, "%s %s %s%s %s\n", bot->nick,
+    my_write(f, "%s %s %s%s %s\n", bot->nick,
                                    bot->ip ? bot->ip : ".",
                                    bot->host6 ? "+" : "",
                                    bot->host ? bot->host : (bot->host6 ? bot->host6 : "."),
                                    bot->ip6 ? bot->ip6 : "");
   }
-  lfprintf(f, "%s", conffile.comments);
+
   fflush(f);
-  fclose(f);
+
+  if (!stream)
+    fclose(f);
 
   return 0;
 }

+ 12 - 1
src/conf.h

@@ -2,6 +2,7 @@
 #define _CONF_H
 
 #include <sys/types.h>
+#include <stdio.h>
 
 typedef struct conf_bot_b {
   char *nick;
@@ -36,15 +37,25 @@ typedef struct conf_b {
 } conf_t;
 
 extern conf_t		conf;
+
+enum {
+  CONF_ENC = 1,
+  CONF_COMMENT = 2
+};
+
+
 #ifndef MAKING_MODS
 
+#ifdef S_CONFEDIT
+void confedit(char *);
+#endif /* S_CONFEDIT */
 int checkpid(char *, conf_bot *);
 void showconf();
 void init_conf();
 void free_conf();
 int readconf(char *);
 int parseconf();
-int writeconf(char *);
+int writeconf(char *, FILE *, int);
 void fillconf(conf_t *);
 #endif /* !MAKING_MODS */
 

+ 5 - 5
src/log.c

@@ -233,11 +233,11 @@ void putlog(int type, char *chname, char *format, ...)
 
   va_start(va, format);
 #ifdef HUB
-#ifdef S_UTCTIME
+# ifdef S_UTCTIME
   t = gmtime(&now);
-#else /* !S_UTCTIME */
+# else /* !S_UTCTIME */
   t = localtime(&now);
-#endif /* S_UTCTIME */
+# endif /* S_UTCTIME */
 
   egg_strftime(stamp, sizeof(stamp) - 2, LOG_TS, t);
   strcat(stamp, " ");
@@ -271,8 +271,8 @@ void putlog(int type, char *chname, char *format, ...)
 
     egg_snprintf(outbuf, sizeof outbuf, "hl %d %s", type, out);
     if (userlist && !loading) {
-      tand_t *bot;
-      struct userrec *ubot;
+      tand_t *bot = NULL;
+      struct userrec *ubot = NULL;
 
       for (bot = tandbot ; bot; bot = bot->next) {
         if ((ubot = get_user_by_handle(userlist, bot->bot))) {

+ 30 - 16
src/main.c

@@ -66,6 +66,9 @@ extern struct chanset_t	*chanset;
 const time_t 	buildts = CVSBUILD;		/* build timestamp (UTC) */
 const char	egg_version[1024] = "1.1.0";
 
+#ifdef S_CONFEDIT
+int	do_confedit = 0;		/* show conf menu if -C */
+#endif /* S_CONFEDIT */
 int 	localhub = 1; 		/* we set this to 0 if we get a -B */
 int 	role;
 int 	loading = 0;
@@ -167,7 +170,7 @@ static void checkpass()
     gpasswd = (char *) getpass("");
     checkedpass = 1;
     if (!gpasswd || (gpasswd && md5cmp(shellhash, gpasswd)))
-      fatal(STR("incorrect password."), 0);
+      werr(ERR_BADPASS);
   }
 }
 
@@ -198,6 +201,7 @@ static void show_help()
   printf(format, STR("Option"), STR("Description"));
   printf(format, STR("------"), STR("-----------"));
   printf(format, STR("-B <botnick>"), STR("Starts the specified bot"));
+  printf(format, STR("-C"), STR("Config file menu system"));
   printf(format, STR("-e <infile> <outfile>"), STR("Encrypt infile to outfile"));
   printf(format, STR("-d <infile> <outfile>"), STR("Decrypt infile to outfile"));
   printf(format, STR("-D"), STR("Enables debug mode (see -n)"));
@@ -216,9 +220,9 @@ static void show_help()
 
 
 #ifdef LEAF
-# define PARSE_FLAGS "2B:d:De:Eg:G:L:P:hnstv"
+# define PARSE_FLAGS "2B:Cd:De:Eg:G:L:P:hnstv"
 #else /* !LEAF */
-# define PARSE_FLAGS "2d:De:Eg:G:hnstv"
+# define PARSE_FLAGS "2Cd:De:Eg:G:hnstv"
 #endif /* HUB */
 #define FLAGS_CHECKPASS "dDeEgGhntv"
 static void dtx_arg(int argc, char *argv[])
@@ -229,6 +233,7 @@ static void dtx_arg(int argc, char *argv[])
 #endif /* LEAF */
   char *p = NULL;
 
+  opterr = 0;
   while ((i = getopt(argc, argv, PARSE_FLAGS)) != EOF) {
     if (strchr(FLAGS_CHECKPASS, i))
       checkpass();
@@ -241,6 +246,11 @@ static void dtx_arg(int argc, char *argv[])
         strncpyz(origbotname, optarg, NICKLEN + 1);
         break;
 #endif /* LEAF */
+#ifdef S_CONFEDIT
+      case 'C':
+        do_confedit = 1;
+        break;
+#endif /* S_CONFEDIT */
       case 'h':
         show_help();
       case 'n':
@@ -313,6 +323,7 @@ static void dtx_arg(int argc, char *argv[])
         updating = 1;
         break;
 #endif
+      case '?':
       default:
         break;
     }
@@ -484,8 +495,6 @@ static void event_resettraffic()
 
 extern module_entry *module_list;
 
-void check_static(char *, char *(*)());
-
 #include "mod/static.h"
 
 int init_dcc_max(), init_userent(), init_auth(), init_config(), init_bots(),
@@ -575,7 +584,8 @@ int main(int argc, char **argv)
 
     sdprintf(STR("newbin at: %s"), newbin);
 
-    if (strcmp(binname,newbin)) { //running from wrong dir, or wrong bin name.. lets try to fix that :)
+    /* running from wrong dir, or wrong bin name.. lets try to fix that :) */
+    if (strcmp(binname,newbin)) { 
 #ifdef LEAF
       int ok = 1;
 #endif /* LEAF */
@@ -651,15 +661,20 @@ int main(int argc, char **argv)
   if (localhub)
 #endif /* LEAF */
     showconf();
-  parseconf();
+#ifdef S_CONFEDIT
+  if (do_confedit)
+    confedit(cfile);		/* this will exit() */
+#endif /* S_CONFEDIT */
 #ifdef LEAF
-  if (localhub)
+  if (localhub) {
+#endif /* LEAF */
+    parseconf();
+    writeconf(cfile, NULL, CONF_ENC);
+#ifdef LEAF
+  }
 #endif /* LEAF */
-    writeconf(cfile);
   fillconf(&conf);
   free_conf();
-printf("I AM : %s (%s: %d)\n", conf.bot->nick, conf.bot->pid_file, conf.bot->pid);
-printf("bleh..ip: %s host: %s ip6: %s host6: %s\n", conf.bot->ip, conf.bot->host, conf.bot->ip6, conf.bot->host6);
 
   if ((localhub && !updating) || !localhub) {
     if ((conf.bot->pid > 0) && conf.bot->pid_file) {
@@ -704,7 +719,7 @@ printf("bleh..ip: %s host: %s ip6: %s host6: %s\n", conf.bot->ip, conf.bot->host
   }
 #endif /* LEAF && PSCLOAK */
 
-  putlog(LOG_MISC, "*", STR("=== %s: %d users."), conf.bot->nick, count_users(userlist));
+  putlog(LOG_MISC, "*", "=== %s: %d users.", conf.bot->nick, count_users(userlist));
 
   /* Move into background? */
   if (backgrd) {
@@ -724,10 +739,8 @@ printf("bleh..ip: %s host: %s ip6: %s host6: %s\n", conf.bot->ip, conf.bot->host
       /* Let the bot live since this doesn't appear to be a botchk */
         printf(EGG_NOWRITE, conf.bot->pid_file);
         unlink(conf.bot->pid_file);
-        fclose(f);
-      } else {
-        fclose(f);
       }
+      fclose(f);
     } else
       printf(EGG_NOWRITE, conf.bot->pid_file);
 #ifdef CYGWIN_HACKS
@@ -790,7 +803,8 @@ printf("bleh..ip: %s host: %s ip6: %s host6: %s\n", conf.bot->ip, conf.bot->host
   add_hook(HOOK_USERFILE, (Function) event_save);
   add_hook(HOOK_DAILY, (Function) event_resettraffic);
 
-  debug0(STR("main: entering loop"));
+  debug0("main: entering loop");
+
   while (1) {
     int socket_cleanup = 0, i, xx;
     char buf[SGRAB + 9] = "";

+ 2 - 2
src/misc.c

@@ -798,7 +798,7 @@ int updatebin(int idx, char *par, int autoi)
   if (i == -1 || WEXITSTATUS(i) != 2) {
     if (idx)
       dprintf(idx, STR("Couldn't restart new binary (error %d)\n"), i);
-    putlog(LOG_MISC, "*", STR("Couldn't restart new binary (error %d)\n"), i);
+    putlog(LOG_MISC, "*", STR("Couldn't restart new binary (error %d)"), i);
     return i;
   }
 
@@ -838,7 +838,7 @@ int updatebin(int idx, char *par, int autoi)
 #endif /* LEAF */
     if (idx)
       dprintf(idx, STR("Updating...bye\n"));
-    putlog(LOG_MISC, "*", STR("Updating...\n"));
+    putlog(LOG_MISC, "*", STR("Updating..."));
     botnet_send_chat(-1, conf.bot->nick, "Updating...");
     botnet_send_bye();
     fatal("Updating...", 1);

+ 1 - 0
src/misc.h

@@ -30,6 +30,7 @@
 
 
 #ifndef MAKING_MODS
+char *wbanner();
 char *color(int, int, int);
 void shuffle(char *, char *);
 void showhelp(int, struct flag_record *, char *);

+ 1 - 1
src/mod/channels.mod/channels.c

@@ -123,7 +123,7 @@ static void got_cset(char *botnick, char *code, char *par)
     newsplit(&par);
    } else {
     if (!strchr(CHANMETA, par[0])) {
-      putlog(LOG_ERROR, "*", "Got bad cset: bot: %s code: %s par: %s\n", botnick, code, par);
+      putlog(LOG_ERROR, "*", "Got bad cset: bot: %s code: %s par: %s", botnick, code, par);
       return;
     }
     chname = newsplit(&par);

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

@@ -1097,7 +1097,7 @@ void check_netfight()
     for (chan = chanset; chan; chan = chan->next) {
       if ((chan->channel.fighting) && (chan->channel.fighting > limit)) {
         if (!channel_bitch(chan) || !channel_closed(chan)) {
-          putlog(LOG_WARN, "*", STR("Auto-closed %s - channel fight\n"), chan->dname);
+          putlog(LOG_WARN, "*", STR("Auto-closed %s - channel fight"), chan->dname);
           do_chanset(NULL, chan, STR("+bitch +closed"), DO_LOCAL | DO_NET);
           enforce_closed(chan);
           dprintf(DP_MODE, STR("TOPIC %s :Auto-closed - channel fight\n"), chan->name);

+ 2 - 0
src/modules.h

@@ -16,6 +16,8 @@
 
 #ifndef MAKING_NUMMODS
 
+void check_static(char *, char *(*)());
+
 /* Modules specific functions and functions called by eggdrop
  */
 

+ 16 - 0
src/shell.c

@@ -595,6 +595,8 @@ char *werr_tostr(int errnum)
   switch (errnum) {
   case ERR_BINSTAT:
     return STR("Cannot access binary");
+  case ERR_BADPASS:
+    return STR("Incorrect password");
   case ERR_BINMOD:
     return STR("Cannot chmod() binary");
   case ERR_PASSWD:
@@ -767,6 +769,20 @@ char *homedir()
   return homedir;
 }
 
+char *my_username()
+{
+  static char username[DIRMAX] = "";
+
+  if (!username || (username && !username[0])) {
+    struct passwd *pw = NULL;
+
+    ContextNote("Calling getpwuid");
+    pw = getpwuid(myuid);
+    egg_snprintf(username, sizeof username, "%s", pw->pw_name);
+  }
+  return username;
+}
+
 char *confdir()
 {
   static char confdir[DIRMAX] = "";

+ 3 - 1
src/shell.h

@@ -16,7 +16,8 @@
 #define ERR_WRONGUNAME  13
 #define ERR_BADCONF     14
 #define ERR_BADBOT	15
-#define ERR_MAX         16
+#define ERR_BADPASS	16
+#define ERR_MAX         17
 
 #define EMAIL_OWNERS    0x1
 #define EMAIL_TEAM      0x2
@@ -38,6 +39,7 @@
 void check_mypid();
 int clear_tmp();
 char *homedir();
+char *my_username();
 char *my_uname();
 char *confdir();
 void baduname(char *, char *);