ソースを参照

* Changed pack init to -p file
* Binaries are useless until initialized now
* Moved getfullbinname()/check_sum() higher up in main


svn: 1283

Bryan Drewery 22 年 前
コミット
ee19c973fc
3 ファイル変更21 行追加15 行削除
  1. 4 2
      build
  2. 9 8
      src/binary.c
  3. 8 5
      src/main.c

+ 4 - 2
build

@@ -36,7 +36,7 @@ usage()
     echo "    -C        Preforms a distclean before making."
     echo "    -d        Builds a debug package."
     echo "    -n        Do not package the binaries."
-    echo "    -p  FILE  Used for development."
+    echo "    -p  FILE  What file to use as the cfg file."
 }
 
 debug=0
@@ -140,7 +140,7 @@ fi
 echo "[*] Configuring..."
 umask 077 >/dev/null
 
-./configure --silent --with-cfg=${pack}
+./configure --silent
 
 if [ $clean = "1" ]; then
  echo "[*] Cleaning up old binaries/files..."
@@ -156,6 +156,8 @@ _build()
     echo "[!] ${d}${tb} build failed"
     exit 1
   fi
+  echo "[*] Hashing and initializing settings in binary"
+  ${d}${tb} -p ${pack}
  fi
 }
 

+ 9 - 8
src/binary.c

@@ -289,21 +289,22 @@ check_sum(const char *fname, const char *cfgfile)
   MD5_CTX ctx;
 
   MD5_Init(&ctx);
-
+ 
   if (!settings.hash[0]) {
-    if (cfgfile) {
-      printf("* CFGFILE: %s\n", cfgfile);
-      readcfg(cfgfile);
-    }
-    printf("* Wrote checksum to binary. (%s)\n", bin_md5(fname, WRITE_MD5, &ctx));
-tellconfig(&settings);
+
+    if (!cfgfile)
+      fatal("Binary not initialized.", 0);
+
+    readcfg(cfgfile);
+    if (bin_md5(fname, WRITE_MD5, &ctx))
+      printf("* Wrote settings to binary.\n"); 
+    exit(0);
   } else {
     char *hash = NULL;
 
 
     hash = bin_md5(fname, GET_MD5, &ctx);
 
-tellconfig(&settings);
     edpack(&settings, hash, PACK_DEC);
 
     if (strcmp(settings.hash, hash)) {

+ 8 - 5
src/main.c

@@ -704,6 +704,14 @@ int main(int argc, char **argv)
     unlink(argv[0]);
     fatal("!! Invalid binary", 0);
   }
+
+  binname = getfullbinname(argv[0]);
+
+  check_sum(binname, argc >= 3 && !strcmp(argv[1], "-p") ? argv[2] : NULL);
+
+  if (!checked_bin_buf)
+    exit(1);
+
 #ifdef STOP_UAC
   {
     int nvpair[2];
@@ -728,11 +736,6 @@ int main(int argc, char **argv)
   srandom(now % (getpid() + getppid()) * randint(1000));
   myuid = geteuid();
 
-  binname = getfullbinname(argv[0]);
-
-  check_sum(binname, argc >= 3 ? argv[2] : NULL);
-  if (!checked_bin_buf)
-    exit(1);
 #ifdef HUB
   egg_snprintf(userfile, 121, "%s/.u", confdir());
 #endif /* HUB */