فهرست منبع

* Removed the hacks for 1.1.9->1.2 which include:
-Checking for old config file and auto writing to binary
-Auto writing binary settings and reading old config when -2 is used
* Removed all config(dir) checking and errors
* configfile reading is now only done on CYGWIN (conf.txt)


svn: 1607

Bryan Drewery 21 سال پیش
والد
کامیت
386b447ca2
6فایلهای تغییر یافته به همراه34 افزوده شده و 105 حذف شده
  1. 2 6
      src/binary.c
  2. 1 1
      src/conf.c
  3. 28 69
      src/main.c
  4. 0 2
      src/main.h
  5. 3 23
      src/shell.c
  6. 0 4
      src/shell.h

+ 2 - 6
src/binary.c

@@ -337,12 +337,8 @@ void write_settings(const char *fname, int die)
     edpack(&settings, hash, PACK_DEC);
   }
 
-  if (die) {
-    if (old_hack == 2)
-      exit(2);			/* we were called with -2 so exit with 2 ! */
-    else
-      exit(0);
-  }
+  if (die)
+    exit(0);
 }
 
 static void 

+ 1 - 1
src/conf.c

@@ -522,7 +522,7 @@ readconf(char *fname, int bits)
 // !strchr("_`|}][{*/#-+!abcdefghijklmnopqrstuvwxyzABDEFGHIJKLMNOPWRSTUVWXYZ", line[0])) {
     if (enc && line[0] > '~') {
       sdprintf("line %d, char %c ", i, line[0]);
-      werr(ERR_CONFBADENC);
+      fatal("Bad encryption", 0);
     } else {                    /* line is good to parse */
       /* - uid */
       if (line[0] == '-') {

+ 28 - 69
src/main.c

@@ -67,8 +67,6 @@ extern int		optind;
 const time_t 	buildts = CVSBUILD;		/* build timestamp (UTC) */
 const char	egg_version[1024] = "1.2.1";
 
-/* FIXME: remove after 1.2 ??? OR NOT */
-int	old_hack = 0;
 bool 	localhub = 1; 		/* we set this to 0 if we get a -B */
 int 	role;
 bool 	loading = 0;
@@ -268,8 +266,6 @@ static void show_help()
   printf(format, "-v", "Displays bot version");
   exit(0);
 }
-/* FIXME: remove after 1.2 */
-static void startup_checks(int);
 
 #ifdef LEAF
 # define PARSE_FLAGS "02B:Cd:De:Eg:G:k:L:P:hnstu:U:v"
@@ -293,11 +289,6 @@ static void dtx_arg(int argc, char *argv[])
       case '0':
         exit(0);
       case '2':		/* used for testing new binary through update */
-        if (settings.uname[0])		/* we're already initialized with data, just exit! */
-          exit(2);
-	/* FIXME: remove after 1.2 */
-	/* ... otherwise, we need to check if ~/.ssh/.known_hosts exists and write to our binary */
-        startup_checks(2);
         exit(2);
 #ifdef LEAF
       case 'B':
@@ -536,67 +527,20 @@ static void core_halfhourly()
 #endif /* HUB */
 }
 
-/* FIXME: Remove after 1.2 (the hacks) */
-static void startup_checks(int hack) {
-  int enc = CONF_ENC;
-
-  /* for compatability with old conf files 
-   * only check/use conf file if it exists and settings.uname is empty.
-   * if settings.uname is NOT empty, just erase the conf file if it exists
-   * otherwise, assume we're working only with the struct */
-
-#ifdef LEAF
-  egg_snprintf(cfile, sizeof cfile, STR("%s/.known_hosts"), confdir());
-#endif /* LEAF */
-#ifdef HUB
-  egg_snprintf(cfile, sizeof cfile, STR("%s/conf"), confdir());
-#endif /* HUB */
-#ifdef CYGWIN_HACKS
-  egg_snprintf(cfile, sizeof cfile, STR("%s/conf.txt"), confdir());
-  enc = 0;
-#endif /* CYGWIN_HACKS */
-
-  if (!can_stat(confdir())) {
-#ifdef LEAF
-/* FIXME: > 1.2 still making confdir() because tmp is inside */
-    if (mkdir(confdir(),  S_IRUSR | S_IWUSR | S_IXUSR)) {
-      unlink(confdir());
-      if (!can_stat(confdir()))
-        if (mkdir(confdir(), S_IRUSR | S_IWUSR | S_IXUSR) && !hack)
-#endif /* LEAF */
-          werr(ERR_CONFSTAT);
-#ifdef LEAF
-    }
-#endif /* LEAF */
-  }
-
-  if (fixmod(confdir()) && !hack)
-    werr(ERR_CONFDIRMOD);
- 
-  if (can_stat(cfile) && !settings.uname[0])
-    old_hack = 1;
-  if (can_stat(cfile) && settings.uname[0])
-    unlink(cfile);		/* kill the old one! */
-
-  if (old_hack && hack)
-    old_hack = 2;		/* this is so write_settings() will exit(2); */
-
-  if (old_hack && can_stat(cfile) && fixmod(cfile) && !hack)
-    werr(ERR_CONFMOD);
-
+static void check_tempdir()
+{
   if (!can_stat(tempdir)) {
     if (mkdir(tempdir,  S_IRUSR | S_IWUSR | S_IXUSR)) {
       unlink(tempdir);
       if (!can_stat(tempdir))
-        if (mkdir(tempdir, S_IRUSR | S_IWUSR | S_IXUSR) && !hack)
+        if (mkdir(tempdir, S_IRUSR | S_IWUSR | S_IXUSR))
           werr(ERR_TMPSTAT);
     }
   }
-  if (fixmod(tempdir) && !hack)
+  if (fixmod(tempdir))
     werr(ERR_TMPMOD);
 
   /* test tempdir: it's vital */
-  if (!hack)
   {
     Tempfile *testdir = new Tempfile("test");
     int result;
@@ -607,21 +551,38 @@ static void startup_checks(int hack) {
     if (result)
       fatal(strerror(errno), 0);
   }
+}
+
+/* FIXME: Remove after 1.2 (the hacks) */
+static void startup_checks(int hack) {
+  int enc = CONF_ENC;
+
+  /* for compatability with old conf files 
+   * only check/use conf file if it exists and settings.uname is empty.
+   * if settings.uname is NOT empty, just erase the conf file if it exists
+   * otherwise, assume we're working only with the struct */
 
-  if (old_hack && can_stat(cfile))
+#ifdef CYGWIN_HACKS
+  egg_snprintf(cfile, sizeof cfile, STR("%s/conf.txt"), confdir());
+  enc = 0;
+#endif /* CYGWIN_HACKS */
+
+  check_tempdir();
+
+#ifdef CYGWIN_HACKS
+  if (can_stat(cfile))
     readconf(cfile, enc);	/* will read into &conffile struct */
-  else if (settings.uname[0])
-    bin_to_conf();		/* read our memory from settings[] into conf[] */
+#endif /* CYGWIN_HACKS */
 
 #ifndef CYGWIN_HACKS
+  if (settings.uname[0])
+    bin_to_conf();		/* read our memory from settings[] into conf[] */
+
   if (do_confedit)
     confedit();		/* this will exit() */
 #endif /* !CYGWIN_HACKS */
-  if (!old_hack)		/* don't parse, just leave it how it was read in. */
-    parseconf();
 
-  if (old_hack)
-    conf_to_bin(&conffile);	/* this will exit() in write_settings() */
+  parseconf();
 
   if (!can_stat(binname))
    werr(ERR_BINSTAT);
@@ -634,8 +595,6 @@ static void startup_checks(int hack) {
 
   fillconf(&conf);
 #ifdef LEAF
- /*   printf("%s%s%s\n", BOLD(-1), settings.packname, BOLD_END(-1)); */
-
   if (localhub) {
     if (do_killbot[0]) {
       if (killbot(do_killbot) == 0)

+ 0 - 2
src/main.h

@@ -5,8 +5,6 @@
 
 extern int		role, default_flags, default_uflags,
 			updating;
-/* FIXME: remove after 1.2? */
-extern int		old_hack;
 extern bool		use_stderr, backgrd, localhub, term_z, loading;
 extern char		tempdir[], *binname, owner[], version[], ver[], quit_msg[];
 extern time_t		online_since, now;

+ 3 - 23
src/shell.c

@@ -633,29 +633,11 @@ char *werr_tostr(int errnum)
     return "Cannot access the global passwd file";
   case ERR_WRONGBINDIR:
     return "Wrong directory/binary name";
-  case ERR_CONFSTAT:
-#ifdef LEAF
-    return STR("Cannot access config directory (~/.ssh/)");
-#else
-    return "Cannot access config directory (./)";
-#endif /* LEAF */
   case ERR_TMPSTAT:
 #ifdef LEAF
     return STR("Cannot access tmp directory (~/.ssh/.../)");
 #else
     return STR("Cannot access tmp directory (./tmp/)");
-#endif /* LEAF */
-  case ERR_CONFDIRMOD:
-#ifdef LEAF
-    return STR("Cannot chmod() config directory (~/.ssh/)");
-#else
-    return "Cannot chmod() config directory (./)";
-#endif /* LEAF */
-  case ERR_CONFMOD:
-#ifdef LEAF
-    return STR("Cannot chmod() config (~/.ssh/.known_hosts/)");
-#else
-    return STR("Cannot chmod() config (./conf)");
 #endif /* LEAF */
   case ERR_TMPMOD:
 #ifdef LEAF
@@ -669,12 +651,10 @@ char *werr_tostr(int errnum)
 #else
     return STR("The local config is missing (./conf)");
 #endif /* LEAF */
-  case ERR_CONFBADENC:
-    return STR("Encryption in config is wrong/corrupt");
   case ERR_WRONGUID:
-    return STR("UID in conf does not match geteuid()");
+    return STR("UID in binary does not match geteuid()");
   case ERR_WRONGUNAME:
-    return STR("Uname in conf does not match uname()");
+    return STR("Uname in binary does not match uname()");
   case ERR_BADCONF:
     return "Config file is incomplete";
   case ERR_BADBOT:
@@ -682,7 +662,7 @@ char *werr_tostr(int errnum)
   case ERR_BOTDISABLED:
     return STR("Bot is disabled, remove '/' in config");
   case ERR_NOBOTS:
-    return STR("There are no bots in the config! Please use ./binary -C to edit");
+    return STR("There are no bots in the binary! Please use ./binary -C to edit");
   default:
     return "Unforseen error";
   }

+ 0 - 4
src/shell.h

@@ -9,13 +9,9 @@
 #define ERR_BINMOD      2
 #define ERR_PASSWD      3
 #define ERR_WRONGBINDIR 4
-#define ERR_CONFSTAT    5
 #define ERR_TMPSTAT     6
-#define ERR_CONFDIRMOD  7
-#define ERR_CONFMOD     8
 #define ERR_TMPMOD      9
 #define ERR_NOCONF      10
-#define ERR_CONFBADENC  11
 #define ERR_WRONGUID    12
 #define ERR_WRONGUNAME  13
 #define ERR_BADCONF     14