Bläddra i källkod

* Default UID is now -1 (to fix running as root) (Fixes #12)

svn: 1950
Bryan Drewery 21 år sedan
förälder
incheckning
ce9e5dc1d0
3 ändrade filer med 5 tillägg och 4 borttagningar
  1. 1 0
      doc/UPDATES
  2. 3 3
      src/conf.c
  3. 1 1
      src/conf.h

+ 1 - 0
doc/UPDATES

@@ -47,6 +47,7 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Fixed bot sending +Ie modes before recieving list after opping.
 * Fixed channel bans not displaying on hubs (#1)
 * Fixed users showing up in .whom after doing .botcmd and relinking the bot which the cmd was ran on. (#9)
+* Default UID is now: -1 (Fixes running as root by accident. #12)
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 3 - 3
src/conf.c

@@ -296,7 +296,7 @@ init_conf()
   conf.portmin = 0;
   conf.portmax = 0;
   conf.pscloak = 0;
-  conf.uid = 0;
+  conf.uid = -1;
   conf.uname = NULL;
   conf.username = NULL;
   conf.homedir = NULL;
@@ -488,7 +488,7 @@ parseconf(bool error)
   }
 
 #ifndef CYGWIN_HACKS
-  if (error && conf.uid && conf.uid != myuid) {
+  if (error && conf.uid != (signed) myuid) {
     sdprintf("wrong uid, conf: %d :: %d", conf.uid, myuid);
     werr(ERR_WRONGUID);
   } else if (!conf.uid)
@@ -691,7 +691,7 @@ writeconf(char *filename, FILE * stream, int bits)
 
   my_write(f, "! uid %d\n", conf.uid);
 
-  if ((bits & CONF_COMMENT) && conf.uid != myuid)
+  if ((bits & CONF_COMMENT) && conf.uid != (signed) myuid)
     my_write(f, "#! uid %d\n\n", myuid);
 
   if (!conf.uname || (conf.uname && conf.autouname && strcmp(conf.uname, my_uname()))) {

+ 1 - 1
src/conf.h

@@ -29,7 +29,7 @@ typedef struct conf_bot_b {
 typedef struct conf_b {
   conf_bot *bots;       /* the list of bots */
   conf_bot *bot;        /* single bot (me) */
-  uid_t uid;
+  int uid;
   int autouname;        /* should we just auto update any changed in uname output? */
   int pscloak;          /* should the bots bother trying to cloak `ps`? */
   int autocron;         /* should the bot auto crontab itself? */