Explorar el Código

* Fixed rehash() to work as intended
* took out 'return;' from cmd_restart
* reorganized main.c init's
* Fixed some compile issues


svn: 192

Bryan Drewery hace 22 años
padre
commit
1ab8701841
Se han modificado 7 ficheros con 36 adiciones y 41 borrados
  1. 1 0
      src/auth.c
  2. 0 2
      src/chanprog.c
  3. 5 2
      src/cmds.c
  4. 3 4
      src/config.c
  5. 19 24
      src/main.c
  6. 1 1
      src/mod/modvals.h
  7. 7 8
      src/proto.h

+ 1 - 0
src/auth.c

@@ -31,6 +31,7 @@ extern struct chanset_t	*chanset;
 extern time_t		 now;
 
 #ifdef S_AUTH
+extern char 		authkey[];
 int auth_total = 0;
 int max_auth = 100;
 struct auth_t *auth = 0;

+ 0 - 2
src/chanprog.c

@@ -707,12 +707,10 @@ void reload()
 void rehash()
 {
   call_hook(HOOK_PRE_REHASH);
-#ifdef HUB
   noshare = 1;
   clear_userlist(userlist);
   noshare = 0;
   userlist = NULL;
-#endif /* HUB */
   chanprog();
 }
 

+ 5 - 2
src/cmds.c

@@ -1668,7 +1668,7 @@ static void cmd_randstring(struct userrec *u, int idx, char *par)
 
 static void cmd_restart(struct userrec *u, int idx, char *par)
 {
-return;
+
   putlog(LOG_CMDS, "*", STR("#%s# restart"), dcc[idx].nick);
   if (!backgrd) {
     dprintf(idx, STR("You cannot %srestart a bot when running -n (due to Tcl).\n"), dcc_prefix);
@@ -1677,10 +1677,13 @@ return;
   dprintf(idx, STR("Restarting.\n"));
 #ifdef HUB
   write_userfile(-1);
-#endif
+#endif /* HUB */
   putlog(LOG_MISC, "*", STR("Restarting ..."));
+Context;
   wipe_timers(interp, &utimer);
+Context;
   wipe_timers(interp, &timer);
+Context;
   do_restart = idx;
 }
 

+ 3 - 4
src/config.c

@@ -468,7 +468,8 @@ int has_cmd_pass(char *cmd)
   return 0;
 }
 
-void set_cmd_pass(char *ln, int shareit) {
+void set_cmd_pass(char *ln, int shareit) 
+{
   struct cmd_pass *cp;
   char *cmd;
 
@@ -541,7 +542,6 @@ struct cfg_entry *check_can_set_cfg(char *target, char *entryname)
 void set_cfg_str(char *target, char *entryname, char *data)
 {
   struct cfg_entry *entry;
-  int free = 0;
 
   if (!(entry = check_can_set_cfg(target, entryname)))
     return;
@@ -588,7 +588,6 @@ void set_cfg_str(char *target, char *entryname, char *data)
     char *olddata = entry->gdata;
 
     if (data) {
-      free = 1;
       entry->gdata = nmalloc(strlen(data) + 1);
       strcpy(entry->gdata, data);
     } else
@@ -649,7 +648,7 @@ void got_config_share(int idx, char *ln)
 
 void add_cfg(struct cfg_entry *entry)
 {
-  cfg = (void *) user_realloc(cfg, sizeof(void *) * (cfg_count + 1));
+  cfg = (void *) nrealloc(cfg, sizeof(void *) * (cfg_count + 1));
   cfg[cfg_count] = entry;
   cfg_count++;
   entry->ldata = NULL;

+ 19 - 24
src/main.c

@@ -958,8 +958,6 @@ Context;
     fatal(STR("Wrong number of arguments: -e/-d <infile> <outfile/STDOUT>"),0);
   if (!strcmp(in, out))
     fatal(STR("<infile> should NOT be the same name as <outfile>"), 0);
-  check_static("blowfish", blowfish_start);
-  module_load(ENCMOD);
   if (!strcmp(which, "e")) {
     EncryptFile(in, out);
     fatal(STR("File Encryption complete"),3);
@@ -1064,9 +1062,6 @@ static void gotspawn(char *filename)
   if (!(fp = fopen(filename, "r")))
     fatal(STR("Cannot read from local config (2)"), 0);
 
-  check_static("blowfish", blowfish_start);
-  module_load(ENCMOD);
-
   while(fscanf(fp,"%[^\n]\n",templine) != EOF) 
   {
     Context;
@@ -1409,13 +1404,29 @@ int main(int argc, char **argv)
   myuid = geteuid();
   binname = getfullbinname(argv[0]);
 
+  /* just load everything now, won't matter if it's loaded if the bot has to suicide on startup */
+  init_auth();
+  init_config();
+  init_dcc_max();
+  init_userent();
+  init_misc();
+  init_bots();
+  init_net();
+  init_modules();
+  init_settings();
+  init_userrec();
+  if (backgrd)
+    bg_prepare_split();
+  init_tcl(argc, argv);
+  init_botcmd();
+  link_statics();
+  module_load(ENCMOD);
+
   if (!can_stat(binname))
    werr(ERR_BINSTAT);
   if (!fixmod(binname))
    werr(ERR_BINMOD);
 
-  init_settings();
-  init_tcl(argc, argv);
   if (argc) {
     sdprintf(STR("Calling dtx_arg with %d params."), argc);
     dtx_arg(argc, argv);
@@ -1507,21 +1518,6 @@ int main(int argc, char **argv)
   if (!fixmod(cfile))
     werr(ERR_CONFMOD);
 
-  init_dcc_max();
-  init_userent();
-  init_misc();
-  init_auth();
-  init_config();
-  init_bots();
-  init_net();
-  init_modules();
-  init_userrec();
-  if (backgrd)
-    bg_prepare_split();
-  init_botcmd();
-  link_statics();
-  module_load(ENCMOD);
-
 #ifdef LEAF
   if (localhub) { //we only want to read the config if we are the spawn bot..
 #endif /* LEAF */
@@ -1688,8 +1684,7 @@ int main(int argc, char **argv)
     check_crontab();
 #ifdef LEAF
   }
-#endif
-
+#endif /* LEAF */
 
   if (!encrypt_pass) {
     sdprintf(MOD_NOCRYPT);

+ 1 - 1
src/mod/modvals.h

@@ -42,7 +42,7 @@
 #define HOOK_DIE		 15
 #define HOOK_10SECONDLY          16
 #define HOOK_30SECONDLY          17
-#define HOOK_3SECONDLY		18
+#define HOOK_3SECONDLY           18
 #define REAL_HOOKS		 19
 //#define HOOK_CHANFILE            17
 #define HOOK_SHAREOUT		105

+ 7 - 8
src/proto.h

@@ -50,14 +50,6 @@ void bot_share(int, char *);
 void bot_shareupdate(int, char *);
 int base64_to_int(char *);
 
-
-/* pcrypt.c */
-char *cryptit (char *);
-char *decryptit (char *);
-int lfprintf(FILE *, char *, ...);
-void EncryptFile(char *, char *);
-void DecryptFile(char *, char *);
-
 /* botnet.c */
 void lower_bot_linked(int idx);
 void higher_bot_linked(int idx);
@@ -138,6 +130,13 @@ char *stripmasktype(int);
 void gotremotecmd(char * forbot, char * frombot, char * fromhand, char * fromidx, char * cmd);
 void gotremotereply(char * frombot, char * tohand, char * toidx, char * ln);
 
+/* crypt.c */
+char *cryptit (char *);
+char *decryptit (char *);
+int lfprintf(FILE *, char *, ...);
+void EncryptFile(char *, char *);
+void DecryptFile(char *, char *);
+
 /* dcc.c */
 void failed_link(int);
 void dupwait_notify(char *);