Răsfoiți Sursa

* Remove conf.binpath and conf.binname

Bryan Drewery 16 ani în urmă
părinte
comite
02d4d4f4e7
9 a modificat fișierele cu 9 adăugiri și 68 ștergeri
  1. 1 7
      src/binary.c
  2. 1 1
      src/chanprog.c
  3. 0 4
      src/cmds.c
  4. 1 45
      src/conf.c
  5. 0 2
      src/conf.h
  6. 0 1
      src/main.c
  7. 1 1
      src/misc_file.c
  8. 3 3
      src/mod/update.mod/update.c
  9. 2 4
      src/settings.h

+ 1 - 7
src/binary.c

@@ -32,7 +32,7 @@ settings_t settings = {
   /* -- STATIC -- */
   "", "", "", "", "", "", "", "", "", "",
   /* -- DYNAMIC -- */
-  "", "", "", "", "", "", "", "", "", "",
+  "", "", "", "", "", "", "", "",
   /* -- PADDING */
   ""
 };
@@ -480,8 +480,6 @@ static void edpack(settings_t *incfg, const char *in_hash, int what)
   dofield(incfg->username);
   dofield(incfg->datadir);
   dofield(incfg->homedir);
-  dofield(incfg->binpath);
-  dofield(incfg->binname);
   dofield(incfg->portmin);
   dofield(incfg->portmax);
 
@@ -515,8 +513,6 @@ tellconfig(settings_t *incfg)
   dofield(incfg->username);
   dofield(incfg->datadir);
   dofield(incfg->homedir);
-  dofield(incfg->binpath);
-  dofield(incfg->binname);
   dofield(incfg->portmin);
   dofield(incfg->portmax);
 #undef dofield
@@ -669,13 +665,11 @@ void conf_to_bin(conf_t *in, bool move, int die)
   simple_snprintf(settings.portmin, sizeof(settings.portmin), "%d", in->portmin);
   simple_snprintf(settings.portmax, sizeof(settings.portmax), "%d", in->portmax);
 
-  strlcpy(settings.binname, in->binname, sizeof(settings.binname));
   if (in->username)
     strlcpy(settings.username, in->username, sizeof(settings.username));
   strlcpy(settings.datadir, in->datadir, sizeof(settings.datadir));
   if (in->homedir)
     strlcpy(settings.homedir, in->homedir, sizeof(settings.homedir));
-  strlcpy(settings.binpath, in->binpath, sizeof(settings.binpath));
   for (bot = in->bots; bot && bot->nick; bot = bot->next) {
     simple_snprintf(settings.bots, sizeof(settings.bots), STR("%s%s%s %s %s%s %s,"), 
                            settings.bots && settings.bots[0] ? settings.bots : "",

+ 1 - 1
src/chanprog.c

@@ -582,7 +582,7 @@ void chanprog()
 
   sdprintf("I am: %s", conf.bot->nick);
   if (conf.bot->hub) {
-    simple_snprintf(userfile, 121, "%s/.u", conf.binpath);
+    simple_snprintf(userfile, 121, "%s/.u", dirname(binname));
     loading = 1;
     checkchans(0);
     readuserfile(userfile, &userlist);

+ 0 - 4
src/cmds.c

@@ -1748,8 +1748,6 @@ static void cmd_conf(int idx, char *par)
         else if (!strcasecmp(what, "username"))  str_redup(&conf.username, par);
 */
         if (!strcasecmp(what, "homedir"))   str_redup(&conf.homedir, par);
-        else if (!strcasecmp(what, "binpath"))   str_redup(&conf.binpath, par);
-        else if (!strcasecmp(what, "binname"))   str_redup(&conf.binname, par);
         else if (!strcasecmp(what, "datadir"))   str_redup(&conf.datadir, par);
         else if (!strcasecmp(what, "portmin"))   conf.portmin = atoi(par);
         else if (!strcasecmp(what, "portmax"))   conf.portmax = atoi(par);
@@ -1768,8 +1766,6 @@ static void cmd_conf(int idx, char *par)
       if (!what || !strcasecmp(what, "username"))   dprintf(idx, "%susername: %s\n", ss, conf.username);
 */
       if (!what || !strcasecmp(what, "homedir"))    dprintf(idx, "%shomedir: %s\n", ss, conf.homedir);
-      if (!what || !strcasecmp(what, "binpath"))    dprintf(idx, "%sbinpath: %s\n", ss, conf.binpath);
-      if (!what || !strcasecmp(what, "binname"))    dprintf(idx, "%sbinname: %s\n", ss, conf.binname);
       if (!what || !strcasecmp(what, "datadir"))    dprintf(idx, "%sdatadir: %s\n", ss, conf.datadir);
       if (!what || !strcasecmp(what, "portmin"))    dprintf(idx, "%sportmin: %d\n", ss, conf.portmin);
       if (!what || !strcasecmp(what, "portmax"))    dprintf(idx, "%sportmax: %d\n", ss, conf.portmax);

+ 1 - 45
src/conf.c

@@ -52,8 +52,6 @@ tellconf()
   sdprintf(STR("uid: %d\n"), conf.uid);
   sdprintf(STR("homedir: %s\n"), conf.homedir);
   sdprintf(STR("username: %s\n"), conf.username);
-  sdprintf(STR("binpath: %s\n"), replace(conf.binpath, conf.homedir, "~"));
-  sdprintf(STR("binname: %s\n"), conf.binname);
   sdprintf(STR("datadir: %s\n"), replace(conf.datadir, conf.homedir, "~"));
   sdprintf(STR("portmin: %d\n"), conf.portmin);
   sdprintf(STR("portmax: %d\n"), conf.portmax);
@@ -313,7 +311,6 @@ confedit()
   free_conf();
 
   readconf((const char *) tmpconf.file, 0);               /* read cleartext conf tmp into &settings */
-  expand_tilde(&conf.binpath);
   expand_tilde(&conf.datadir);
   unlink(tmpconf.file);
   conf_to_bin(&conf, 0, -1);
@@ -350,20 +347,6 @@ init_conf()
 #else
   conf.autocron = 1;
 #endif /* !CYGWIN_HACKS */
-#ifdef CYGWIN_HACKS
-  if (homedir())
-    conf.binpath = strdup(homedir());
-#else /* !CYGWIN_HACKS */
-  conf.binpath = strdup(dirname(binname));
-#endif /* CYGWIN_HACKS */
-  char *p = strrchr(binname, '/');
-
-  p++;
-
-  if (!strncmp(p, STR("wraith."), 7) && strchr(p, '-'))
-    conf.binname = strdup(STR("wraith"));
-  else
-    conf.binname = strdup(p);
 
   conf.features = 0;
   conf.portmin = 0;
@@ -566,10 +549,6 @@ free_conf()
     free(conf.datadir);
   if (conf.homedir)
     free(conf.homedir);
-  if (conf.binname)
-   free(conf.binname);
-  if (conf.binpath)
-    free(conf.binpath);
   init_conf();
 }
 
@@ -678,12 +657,6 @@ readconf(const char *fname, int bits)
       } else if (option == STR("datadir")) {        /* datadir */
         str_redup(&conf.datadir, line.c_str());
 
-      } else if (option == STR("binpath")) {        /* path that the binary should move to? */
-        str_redup(&conf.binpath, line.c_str());
-
-      } else if (option == STR("binname")) {        /* filename of the binary? */
-        str_redup(&conf.binname, line.c_str());
-
       } else if (option == STR("portmin")) {
         if (egg_isdigit(line[0]))
           conf.portmin = atoi(line.c_str());
@@ -787,20 +760,6 @@ writeconf(char *filename, int fd, int bits)
   } else 
     *stream << buf.printf(STR("! homedir %s\n"), conf.homedir ? conf.homedir : homedir(0) ? homedir(0) : "");
 
-  comment("\n# binpath needs to be full path unless it begins with '~', which uses 'homedir', ie, '~/'");
-
-  if (homedir() && strstr(conf.binpath, homedir())) {
-    p = replace(conf.binpath, homedir(), "~");
-    *stream << buf.printf(STR("! binpath %s\n"), p);
-  } else if (conf.homedir && strstr(conf.binpath, conf.homedir)) { /* Could be an older homedir */
-    p = replace(conf.binpath, conf.homedir, "~");
-    *stream << buf.printf(STR("! binpath %s\n"), p);
-  } else
-    *stream << buf.printf(STR("! binpath %s\n"), conf.binpath);
-
-  comment("# binname is relative to binpath, if you change this, you'll need to manually remove the old one from crontab.");
-  *stream << buf.printf(STR("! binname %s\n"), conf.binname);
-
   comment("");
 
   if (conf.datadir && strcmp(conf.datadir, "./...")) {
@@ -980,8 +939,6 @@ bin_to_conf(bool error)
   str_redup(&conf.datadir, settings.datadir);
   if (settings.homedir[0])
     str_redup(&conf.homedir, settings.homedir);
-  str_redup(&conf.binpath, settings.binpath);
-  str_redup(&conf.binname, settings.binname);
   conf.portmin = atol(settings.portmin);
   conf.portmax = atol(settings.portmax);
   conf.autocron = atoi(settings.autocron);
@@ -989,7 +946,6 @@ bin_to_conf(bool error)
 
   prep_homedir(error);
   expand_tilde(&conf.datadir);
-  expand_tilde(&conf.binpath);
 
   /* PARSE/ADD BOTS */
   {
@@ -1028,7 +984,7 @@ bin_to_conf(bool error)
   if (!mkdir_p(conf.datadir) && error)
     werr(ERR_DATADIR);
 
-  str_redup(&conf.datadir, replace(datadir, conf.binpath, "."));
+  str_redup(&conf.datadir, replace(datadir, dirname(binname), "."));
 
   if (Tempfile::FindDir() == ERROR)
     werr(ERR_TMPSTAT);

+ 0 - 2
src/conf.h

@@ -37,8 +37,6 @@ typedef struct conf_b {
   char *datadir;
   char *username;       /* shell username */
   char *homedir;        /* homedir */
-  char *binpath;        /* path to binary, ie: ~/ */
-  char *binname;        /* binary name, ie: .sshrc */
   port_t portmin;       /* for hubs, the reserved port range for incoming connections */
   port_t portmax;       /* for hubs, the reserved port range for incoming connections */
 } conf_t;

+ 0 - 1
src/main.c

@@ -349,7 +349,6 @@ static void dtx_arg(int& argc, char *argv[])
         exit(2);
       case '4':
         readconf(optarg, CONF_ENC);
-        expand_tilde(&conf.binpath);
         expand_tilde(&conf.datadir);
         parseconf(0);
         conf_to_bin(&conf, 0, 6);		/* this will exit() in write_settings() */

+ 1 - 1
src/misc_file.c

@@ -303,7 +303,7 @@ bool Tempfile::FindDir()
 
   /* If this is a hub, use, "./tmp/" */
   if (conf.bots && conf.bots->nick && conf.bots->hub) {
-    simple_snprintf(tempdir, DIRMAX, "%s/tmp/", conf.binpath);
+    simple_snprintf(tempdir, DIRMAX, "%s/tmp/", dirname(binname));
     if (check_tempdir(0)) {
       looking = 0;
       return OK;

+ 3 - 3
src/mod/update.mod/update.c

@@ -239,7 +239,7 @@ void finish_update_stream(int idx, bd::Stream& stream)
 
   char rand[7] = "";
   make_rand_str(rand, sizeof(rand) - 1, 0);
-  simple_snprintf(buf, sizeof(buf), "%s/.update-%s", conf.binpath, rand);
+  simple_snprintf(buf, sizeof(buf), "%s/.update-%s", dirname(binname), rand);
 
   stream.writeFile(buf);
   fixmod(buf);
@@ -295,9 +295,9 @@ static void start_sending_binary(int idx, bool streamable)
 
   simple_snprintf(update_file, sizeof update_file, "wraith.%s-%s", sysname, egg_version);
 
-  simple_snprintf(update_fpath, sizeof update_fpath, "%s/bins/%s", conf.binpath, update_file);
+  simple_snprintf(update_fpath, sizeof update_fpath, "%s/bins/%s", dirname(binname), update_file);
   if (!can_stat(update_fpath))
-    simple_snprintf(update_fpath, sizeof update_fpath, "%s/%s", conf.binpath, update_file);
+    simple_snprintf(update_fpath, sizeof update_fpath, "%s/%s", dirname(binname), update_file);
 
   if (!can_stat(update_fpath)) {
     putlog(LOG_MISC, "*", "Need to update \002%s\002 with %s but there was an error: %s", dcc[idx].nick, update_fpath,

+ 2 - 4
src/settings.h

@@ -28,12 +28,10 @@ typedef struct settings_struct {
   char username[49];       /* shell username */
   char datadir[1025];
   char homedir[1025];        /* homedir */
-  char binpath[1025];        /* path to binary, ie: ~/ */
-  char binname[113];        /* binary name, ie: .sshrc */
   char portmin[17];       /* for hubs, the reserved port range for incoming connections */
   char portmax[17];       /* for hubs, the reserved port range for incoming connections */
   /* -- PADDING -- */
-  char padding[12];        // (16 - (sizeof(settings_t) % 16)) % 16]
+  char padding[14];        // (16 - (sizeof(settings_t) % 16)) % 16]
 } settings_t;
 
 #define SALT1 {s1_1[0],s1_1[1],s1_5[0],s1_5[1],s1_8[0],s1_8[1],s1_4[0],s1_9[1],s1_2[0],s1_13[0],s1_6[0],s1_6[1],s1_7[0],s1_7[1],s1_3[0],s1_13[1],s1_16[1],s1_4[1],s1_15[0],s1_10[1],s1_14[0],s1_14[1],s1_12[0],s1_12[1],s1_2[1],s1_3[1],s1_11[0],s1_11[1],s1_10[0],s1_15[1],s1_16[0],s1_9[0],'\0'}
@@ -50,7 +48,7 @@ sizeof(settings.salt1) + sizeof(settings.salt2) + sizeof(settings.dcc_prefix) +
 
 #define SIZE_CONF sizeof(settings.bots) + sizeof(settings.uid) + \
 sizeof(settings.autocron) + \
-sizeof(settings.username) + sizeof(settings.homedir) + sizeof(settings.binpath) + sizeof(settings.binname) + \
+sizeof(settings.username) + sizeof(settings.homedir) + \
 sizeof(settings.portmin) + sizeof(settings.portmin) + sizeof(settings.datadir)
 
 #define SIZE_PAD sizeof(settings.padding)