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

* Increased buffer size in binary config for binname/binpath/homedir

svn: 2231
Bryan Drewery 21 лет назад
Родитель
Сommit
4564197417
6 измененных файлов с 28 добавлено и 18 удалено
  1. 1 1
      doc/UPDATES
  2. 11 6
      src/binary.c
  3. 8 1
      src/conf.c
  4. 1 0
      src/conf.h
  5. 1 0
      src/main.c
  6. 6 10
      src/settings.h

+ 1 - 1
doc/UPDATES

@@ -4,7 +4,6 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 
 1.2.4 (Planned updates)
 - Another new password encryption
-- Increased buffer size in -C for binname/binpath/homedir
 - Added tempdir option in config -C
 - Add back in uhost cache / hash table for invites
 - Change user system to hash table with uids
@@ -26,6 +25,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Slightly changed/added a comment in -C for uname.
 * Fixed binary config stating there was no change with -C under certain conditions.
 * Default binary name is now what you name it, or "wraith" if left in "wraith.OS-ver" format.
+* Increased buffer size in binary config for binname/binpath/homedir
 
 1.2.3
 

+ 11 - 6
src/binary.c

@@ -36,7 +36,7 @@ settings_t settings = {
   /* -- STATIC -- */
   "", "", "", "", "", "", "", "", "", "",
   /* -- DYNAMIC -- */
-  "", "", "", "", "", "", "", "", "", "", "", "", "",
+  "", "", "", "", "", "", "", "", "", "", "", "", "", "",
   /* -- PADDING */
   ""
 };
@@ -330,6 +330,8 @@ static void edpack(settings_t *incfg, const char *hash, int what)
   dofield(incfg->owners);
   dofield(incfg->owneremail);
   dofield(incfg->hubs);
+//  dofield(incfg->salt1);
+//  dofield(incfg->salt2);
   /* -- DYNAMIC -- */
 //printf("BOTS: %s\n", incfg->bots);
   dofield(incfg->bots);
@@ -341,6 +343,7 @@ static void edpack(settings_t *incfg, const char *hash, int what)
   dofield(incfg->watcher);
   dofield(incfg->uname);
   dofield(incfg->username);
+  dofield(incfg->tempdir);
   dofield(incfg->homedir);
   dofield(incfg->binpath);
   dofield(incfg->binname);
@@ -372,6 +375,7 @@ tellconfig(settings_t *incfg)
   dofield(incfg->watcher);
   dofield(incfg->uname);
   dofield(incfg->username);
+  dofield(incfg->tempdir);
   dofield(incfg->homedir);
   dofield(incfg->binpath);
   dofield(incfg->binname);
@@ -460,7 +464,7 @@ void write_settings(const char *fname, int die, bool conf)
 static void 
 clear_settings(void)
 {
-  memset(&settings.bots, 0, sizeof(settings_t) - 3467);
+  memset(&settings.bots, 0, sizeof(settings_t) - SIZE_PACK);
 }
 
 void conf_to_bin(conf_t *in, bool move, int die)
@@ -478,12 +482,13 @@ void conf_to_bin(conf_t *in, bool move, int die)
   simple_sprintf(settings.portmax, "%d", in->portmax);
   simple_sprintf(settings.pscloak, "%d", in->pscloak);
 
-  strlcpy(settings.binname, in->binname, 16);
+  strlcpy(settings.binname, in->binname, 51);
   strlcpy(settings.username, in->username, 16);
 
   strlcpy(settings.uname, in->uname, 350);
-  strlcpy(settings.homedir, in->homedir, 350);
-  strlcpy(settings.binpath, in->binpath, 350);
+  strlcpy(settings.tempdir, in->tempdir, 1024);
+  strlcpy(settings.homedir, in->homedir, 1024);
+  strlcpy(settings.binpath, in->binpath, 1024);
   for (bot = in->bots; bot && bot->nick; bot = bot->next) {
     simple_sprintf(settings.bots, "%s%s%s %s %s%s %s,", settings.bots && settings.bots[0] ? settings.bots : "",
                            bot->disabled ? "/" : "",
@@ -498,7 +503,7 @@ void conf_to_bin(conf_t *in, bool move, int die)
     newbin = move_bin(in->binpath, in->binname, 0);
   else
     newbin = binname;
-  /* tellconfig(&settings); */
+//  tellconfig(&settings); 
   write_settings(newbin, -1, 1);
 
   if (die >= 0)

+ 8 - 1
src/conf.c

@@ -45,6 +45,7 @@ tellconf()
   sdprintf("tempdir: %s\n", replace(tempdir, conf.homedir, "~"));
   sdprintf("uid: %d\n", conf.uid);
   sdprintf("uname: %s\n", conf.uname);
+  sdprintf("tempdir: %s\n", conf.tempdir);
   sdprintf("homedir: %s\n", conf.homedir);
   sdprintf("binpath: %s\n", replace(conf.binpath, conf.homedir, "~"));
   sdprintf("binname: %s\n", conf.binname);
@@ -363,6 +364,7 @@ init_conf()
   conf.uname = NULL;
   conf.username = NULL;
   conf.homedir = NULL;
+  conf.tempdir = strdup("");
 }
 
 void conf_checkpids()
@@ -548,6 +550,7 @@ free_conf()
   free(conf.localhub);
   free(conf.uname);
   free(conf.username);
+  free(conf.tempdir);
   free(conf.homedir);
   free(conf.binname);
   free(conf.binpath);
@@ -599,7 +602,7 @@ parseconf(bool error)
   } else {
     conf.homedir = strdup(homedir());
   }
-
+  
 #endif /* !CYGWIN_HACKS */
   return 0;
 }
@@ -678,6 +681,9 @@ readconf(const char *fname, int bits)
         } else if (!strcmp(option, "homedir")) {        /* homedir */
           conf.homedir = strdup(line);
 
+        } else if (!strcmp(option, "tempdir")) {        /* tempdir */
+          conf.tempdir = strdup(line);
+
         } else if (!strcmp(option, "binpath")) {        /* path that the binary should move to? */
           str_redup(&conf.binpath, line);
 
@@ -992,6 +998,7 @@ bin_to_conf(void)
   conf.uid = atol(settings.uid);
   conf.username = strdup(settings.username);
   conf.uname = strdup(settings.uname);
+  conf.tempdir = strdup(settings.tempdir);
   conf.homedir = strdup(settings.homedir);
   conf.binpath = strdup(settings.binpath);
   fix_tilde(&conf.binpath);

+ 1 - 0
src/conf.h

@@ -37,6 +37,7 @@ typedef struct conf_b {
   int watcher;		/* spawn a watcher pid to block ptrace? */
   char *localhub;	/* my localhub */
   char *uname;
+  char *tempdir;
   char *username;       /* shell username */
   char *homedir;        /* homedir */
   char *binpath;        /* path to binary, ie: ~/ */

+ 1 - 0
src/main.c

@@ -294,6 +294,7 @@ static void dtx_arg(int argc, char *argv[])
         printf("%d %d\n", SETTINGS_VER, sizeof(settings_t));
         exit(0);
       case '4':
+        sdebug = 1;
         readconf(optarg, CONF_ENC);
         fix_tilde(&conf.binpath);
         parseconf(0);

+ 6 - 10
src/settings.h

@@ -19,7 +19,6 @@ typedef struct settings_struct {
   char dcc_prefix[25];
   /* -- DYNAMIC -- */
  
-//  char tempdir[1389];
   char bots[1389];
   char uid[25];
   char autouname[25];        /* should we just auto update any changed in uname output? */
@@ -28,17 +27,14 @@ typedef struct settings_struct {
   char watcher[25];          /* spawn a watcher pid to block ptrace? */
   char uname[489];
   char username[45];       /* shell username */
-//  char homedir[1389];        /* homedir */
-//  char binpath[1389];        /* path to binary, ie: ~/ */
-  char homedir[489];        /* homedir */
-  char binpath[489];        /* path to binary, ie: ~/ */
-//  char binname[121];        /* binary name, ie: .sshrc */
-  char binname[45];        /* binary name, ie: .sshrc */
+  char tempdir[1389];
+  char homedir[1389];        /* homedir */
+  char binpath[1389];        /* path to binary, ie: ~/ */
+  char binname[121];        /* binary name, ie: .sshrc */
   char portmin[25];       /* for hubs, the reserved port range for incoming connections */
   char portmax[25];       /* for hubs, the reserved port range for incoming connections */
   /* -- PADDING -- */
-//  char padding[3];
-  char padding[4];
+  char padding[3];
 } settings_t;
 
 #define SIZE_PACK sizeof(settings.hash) + sizeof(settings.packname) + sizeof(settings.shellhash) + \
@@ -48,7 +44,7 @@ sizeof(settings.salt1) + sizeof(settings.salt2) + sizeof(settings.dcc_prefix)
 #define SIZE_CONF sizeof(settings.bots) + sizeof(settings.uid) + sizeof(settings.autouname) + \
 sizeof(settings.pscloak) + sizeof(settings.autocron) + sizeof(settings.watcher) + sizeof(settings.uname) + \
 sizeof(settings.username) + sizeof(settings.homedir) + sizeof(settings.binpath) + sizeof(settings.binname) + \
-sizeof(settings.portmin) + sizeof(settings.portmin)
+sizeof(settings.portmin) + sizeof(settings.portmin) + sizeof(settings.tempdir)
 
 #define SIZE_PAD sizeof(settings.padding)