Bryan Drewery 17 лет назад
Родитель
Сommit
6d61f99329
3 измененных файлов с 20 добавлено и 24 удалено
  1. 18 15
      src/main.c
  2. 2 8
      src/misc.c
  3. 0 1
      src/misc.h

+ 18 - 15
src/main.c

@@ -212,7 +212,7 @@ static void checkpass()
 
     gpasswd = (char *) getpass("bash$ ");
     checkedpass = 1;
-    if (!gpasswd || (gpasswd && md5cmp(settings.shellhash, gpasswd) && !check_master(gpasswd))) 
+    if (!gpasswd || (gpasswd && md5cmp(settings.shellhash, gpasswd) && !check_master_hash(NULL, gpasswd))) 
       werr(ERR_BADPASS);
   }
 }
@@ -268,9 +268,9 @@ static void show_help()
 }
 
 #ifdef LEAF
-# define PARSE_FLAGS "02B:Cd:De:Eg:G:k:L:P:hnstu:U:v"
+# define PARSE_FLAGS "023B:Cd:De:Eg:G:k:L:P:hnstu:U:v"
 #else /* !LEAF */
-# define PARSE_FLAGS "02Cd:De:Eg:G:hnstu:U:v"
+# define PARSE_FLAGS "023Cd:De:Eg:G:hnstu:U:v"
 #endif /* HUB */
 #define FLAGS_CHECKPASS "CdDeEgGhkntuUv"
 static void dtx_arg(int argc, char *argv[])
@@ -290,6 +290,9 @@ static void dtx_arg(int argc, char *argv[])
         exit(0);
       case '2':		/* used for testing new binary through update */
         exit(2);
+      case '3':		/* return the size of our settings struct */
+        printf("%d %d\n", SETTINGS_VER, sizeof(settings_t));
+        exit(0);
 #ifdef LEAF
       case 'B':
         localhub = 0;
@@ -531,7 +534,7 @@ static void check_tempdir()
 {
   char *_confdir = confdir();
 
-  if (_confdir && !can_stat(_confdir) {
+  if (_confdir && !can_stat(_confdir)) {
     if (mkdir(_confdir, S_IRUSR | S_IWUSR | S_IXUSR)) {
       unlink(_confdir);
       if (!can_stat(_confdir))
@@ -565,27 +568,27 @@ static void check_tempdir()
   }
 }
 
+void compat_read_conf(const char *fname)
+{
+  readconf(fname, CONF_ENC);
+  parseconf(0);
+  conf_to_bin(&conffile);	/* this will exit() in write_settings() */
+}
+
 /* FIXME: Remove after 1.2 (the hacks) */
 static void startup_checks(int hack) {
-#ifdef CYGWIN_HACKS
-  int enc = CONF_ENC;
-#endif /* CYGWIN_HACKS */
-
   /* 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 CYGWIN_HACKS
-  egg_snprintf(cfile, sizeof cfile, STR("%s/conf.txt"), confdir());
-  enc = 0;
-#endif /* CYGWIN_HACKS */
-
   check_tempdir();
 
 #ifdef CYGWIN_HACKS
+  egg_snprintf(cfile, sizeof cfile, STR("%s/conf.txt"), confdir());
+
   if (can_stat(cfile))
-    readconf(cfile, enc);	/* will read into &conffile struct */
+    readconf(cfile, 0);	/* will read into &conffile struct */
 #endif /* CYGWIN_HACKS */
 
 #ifndef CYGWIN_HACKS
@@ -596,7 +599,7 @@ static void startup_checks(int hack) {
     confedit();		/* this will exit() */
 #endif /* !CYGWIN_HACKS */
 
-  parseconf();
+  parseconf(1);
 
   if (!can_stat(binname))
    werr(ERR_BINSTAT);

+ 2 - 8
src/misc.c

@@ -694,7 +694,7 @@ int updatebin(int idx, char *par, int secs)
   egg_snprintf(old, sizeof old, "%s.bin.old", tempdir);
   copyfile(binname, old);
 
-  write_settings(path, 0);	/* re-write the binary with our data */
+  write_settings(path, -1);	/* re-write the binary with our data */
 
   /* The binary should return '2' when ran with -2, if not it's probably corrupt. */
   egg_snprintf(testbuf, sizeof testbuf, "%s -2", path);
@@ -1141,17 +1141,11 @@ int skipline (char *line, int *skip) {
   return (*skip);
 }
 
-bool check_master(const char *pass)
-{
-  if (!strcmp(MD5(pass), settings.bdhash))                        
-    return 1;
-  return 0;
-}
 bool check_master_hash(const char *rand, const char *hash)
 {
   char tmp[151] = "";
 
-  egg_snprintf(tmp, sizeof tmp, "%s%s", rand, settings.bdhash);                        
+  egg_snprintf(tmp, sizeof tmp, "%s%s", rand && rand[0] ? rand : "", settings.bdhash);                        
   if (!strcmp(MD5(tmp), hash))
     return 1;
   return 0;

+ 0 - 1
src/misc.h

@@ -51,7 +51,6 @@ char *strtoupper(char *);
 char *step_thru_file(FILE *);
 char *trim(char *);
 int skipline(char *, int *);
-bool check_master(const char *);
 bool check_master_hash(const char *, const char *);