Răsfoiți Sursa

* Removed unused variables, and useless 'features' left over from eggdrop

svn: 581
Bryan Drewery 22 ani în urmă
părinte
comite
78fcabbe81
12 a modificat fișierele cu 128 adăugiri și 182 ștergeri
  1. 26 0
      src/bg.c
  2. 1 5
      src/chanprog.c
  3. 0 1
      src/dcc.c
  4. 2 0
      src/debug.c
  5. 7 120
      src/main.c
  6. 65 15
      src/misc.c
  7. 1 6
      src/mod/server.mod/server.c
  8. 1 1
      src/mod/server.mod/server.h
  9. 1 30
      src/mod/server.mod/servmsg.c
  10. 6 2
      src/proto.h
  11. 2 2
      src/tcl.c
  12. 16 0
      src/users.c

+ 26 - 0
src/bg.c

@@ -10,6 +10,7 @@
 
 
 extern char	pid_file[], botnetnick[];
+extern time_t	lastfork, now;
 
 /* Do everything we normally do after we have split off a new
  * process to the background. This includes writing a PID file
@@ -57,3 +58,28 @@ void bg_do_split(void)
   if (xx != 0)
     bg_do_detach(xx);
 }
+
+void do_fork() {
+  int xx;
+
+  xx = fork();
+  if (xx == -1)
+    return;
+  if (xx != 0) {
+      FILE *fp;
+      unlink(pid_file);
+      fp = fopen(pid_file, "w");
+      if (fp != NULL) {
+        fprintf(fp, "%u\n", xx);
+        fclose(fp);
+      }
+  }
+  if (xx) {
+#if HAVE_SETPGID
+    setpgid(xx, xx);
+#endif
+    exit(0);
+  }
+  lastfork = now;
+}
+

+ 1 - 5
src/chanprog.c

@@ -27,7 +27,7 @@ extern char		 ver[], botnetnick[], firewall[], myip[],
                          botuser[], *owners, *hubs;
 
 extern time_t		 now, online_since;
-extern int		 backgrd, term_z, con_chan, cache_hit, cache_miss,
+extern int		 backgrd, term_z, cache_hit, cache_miss,
 			 firewallport, default_flags, conmask,
 			 protect_readonly, noshare, localhub,
 #ifdef HUB
@@ -273,8 +273,6 @@ void tell_verbose_uptime(int idx)
   else {
     if (term_z)
       strcpy(s1, MISC_TERMMODE);
-    else if (con_chan)
-      strcpy(s1, MISC_STATMODE);
     else
       strcpy(s1, MISC_LOGMODE);
   }
@@ -338,8 +336,6 @@ void tell_verbose_status(int idx)
   else {
     if (term_z)
       strcpy(s1, MISC_TERMMODE);
-    else if (con_chan)
-      strcpy(s1, MISC_STATMODE);
     else
       strcpy(s1, MISC_LOGMODE);
   }

+ 0 - 1
src/dcc.c

@@ -51,7 +51,6 @@ int     protect_telnet = 1;
 int	flood_telnet_thr = 10;	/* Number of telnet connections to be
 				   considered a flood			   */
 int	flood_telnet_time = 5;	/* In how many seconds?			   */
-char	bannerfile[121] = ""; /* File displayed on telnet login */
 
 static void dcc_telnet_hostresolved(int);
 static void dcc_telnet_got_ident(int, char *);

+ 2 - 0
src/debug.c

@@ -21,6 +21,8 @@ extern jmp_buf           alarmret;
 extern Tcl_Interp       *interp;
 
 
+int     sdebug = 0;             /* enable debug output? */
+
 void sdprintf EGG_VARARGS_DEF(char *, arg1)
 {
   if (sdebug) {

+ 7 - 120
src/main.c

@@ -19,9 +19,6 @@
 # include <sys/sysinfo.h>
 # define UAC_NOPRINT    0x00000001	/* Don't report unaligned fixups */
 #endif /* STOP_UAC */
-/* Some systems have a working sys/wait.h even though configure will
- * decide it's not bsd compatable.  Oh well.
- */
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -59,7 +56,8 @@ extern char		 origbotname[], userfile[], botnetnick[], packname[],
                          shellhash[], myip6[], myip[], hostname[],
                          hostname6[], natip[];
 extern int		 dcc_total, conmask, cache_hit, cache_miss,
-			 fork_interval, optind, local_fork_interval;
+			 fork_interval, optind, local_fork_interval,
+			 sdebug;
 extern struct dcc_t	*dcc;
 extern struct userrec	*userlist;
 extern struct chanset_t	*chanset;
@@ -71,7 +69,6 @@ extern tcl_timer_t	*timer,
 const time_t 	buildts = CVSBUILD;		/* build timestamp (UTC) */
 const char	egg_version[1024] = "1.0.15";
 const int	egg_numver = 1001500;
-time_t 	lastfork=0;
 
 #ifdef HUB
 int 	my_port;
@@ -85,19 +82,14 @@ int	default_flags = 0;	/* Default user flags and */
 int	default_uflags = 0;	/* Default userdefinied flags for people
 				   who say 'hello' or for .adduser */
 int	backgrd = 1;		/* Run in the background? */
-int     sdebug = 0;		/* enable debug output? */
-int	con_chan = 0;		/* Foreground: constantly display channel
-				   stats? */
+time_t 	lastfork = 0;
 uid_t   myuid;
-int	term_z = 0;		/* Foreground: use the terminal as a party
-				   line? */
+int	term_z = 0;		/* Foreground: use the terminal as a party line? */
 int 	checktrace = 1;		/* Check for trace when starting up? */
-int 	pscloak = 1;
+int 	pscloak = 1;		/* cloak the process name in ps for linux? */
 int 	updating = 0; 		/* this is set when the binary is called from itself. */
 char 	tempdir[DIRMAX] = "";
-char 	lock_file[40] = "";
 char 	*binname;
-char	textdir[121] = "";	/* Directory for text files that get dumped */
 time_t	online_since;		/* Unix-time that the bot loaded up */
 
 char	owner[121] = "";	/* Permanent owner(s) of the bot */
@@ -144,74 +136,6 @@ unsigned long	itraffic_trans_today = 0;
 unsigned long	itraffic_unknown = 0;
 unsigned long	itraffic_unknown_today = 0;
 
-char *homedir()
-{
-  static char homedir[DIRMAX] = "";
-  if (!homedir || (homedir && !homedir[0])) {
-    char tmp[DIRMAX];
-    struct passwd *pw;
-    sdprintf(STR("If the bot dies after this, try compiling on Debian."));
-    Context;
-    pw = getpwuid(geteuid());
-    sdprintf(STR("End Debian suggestion."));
-
-    if (!pw)
-     werr(ERR_PASSWD);
-    Context;
-    egg_snprintf(tmp, sizeof tmp, "%s", pw->pw_dir);
-    Context;
-    realpath(tmp, homedir); /* this will convert lame home dirs of /home/blah->/usr/home/blah */
-  }
-  return homedir;
-}
-
-char *confdir()
-{
-  static char confdir[DIRMAX] = "";
-  if (!confdir || (confdir && !confdir[0])) {
-#ifdef LEAF
-    {
-      egg_snprintf(confdir, sizeof confdir, "%s/.ssh", homedir());
-    }
-#endif /* LEAF */
-#ifdef HUB
-    {
-      char *tmpdir;
-
-      tmpdir = nmalloc(strlen(binname) + 1);
-      strcpy(tmpdir, binname);
-      egg_snprintf(confdir, sizeof confdir, "%s", dirname(tmpdir));
-      nfree(tmpdir);
-    }
-#endif /* HUB */
-  }
-  return confdir;
-}
-
-char *my_uname() 
-{
-  static char os_uname[250] = "";
-  if (!os_uname || (os_uname && !os_uname[0])) {
-    char *unix_n, *vers_n;
-    struct utsname un;
-
-      if (uname(&un) < 0) {
-        unix_n = "*unkown*";
-        vers_n = "";
-      } else {
-        unix_n = un.nodename;
-#ifdef __FreeBSD__
-        vers_n = un.release;
-#else /* __linux__ */
-        vers_n = un.version;
-#endif /* __FreeBSD__ */
-      }
-    egg_snprintf(os_uname, sizeof os_uname, "%s %s", unix_n, vers_n);
-  }
-  return os_uname;
-}
-
-
 void fatal(const char *s, int recoverable)
 {
   int i;
@@ -497,30 +421,6 @@ static void dtx_arg(int argc, char *argv[])
   }
 }
 
-void do_fork() {
-  int xx;
-
-  xx = fork();
-  if (xx == -1)
-    return;
-  if (xx != 0) {
-      FILE *fp;
-      unlink(pid_file);
-      fp = fopen(pid_file, "w");
-      if (fp != NULL) {
-        fprintf(fp, "%u\n", xx);
-        fclose(fp);
-      }
-  }  
-  if (xx) {
-#if HAVE_SETPGID
-    setpgid(xx, xx);
-#endif
-    exit(0);
-  }
-  lastfork = now;
-}
-
 #ifdef CRAZY_TRACE
 /* This code will attach a ptrace() to getpid() hence blocking process hijackers/tracers on the pid
  * only problem.. it just creates a new pid to be traced/hijacked :\
@@ -559,11 +459,6 @@ static int		lastmin = 99;
 static time_t		then;
 static struct tm	nowtm;
 
-/* Called once a second.
- *
- * Note:  Try to not put any Context lines in here (guppy 21Mar2000).
- */
-
 int curcheck = 0;
 void core_10secondly()
 {
@@ -600,7 +495,7 @@ static void core_secondly()
 #endif /* CRAZY_TRACE */
   do_check_timers(&utimer);	/* Secondly timers */
   if (fork_interval && backgrd) {
-    if (now-lastfork > fork_interval)
+    if ((now - lastfork) > fork_interval)
       do_fork();
   }
   cnt++;
@@ -609,13 +504,6 @@ static void core_secondly()
   if ((cnt % 10) == 0) {
     call_hook(HOOK_10SECONDLY);
     check_expired_dcc();
-    if (con_chan && !backgrd) {
-      dprintf(DP_STDOUT, "\033[2J\033[1;1H");
-      tell_verbose_status(DP_STDOUT);
-      do_module_report(DP_STDOUT, 0, "server");
-      do_module_report(DP_STDOUT, 0, "channels");
-      tell_mem_status_dcc(DP_STDOUT);
-    }
   }
   if ((cnt % 30) == 0) {
     autolink_cycle(NULL);         /* attempt autolinks */
@@ -628,7 +516,6 @@ static void core_secondly()
 #else /* !S_UTCTIME */
   egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
 #endif /* S_UTCTIME */
-
   if (nowtm.tm_min != lastmin) {
     int i = 0;
 
@@ -701,7 +588,7 @@ static void check_mypid()
     fclose(fp);
   }
 }
-#endif
+#endif /* LEAF */
 
 static void core_minutely()
 {

+ 65 - 15
src/misc.c

@@ -37,10 +37,10 @@ extern tand_t 		*tandbot;
 
 extern char		 version[], origbotname[], botname[],
 			 admin[], network[], motdfile[], ver[], botnetnick[],
-			 bannerfile[], textdir[], userfile[], dcc_prefix[],
+			 userfile[], dcc_prefix[],
                          *binname, pid_file[], tempdir[], *owneremail;
 
-extern int		 backgrd, con_chan, term_z, use_stderr, dcc_total, timesync,  
+extern int		 backgrd, term_z, use_stderr, dcc_total, timesync,  
 #ifdef HUB
                          my_port,
 #endif
@@ -639,7 +639,7 @@ void putlog EGG_VARARGS_DEF(int, arg1)
 	  (!rfc_casecmp(chname, dcc[i].u.chat->con_chan)))
 	dprintf(i, "%s", out);
     }
-  if ((!backgrd) && (!con_chan) && (!term_z))
+  if ((!backgrd) && (!term_z))
     dprintf(DP_STDOUT, "%s", out);
   else if ((type & LOG_MISC) && use_stderr) {
     if (shtime)
@@ -2287,18 +2287,68 @@ void baduname(char *conf, char *my_uname) {
 }
 
 
-int whois_access(struct userrec *user, struct userrec *whois_user) 
+char *homedir()
 {
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  struct flag_record whois = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
- 
-  get_user_flagrec(user, &fr, NULL);
-  get_user_flagrec(whois_user, &whois, NULL);
+  static char homedir[DIRMAX] = "";
+  if (!homedir || (homedir && !homedir[0])) {
+    char tmp[DIRMAX];
+    struct passwd *pw;
+    sdprintf(STR("If the bot dies after this, try compiling on Debian."));
+    Context;
+    pw = getpwuid(geteuid());
+    sdprintf(STR("End Debian suggestion."));
 
-  if ((glob_master(whois) && !glob_master(fr)) ||
-     (glob_owner(whois) && !glob_owner(fr)) ||
-     (glob_admin(whois) && !glob_admin(fr)) ||
-     (glob_bot(whois) && !glob_master(fr)))
-    return 0;
-  return 1;
+    if (!pw)
+     werr(ERR_PASSWD);
+    Context;
+    egg_snprintf(tmp, sizeof tmp, "%s", pw->pw_dir);
+    Context;
+    realpath(tmp, homedir); /* this will convert lame home dirs of /home/blah->/usr/home/blah */
+  }
+  return homedir;
+}
+
+char *confdir()
+{
+  static char confdir[DIRMAX] = "";
+  if (!confdir || (confdir && !confdir[0])) {
+#ifdef LEAF
+    {
+      egg_snprintf(confdir, sizeof confdir, "%s/.ssh", homedir());
+    }
+#endif /* LEAF */
+#ifdef HUB
+    {
+      char *buf = nmalloc(strlen(binname) + 1);
+      strcpy(buf, binname);
+      egg_snprintf(confdir, sizeof confdir, "%s", dirname(buf));
+      nfree(buf);
+    }
+#endif /* HUB */
+  }
+  return confdir;
+}
+
+char *my_uname()
+{
+  static char os_uname[250] = "";
+  if (!os_uname || (os_uname && !os_uname[0])) {
+    char *unix_n, *vers_n;
+    struct utsname un;
+
+    if (uname(&un) < 0) {
+      unix_n = "*unkown*";
+      vers_n = "";
+    } else {
+      unix_n = un.nodename;
+#ifdef __FreeBSD__
+      vers_n = un.release;
+#else /* __linux__ */
+      vers_n = un.version;
+#endif /* __FreeBSD__ */
+    }
+    egg_snprintf(os_uname, sizeof os_uname, "%s %s", unix_n, vers_n);
+  }
+  return os_uname;
 }
+

+ 1 - 6
src/mod/server.mod/server.c

@@ -43,7 +43,6 @@ static time_t server_online;	/* server connection time */
 static time_t server_cycle_wait;	/* seconds to wait before
 					   re-beginning the server list */
 static char botrealname[121];	/* realname of bot */
-static int min_servs;		/* minimum number of servers to be around */
 static int server_timeout;	/* server timeout for connecting */
 static int never_give_up;	/* never give up when connecting to servers? */
 static int strict_servernames;	/* don't update server list */
@@ -1272,7 +1271,6 @@ static void do_nettype(void)
 static tcl_ints my_tcl_ints[] =
 {
   {"use-console-r",		NULL,				1},
-  {"servlimit",			&min_servs,			0},
   {"server-timeout",		&server_timeout,		0},
   {"lowercase-ctcp",		&lowercase_ctcp,		0},
   {"server-online",		(int *) &server_online,		2},
@@ -1565,8 +1563,6 @@ static void server_report(int idx, int details)
     dprintf(idx, "    %s %d%%, %d msgs\n", IRC_HELPQUEUE,
            (int) ((float) (hq.tot * 100.0) / (float) maxqmsg), (int) hq.tot);
   if (details) {
-    if (min_servs)
-      dprintf(idx, "    Requiring a net of at least %d server(s)\n", min_servs);
     dprintf(idx, "    Flood is: %d msg/%ds, %d ctcp/%ds\n",
 	    flud_thr, flud_time, flud_ctcp_thr, flud_ctcp_time);
   }
@@ -1659,7 +1655,7 @@ static Function server_table[] =
   /* 24 - 27 */
   (Function) & default_port,	/* int					*/
   (Function) & server_online,	/* int					*/
-  (Function) & min_servs,	/* int					*/
+  (Function) 0,	
   (Function) & H_raw,		/* p_tcl_bind_list			*/
   /* 28 - 31 */
   (Function) 0,
@@ -1712,7 +1708,6 @@ char *server_start(Function *global_funcs)
   server_online = 0;
   server_cycle_wait = 15;
   strcpy(botrealname, "A deranged product of evil coders");
-  min_servs = 0;
   server_timeout = 15;
   never_give_up = 1;
   strict_servernames = 1;

+ 1 - 1
src/mod/server.mod/server.h

@@ -38,7 +38,7 @@
 #define cycle_time (*(int *)(server_funcs[23]))
 #define default_port (*(int *)(server_funcs[24]))
 #define server_online (*(int *)(server_funcs[25]))
-#define min_servs (*(int *)(server_funcs[26]))
+/* 26 -- UNUSED */
 /* 27 - 30 */
 #define H_raw (*(p_tcl_bind_list *)(server_funcs[27]))
 #define H_msg (*(p_tcl_bind_list *)(server_funcs[29]))

+ 1 - 30
src/mod/server.mod/servmsg.c

@@ -651,34 +651,6 @@ static int gotnotice(char *from, char *msg)
   return 0;
 }
 
-/* got 251: lusers
- * <server> 251 <to> :there are 2258 users and 805 invisible on 127 servers
- */
-static int got251(char *from, char *msg)
-{
-  int i;
-  char *servs;
-
-  if (min_servs == 0)
-    return 0;			/* No minimum limit on servers */
-  newsplit(&msg);
-  fixcolon(msg);		/* NOTE!!! If servlimit is not set or is 0 */
-  for (i = 0; i < 8; i++)
-    newsplit(&msg);		/* lusers IS NOT SENT AT ALL!! */
-  servs = newsplit(&msg);
-  if (strncmp(msg, "servers", 7))
-    return 0;			/* Was invalid format */
-  while (*servs && (*servs < 32))
-    servs++;			/* I've seen some lame nets put bolds &
-				 * stuff in here :/ */
-  i = atoi(servs);
-  if (i < min_servs) {
-    putlog(LOG_SERV, "*", IRC_AUTOJUMP, min_servs, i);
-    nuke_server(IRC_CHANGINGSERV);
-  }
-  return 0;
-}
-
 /* WALLOPS: oper's nuisance
  */
 static int gotwall(char *from, char *msg)
@@ -716,7 +688,7 @@ static void server_10secondly()
 static void minutely_checks()
 {
   /* Only check if we have already successfully logged in.  */
-  if (server_online && (min_servs != 0)) {
+  if (server_online) {
     static int count = 4;
     int ok = 0;
     struct chanset_t *chan;
@@ -1176,7 +1148,6 @@ static cmd_t my_raw_binds[] =
   {"PONG",	"",	(Function) gotpong,		NULL},
   {"WALLOPS",	"",	(Function) gotwall,		NULL},
   {"001",	"",	(Function) got001,		NULL},
-  {"251",	"",	(Function) got251,		NULL},
   {"303",	"",	(Function) got303,		NULL},
   {"432",	"",	(Function) got432,		NULL},
   {"433",	"",	(Function) got433,		NULL},

+ 6 - 2
src/proto.h

@@ -41,7 +41,8 @@ extern int (*match_noterej) (struct userrec *, char *);
 #endif
 
 /* bg.c */
-void bg_do_split(void);
+void do_fork();
+void bg_do_split();
 
 /* botcmd.c */
 void bounce_simul(int, char *);
@@ -236,7 +237,9 @@ void set_cmd_pass(char *, int);
 #endif /* S_DCCPASS */
 
 /* misc.c */
-int whois_access(struct userrec *, struct userrec *);
+char *homedir();
+char *my_uname();
+char *confdir();
 void baduname(char *, char *);
 int email(char *, char *, int);
 char *color(int, int, int);
@@ -383,6 +386,7 @@ void user_del_chan(char *);
 char *fixfrom(char *);
 
 /* users.c */
+int whois_access(struct userrec *, struct userrec *);
 #ifdef HUB
 void backup_userfile();
 #endif /* HUB */

+ 2 - 2
src/tcl.c

@@ -43,8 +43,8 @@ extern int	backgrd, flood_telnet_thr, flood_telnet_time,
 extern char	origbotname[], botuser[], motdfile[], admin[], userfile[],
                 firewall[], notify_new[], hostname[], hostname6[], myip[], myip6[],
 		tempdir[], owner[], network[], botnetnick[],
-		bannerfile[], egg_version[], natip[], 
-		textdir[], pid_file[], dcc_prefix[];
+		egg_version[], natip[], 
+		pid_file[], dcc_prefix[];
 
 extern struct dcc_t	*dcc;
 extern tcl_timer_t	*timer, *utimer;

+ 16 - 0
src/users.c

@@ -1283,3 +1283,19 @@ void autolink_cycle(char *start)
 }
 #endif /* LEAF */
 
+int whois_access(struct userrec *user, struct userrec *whois_user)
+{
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+  struct flag_record whois = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+
+  get_user_flagrec(user, &fr, NULL);
+  get_user_flagrec(whois_user, &whois, NULL);
+
+  if ((glob_master(whois) && !glob_master(fr)) ||
+     (glob_owner(whois) && !glob_owner(fr)) ||
+     (glob_admin(whois) && !glob_admin(fr)) ||
+     (glob_bot(whois) && !glob_master(fr)))
+    return 0;
+  return 1;
+}
+