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

* Added struct fields for conf
-now just need to convert old functions and add compatability


svn: 1298

Bryan Drewery 22 лет назад
Родитель
Сommit
8e55bb000d
3 измененных файлов с 84 добавлено и 44 удалено
  1. 1 1
      Makefile.in
  2. 65 42
      src/binary.c
  3. 18 1
      src/settings.h

+ 1 - 1
Makefile.in

@@ -35,7 +35,7 @@ LIBS = @LIBS@ @ZLIB@ @RESLIB@
 DEBCFLAGS = -DDEBUG_ASSERT -DDEBUG_MEM -Dinline= -fno-inline -g3 -ggdb3
 CFLGS = -fno-strict-aliasing -W -Wformat \
 -Wshadow -Wnested-externs -Wno-format-y2k \
--Wlarger-than-4096 -Wpointer-arith -Wcast-align \
+-Wlarger-than-6608 -Wpointer-arith -Wcast-align \
 -Waggrepate-return -Wbad-function-cast \
 -Wlong-long @GCC3@
 

+ 65 - 42
src/binary.c

@@ -14,7 +14,6 @@
 #include "main.h"
 #include "misc_file.h"
 
-
 /*
 typedef struct encdata_struct {
   char prefix[PREFIXLEN];
@@ -29,7 +28,12 @@ static encdata_t encdata = {
 
 settings_t settings = {
   "AAAAAAAAAAAAAAAA",
-  "", "", "", "", "", "", "", "", "", "", "",
+  /* -- STATIC -- */
+  "", "", "", "", "", "", "", "", "", "",
+  /* -- DYNAMIC -- */
+  "", "", "", "", "", "", "", "", "", "", "", "", "",
+  /* -- PADDING */
+  ""
 };
 
 #define PACK_ENC 1
@@ -236,51 +240,67 @@ static void edpack(struct settings_struct *incfg, const char *hash, int what)
   else
     enc_dec_string = decrypt_string;
 
-  tmp = enc_dec_string(hash, incfg->hash);
-  egg_snprintf(incfg->hash, sizeof(incfg->hash), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->packname);
-  egg_snprintf(incfg->packname, sizeof(incfg->packname), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->shellhash);
-  egg_snprintf(incfg->shellhash, sizeof(incfg->shellhash), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->bdhash);
-  egg_snprintf(incfg->bdhash, sizeof(incfg->bdhash), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->dcc_prefix);
-  egg_snprintf(incfg->dcc_prefix, sizeof(incfg->dcc_prefix), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->owners);
-  egg_snprintf(incfg->owners, sizeof(incfg->owners), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->owneremail);
-  egg_snprintf(incfg->owneremail, sizeof(incfg->owneremail), tmp);
-  free(tmp);
-
-  tmp = enc_dec_string(hash, incfg->hubs);
-  egg_snprintf(incfg->hubs, sizeof(incfg->hubs), tmp);
-  free(tmp);
+#define dofield(_field) 		do {		\
+	tmp = enc_dec_string(hash, _field);		\
+	egg_snprintf(_field, sizeof(_field), tmp);	\
+	free(tmp);					\
+} while (0)
+
+  /* -- STATIC -- */
+  dofield(incfg->hash);
+  dofield(incfg->packname);
+  dofield(incfg->shellhash);
+  dofield(incfg->bdhash);
+  dofield(incfg->dcc_prefix);
+  dofield(incfg->owners);
+  dofield(incfg->owneremail);
+  dofield(incfg->hubs);
+  /* -- DYNAMIC -- */
+  dofield(incfg->bots);
+  dofield(incfg->uid);
+  dofield(incfg->autouname);
+  dofield(incfg->pscloak);
+  dofield(incfg->autocron);
+  dofield(incfg->watcher);
+  dofield(incfg->uname);
+  dofield(incfg->username);
+  dofield(incfg->homedir);
+  dofield(incfg->binpath);
+  dofield(incfg->binname);
+  dofield(incfg->portmin);
+  dofield(incfg->portmax);
+#undef dofield
 }
 
 
 static void
 tellconfig(struct settings_struct *incfg)
 {
-  printf("hash: %s\n", incfg->hash);
-  printf("packname: %s\n", incfg->packname);
-  printf("shellhash: %s\n", incfg->shellhash);
-  printf("bdhash: %s\n", incfg->bdhash);
-  printf("dccprefix: %s\n", incfg->dcc_prefix);
-  printf("owners: %s\n", incfg->owners);
-  printf("owneremails: %s\n", incfg->owneremail);
-  printf("hubs: %s\n", incfg->hubs);
+#define dofield(_field)		printf("%s: %s\n", #_field, _field);
+  /* -- STATIC -- */
+  dofield(incfg->hash);
+  dofield(incfg->packname);
+  dofield(incfg->shellhash);
+  dofield(incfg->bdhash);
+  dofield(incfg->dcc_prefix);
+  dofield(incfg->owners);
+  dofield(incfg->owneremail);
+  dofield(incfg->hubs);
+  /* -- DYNAMIC -- */
+  dofield(incfg->bots);
+  dofield(incfg->uid);
+  dofield(incfg->autouname);
+  dofield(incfg->pscloak);
+  dofield(incfg->autocron);
+  dofield(incfg->watcher);
+  dofield(incfg->uname);
+  dofield(incfg->username);
+  dofield(incfg->homedir);
+  dofield(incfg->binpath);
+  dofield(incfg->binname);
+  dofield(incfg->portmin);
+  dofield(incfg->portmax);
+#undef dofield
 }
 
 void
@@ -296,6 +316,7 @@ check_sum(const char *fname, const char *cfgfile)
       fatal("Binary not initialized.", 0);
 
     readcfg(cfgfile);
+tellconfig(&settings);
     if (bin_md5(fname, WRITE_MD5, &ctx))
       printf("* Wrote settings to binary.\n"); 
     exit(0);
@@ -304,8 +325,10 @@ check_sum(const char *fname, const char *cfgfile)
 
 
     hash = bin_md5(fname, GET_MD5, &ctx);
-
+tellconfig(&settings);
     edpack(&settings, hash, PACK_DEC);
+printf("\n\n");
+tellconfig(&settings);
 
     if (strcmp(settings.hash, hash)) {
       unlink(fname);

+ 18 - 1
src/settings.h

@@ -4,6 +4,7 @@
 
 typedef struct settings_struct {
   char prefix[PREFIXLEN];
+  /* -- STATIC -- */
   char hash[65];
   char packname[65];
   char shellhash[65];
@@ -14,7 +15,23 @@ typedef struct settings_struct {
   char salt1[65];
   char salt2[45];
   char dcc_prefix[25];
-  char pad_3418_to_3488[5];
+  /* -- DYNAMIC -- */
+ 
+  char bots[1389];
+  char uid[25];
+  char autouname[25];        /* should we just auto update any changed in uname output? */
+  char pscloak[25];          /* should the bots bother trying to cloak `ps`? */
+  char autocron[25];         /* should the bot auto crontab itself? */
+  char watcher[25];          /* spawn a watcher pid to block ptrace? */
+  char uname[489];
+  char username[45];       /* shell username */
+  char homedir[489];        /* homedir */
+  char binpath[489];        /* path to binary, ie: ~/ */
+  char binname[45];        /* 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[4];
 } settings_t;
 
 extern settings_t       settings;