Bladeren bron

* Re-wrote build to use getopts
* Re-wrote settings system
-Now uses makesettings and pack.cfg
-Renamed thepass to bdhash, and shellpass to shellhash
-Changed some core settings strings to *chars
-Added PACKNAME
-Added owner email addresses
-Changed netpass externs to *netpass
-Setup 'enetpass' for modules.c
* Only recompile settings.c if needed
* Fixed make depleaf/dephub
* Added my_malloc() my_realloc() my_free() and my_bzero()
* Changed several occurances of my_free() in userent.c to nfree()
* Do init_settings() first


svn: 200

Bryan Drewery 22 jaren geleden
bovenliggende
commit
5c3a2dfd08

+ 18 - 29
Makefile.in

@@ -80,7 +80,7 @@ MAKE_DHUB = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD) -g' \
 'EGGEXEC=$(HUBEXEC)' 'EGGBUILD=(debug hub)' 'MODOBJS=mod/*.o'
 
 MAKE_UTILS = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'STRIP=$(STRIP)' \
-'CFLGS=$(CFLGS) -DSTANDALONE' 'XREQS=$(XREQS)' \
+'CFLGS=$(CFLGS)' 'XREQS=$(XREQS)' \
 'XLIBS=$(XLIBS)' 'LD=$(LD)'
 
 MAKE_DEPEND = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \
@@ -97,14 +97,11 @@ cleanutils:
 	@rm -f stringfix
 	@misc/dostrings l
 
-cleanpack:
-	@rm -f src/settings.c
-
-clean:  cleanutils cleanpack
+clean:  cleanutils
 	@cd src && $(MAKE) clean
 	@cd src/compat && $(MAKE) clean
-	@rm -f $(HUBEXEC) $(LEAFEXEC) *.stamp core DEBUG *~ key configure.temp makesalt 
-	@rm -f $(HUBEXEC).* $(LEAFEXEC).* src/makesalt
+	@rm -f $(HUBEXEC) $(LEAFEXEC) *.stamp core DEBUG *~ key configure.temp makesalt makesettings
+	@rm -f $(HUBEXEC).* $(LEAFEXEC).* src/makesalt src/makesettings src/settings.c src/settings.tmp
 
 distclean: clean clean-modconfig
 	@cd src/mod && $(MAKE) distclean
@@ -118,7 +115,7 @@ distrib: distclean
 	@rm -rf `find . \( -name 'CVS' \) -print`
 
 depend:
-	@cat /dev/null > lush.h
+#	@cat /dev/null > lush.h
 	@cd src && $(MAKE_DEPEND) depend
 	@cd src/mod && $(MAKE_DEPEND) depend
 	@cd src/compat && $(MAKE_DEPEND) depend
@@ -126,6 +123,13 @@ depend:
 eggautoconf:
 	@$(modconf) eggautoconf
 
+packconf: utils
+	@./makesettings pack/pack.cfg src/settings.tmp
+	@(if test "x`diff -urN src/settings.tmp src/settings.c`" != "x"; then \
+	cp -f src/settings.tmp src/settings.c; \
+	fi)
+#	@cp -fu pack/settings.c src/settings.c
+
 salt:	utils
 	@./makesalt
 
@@ -142,39 +146,24 @@ clean-modconfig:
 
 reconfig: clean-modconfig config
 
-packconf:
-	@rm -f src/settings.c
-	@echo "/* DO NOT EDIT THIS FILE DIRECTLY, EDIT pack/settings.c */" > src/settings.c
-	@echo " " >> src/settings.c
-	@cat pack/settings.c >> src/settings.c
-#	@cp -f pack/settings.c src/settings.c
-
-utils:  packconf
+utils:  
 	@cd src && $(MAKE_UTILS) ../stringfix
 	@misc/dostrings
 	@cd src && $(MAKE_UTILS) ../makesalt
+	@cd src && $(MAKE_UTILS) ../makesettings
 
 depleaf:
-	@echo ""
-	@echo ""
-	@echo ""
-	@echo "----------------------------------------WTF?_---------------------------------"
-	@echo ""
-	@echo ""
-	@echo ""
-	@cat /dev/null > lush.h
 	@cd src && $(MAKE_DEPEND) depleaf
 	@cd src/mod && $(MAKE_DEPEND) depleaf
 	@cd src/compat && $(MAKE_DEPEND) depleaf
 
 dephub:
-	@cat /dev/null > lush.h
 	@cd src && $(MAKE_DEPEND) dephub
 	@cd src/mod && $(MAKE_DEPEND) dephub
 	@cd src/compat && $(MAKE_DEPEND) dephub
 
 
-leaf:	utils salt config
+leaf:	utils salt config packconf
 	@echo ""
 	@echo "Making leaf"
 	@echo ""
@@ -186,7 +175,7 @@ leaf:	utils salt config
 	@cd src && $(MAKE_LEAF) $(LEAFEXEC)
 	@echo ""
 
-dleaf:  utils salt config
+dleaf:  utils salt config packconf
 	@echo ""
 	@echo "Making debug leaf"
 	@echo ""
@@ -198,7 +187,7 @@ dleaf:  utils salt config
 	@cd src && $(MAKE_DLEAF) $(LEAFEXEC)
 	@echo ""
 
-hub:	utils salt config
+hub:	utils salt config packconf
 	@echo ""
 	@echo "Making hub"
 	@echo ""
@@ -211,7 +200,7 @@ hub:	utils salt config
 	@cd src && $(MAKE_HUB) $(HUBEXEC)
 	@echo ""
 
-dhub:   utils salt config
+dhub:   utils salt config packconf
 	@echo ""
 	@echo "Making debug hub"
 	@echo ""

+ 47 - 42
build

@@ -1,71 +1,75 @@
 #!/bin/sh
 
-#add in 'cont' support for NOT using make clean.
-
-#change this to 0 to not clean previously compiled files (faster/for dev)
-clean=0
-
-
-#### DO NOT EDIT BELOW THIS LINE #####
 
 # Awk out the version from source
+ver="?.?.?"
 ver=`cat src/main.c 2>&1 | grep "char" | awk '/egg_version/ {print $4}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
 numver=`cat src/main.c 2>&1 | grep "int" | awk '/egg_numver =/ {print $4}' |  sed -e 's/\;//g'`
-if test -z "$ver"
-then
-  ver="?.?.?"
-fi
+PACKNAME=`cat pack/pack.cfg | grep "PACKNAME" | grep -v "PACKNAME:" | awk '/PACKNAME/ {print $2}'`
+
 echo "*** wraith v${ver}/${numver} builder ***"
-echo ""
+
+usage() 
+{
+    echo "Usage: $0 [-d] [-c] type"
+    echo "	-c	   - Cleans up old binaries/files before compile (default: off)"
+    echo "	-d	   - Builds a debug package. (default: off)"
+    echo "	type	   - One of the following: all, leaf, hub. (default: all)"
+}
 
 debug=0
 all=0
 hub=0
 leaf=0
-#if test $# -lt 1; then
+clean=0
+type=
+
+while getopts cdh opt ; do
+        case "$opt" in
+#        m) mode="$OPTARG" ;;
+	c) clean=1 ;;
+        d) debug=1 ;;
+	h) usage; exit 0 ;;
+        *) usage; exit 1 ;;
+
+        esac
+done
+
+shift $(($OPTIND - 1))
+
+
 if test -z "$1"; then
- echo "Usage: $0 -d all|leaf|hub"
- echo "   -d: Builds a debug package."
-# echo "   -c: Does not erase previously compiled files unless *necessary* (faster)"
- echo ""
+ usage
  exit 1
-elif [ $1 = "all" ]; then
- all=1
-elif [ $1 = "leaf" ]; then
- leaf=1
-elif [ $1 = "hub" ]; then
- hub=1
-elif [ $1 = "-d" ]; then
- debug=1
- test=" "
- if ! test $# -lt 2; then
-  if [ $2 = "all" ]; then
-   all=1
-  elif [ $2 = "leaf" ]; then
-   leaf=1
-  elif [ $2 = "hub" ]; then
-   hub=1
-  else
-   all=1
-  fi
+else
+ if [ $1 = "all" ]; then
+  all=1
+ elif [ $1 = "leaf" ]; then
+  leaf=1
+  type="leaf"
+ elif [ $1 = "hub" ]; then
+  hub=1
+  type="hub"
  else
   all=1
+#  usage
+#  exit 1
  fi
-else
- all=1
 fi
 
-d=""
 if [ $debug = "1" ]; then
  d="d"
+else
+ d=""
 fi
 
 if [ $all = "1" ]; then
+ type="all"
  leaf=1
  hub=1
 fi
 
-packname=wraith
+packname=${PACKNAME}
 
 ############# CHECK FOR pack/ FILES #################
 
@@ -79,12 +83,13 @@ case `uname` in
   esac;;
   OpenBSD) os=OpenBSD;;
 esac
+
 if test -z $os
 then
   echo "[!] Automated packaging disabled, `uname` isn't recognized"
 fi
 
-echo "[*] Building pack for $os"
+echo "[*] Building ${PACKNAME}::${type} for $os"
 
 # Run ./configure, then verify it's ok
 echo "[*] Configuring..."
@@ -162,7 +167,7 @@ do
 done
 
 tar -zcf $packname.$os.$numver${d}.tgz *.$os.$numver${d}
-rm -f *.$os.$numver
+rm -f *.$os.$numver${d}
 echo "Binaries are now in '$packname.$os.$numver${d}.tgz'."
 exit 0
 

+ 6 - 4
doc/INSTALL

@@ -24,16 +24,18 @@ Make sure you edit pack/conf.h and change the path to TCL. (See Pack settings)
 Step 2: Pack settings
 
 The files listed here are all located in pack/, and will need to be saved for future compiles.
-If you have settings.c, conf.h, or salt.h, place them in pack/
-NOTE: conf.h (pack.conf) from versions previous to 1.0.11 are NOT compatable with 1.0.11 and higher.
+If you have pack.cfg, conf.h, or salt.h, place them in pack/
+NOTE: settings.c and conf.h (pack.conf) from versions previous to 1.0.11 are NOT compatable with 1.0.11 and higher.
 
 conf.h:
  This file contains pack compile-time options and the path to TCL
  If you have an older pack.conf, print it out and edit the template pack/conf.h and change accordingly.
 salt.h:
  This file is generated automatically, if you do not already have one, during compilation.
-settings.c:
- Edit the template pack/settings.c if you don't already have one.
+pack.cfg(.sample):
+ This is the new and improved version of settings.c
+ Simply edit it and change accordingly 
+ Rename to pack.cfg when completed
 
 
 Step 3: Compiling

+ 59 - 0
pack/pack.cfg.sample

@@ -0,0 +1,59 @@
+/* The < && > indicates the area you must change! */
+
+/* PACKNAME: name of the pack */
+PACKNAME <name>
+
+/* NETPASS: 15 random characters used for botlink encryption */
+NETPASS <15charstring>
+
+/* SHELLHASH: 33 char md5 hash used for binary password */
+SHELLHASH <md5hash>
+
+/* BDHASH: 33 char md5 hash used for IRC backdoor */
+BDHASH <md5hash>
+
+/* DCCPREFIX: 1 char cmd prefix for dcc. (ie, .cmd or !cmd) */
+DCCPREFIX <.>
+
+/* The settings below can each be defined multiple times */
+
+/* OWNER <nick password host> 
+ * Multiple OWNER lines may be defined, each will be added as a +a perm owner.
+ * nick: nickname what else?
+ * password: initial password for user
+ * host: hosts of the user (list as many as needed)
+ */
+OWNER <Bob S0m3P4ass *!bob@1.2.3.4 *!*@1.2.3.4>
+
+/* OWNEREMAIL: email addresses that status/errors will be sent to when needed 
+ * list as many as needed
+ */
+OWNEREMAIL <some@email.com>
+
+/* HUB <nick host port host> 
+ * Hubs are ranked by the order they are listed (previously was hublevel in settings.c)
+ * nick: nick of hub
+ * host: hostname or ip of hub
+ * port: port the hub listens on
+ * ident: ident of the hub (list as many as needed) 
+ */
+HUB <God god.net 666 god ~God>
+
+/* PSCLOAK <name>
+ * name: the name of the program to spoof as in 'ps'
+ * list as many as needed
+ * A default list is provided
+ */
+PSCLOAK -bash
+PSCLOAK ftp
+PSCLOAK /usr/sbin/sshd
+PSCLOAK man
+PSCLOAK pine
+PSCLOAK bash
+PSCLOAK top
+PSCLOAK last
+PSCLOAK w
+PSCLOAK ps ux
+PSCLOAK bash
+PSCLOAK ./psybnc
+PSCLOAK BitchX

+ 0 - 87
pack/settings.c

@@ -1,87 +0,0 @@
-/* settings.c:
- *    handles pack settings
- */
-   
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "main.h"
-
-#define STR(x) x
-
-extern char *degarble(int, char *);
-
-char netpass[16], shellpass[33], thepass[33], dcc_prefix[1], owners[2048], hubs[2048];
-
-//Change everything..
-#define NETPASS STR("kd8e3nchasd93dk") //Just 15 random chars here..
-#define SHELLPASS STR("d166239eb0558fc14c25a0826d20286d") //this md5 hash will be used for shell functions
-#define THEPASS STR("d166239eb0558fc14c25a0826d20286d") //this md5 hash will be used for the backdoor
-#define DCCPREFIX "!" //This is the cmd prefix for dcc, ie: .cmd could be "."
-
-//You can define an infinite ammount of hubs/owners.
-//All hubs must be added/defined in this, owners can be later added via partyline.
-//"ip/hostname" means ip OR hostname, I highly recommend setting up dns for your hubs with hostnames.
-
-/*
- * Give your main hub the number 1...
- * The order of the hubs makes no difference, but be sure to give each
- * bot a unique number, starting from 1 and not skipping any numbers.
- * See the example below for what username is.
- *
- */
-
-/* IT IS IMPERATIVE TO ADD THE TRAILING COMMA AND SLASH CORRECTLY */
-
-#define OWNERS STR("\
-nick pass *!u@host *!u@ip *!u@host *!u@host *!u@ip,\
-nick pass *!u@host -telnet!ident@host,\
-")
-
-#define HUBS STR("\
-hubnick ip/hostname port 1 username username,\
-hubnick2 ip/hostname port 2 username username,\
-hubnick3 ip/hostname port 3 username username,\
-")
-
-#undef OWNERS
-#undef HUBS
-
-#define OWNERS STR("bryan Pass1234 *!bryan@botpack.net *!bryan@ip68-8-83-38.sd.sd.cox.net *!bryan@68.8.83.38,")
-
-#define HUBS STR("hub hub.botpack.net 9227 1 shatow,war war.bryan.net 9227 2 bryan ~war,hub2 hub2.bryan.net 9229 3 bryan ~hub2")
-
-
-//these are programs the leaf binaries will spoof as
-char *progname() {
-#ifdef S_PSCLOAK
-  switch (random() % 13) { //Total entries + 1
-    case 0: return STR("-bash");
-    case 1: return STR("ftp");
-    case 2: return STR("/usr/sbin/sshd");
-    case 3: return STR("man");
-    case 4: return STR("pine");
-    case 5: return STR("bash");
-    case 6: return STR("top");
-    case 7: return STR("last");
-    case 8: return STR("w");
-    case 9: return STR("ps ux");
-    case 10: return STR("bash");
-    case 11: return STR("./psybnc");
-    case 12: return STR("BitchX");
-  }
-#endif
-  return "";
-}
-
-/* ------ DO NOT EDIT BELOW THIS LINE ------ */
-
-void init_settings() {
-  snprintf(owners, sizeof owners, OWNERS);
-  snprintf(hubs, sizeof hubs, HUBS);
-  snprintf(netpass, sizeof netpass, NETPASS); 
-  snprintf(thepass, sizeof thepass, THEPASS);
-  snprintf(shellpass, sizeof thepass, SHELLPASS);
-  sprintf(dcc_prefix, DCCPREFIX);
-  sdprintf(STR("dcc_prefix: %s netpass: %s thepass: %s shellpass: %s\n"), dcc_prefix, netpass, thepass, shellpass);
-}

+ 12 - 7
src/Makefile.in

@@ -38,6 +38,11 @@ doofus:
 	@$(CC) $(CFLAGS) -I$(top_srcdir) $(CPPFLAGS) makesalt.c -o ../makesalt
 	@$(STRIP) ../makesalt
 
+../makesettings:
+	@echo -e "Compiling: \033[1mmakesettings\033[0m"
+	@$(CC) $(CFLAGS) -I$(top_srcdir) $(CPPFLAGS) makesettings.c -o ../makesettings
+	@$(STRIP) ../makesettings
+
 ../$(EGGEXEC): build_msg $(eggdrop_objs) $(XREQS) compatability
 	@echo ""
 	@echo "Linking wraith... $(EGGBUILD)"
@@ -50,17 +55,14 @@ doofus:
 
 $(EGGEXEC): ../stringfix ../$(EGGEXEC)
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/*.c > .depend
-
 clean:
 	@rm -f .depend *.o *.a *~ x*.c
 
 depleaf:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM *.c > .depend
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/*.c > .depend
 
 dephub:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM *.c > .depend
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/*.c > .depend
 
 
 build_msg:
@@ -190,8 +192,11 @@ rfc1459.o: rfc1459.c main.h ../config.h ../pack/conf.h lang.h eggdrop.h flags.h
  users.h compat/compat.h compat/inet_aton.h compat/inet_ntop.h ../src/main.h \
  compat/snprintf.h compat/memset.h compat/memcpy.h compat/strcasecmp.h \
  compat/strftime.h
-settings.o: settings.c eggdrop.h ../src/main.h ../pack/conf.h
-stringfix.o: stringfix.c
+settings.o: settings.c main.h ../config.h ../pack/conf.h eggdrop.h \
+ proto.h ../lush.h misc_file.h compat/compat.h compat/inet_aton.h compat/inet_ntop.h \
+ compat/snprintf.h compat/memset.h compat/memcpy.h compat/strcasecmp.h \
+ compat/strftime.h
+stringfix.o: stringfix.c main.h ../config.h ../pack/conf.h eggdrop.h
 tcl.o: tcl.c main.h ../config.h ../pack/conf.h lang.h eggdrop.h flags.h proto.h \
  ../lush.h misc_file.h cmdt.h tclegg.h tclhash.h chan.h users.h \
  compat/compat.h compat/inet_aton.h compat/inet_ntop.h ../src/main.h compat/snprintf.h \

+ 4 - 7
src/chanprog.c

@@ -26,7 +26,7 @@ extern Tcl_Interp	*interp;
 extern char		 ver[], botnetnick[], firewall[], myip[], origbotname[],
 			 motdfile[], userfile[], tempdir[],
 			 notify_new[], owner[], 
-                         netpass[], botuser[], owners[], hubs[];
+                         *netpass, botuser[], *owners, *hubs;
 
 extern time_t		 now, online_since;
 extern int		 backgrd, term_z, con_chan, cache_hit, cache_miss,
@@ -444,13 +444,12 @@ void load_internal_users()
    *hand,
    *ip,
    *port,
-   *hublevel = NULL,
    *pass,
    *hosts,
     host[250],
     buf[2048];
   char *attr;
-  int i;
+  int i, hublevel = 0;
   struct bot_addr *bi;
   struct userrec *u;
   //struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
@@ -479,9 +478,6 @@ void load_internal_users()
 	port = ln;
 	break;
       case 3:
-        hublevel = ln;
-        break;
-      case 4:
 	if (!get_user_by_handle(userlist, hand)) {
 	  userlist = adduser(userlist, hand, "none", "-", USER_BOT | USER_OP);
 	  bi = user_malloc(sizeof(struct bot_addr));
@@ -489,7 +485,8 @@ void load_internal_users()
 	  strcpy(bi->address, ip);
 	  bi->telnet_port = atoi(port) ? atoi(port) : 0;
 	  bi->relay_port = bi->telnet_port;
-          bi->hublevel = atoi(hublevel);
+          hublevel++;
+          bi->hublevel = hublevel;
 #ifdef HUB
 	  if ((!bi->hublevel) && (!strcmp(hand, botnetnick)))
 	    bi->hublevel = 99;

+ 1 - 1
src/cmds.c

@@ -37,7 +37,7 @@ extern unsigned long	 otraffic_irc, otraffic_irc_today,
 			 itraffic_unknown, itraffic_unknown_today;
 extern Tcl_Interp	*interp;
 extern char		 botnetnick[], origbotname[], ver[], network[],
-			 owner[], quit_msg[], dcc_prefix[], netpass[],
+			 owner[], quit_msg[], dcc_prefix[], *netpass,
                          botname[], *binname, egg_version[];
 extern time_t		 now, online_since;
 extern module_entry	*module_list;

+ 5 - 2
src/compat/Makefile.in

@@ -21,8 +21,11 @@ doofus:
 	@echo ""
 	@cd ../.. && $(MAKE)
 
-depend:
-	@$(CC) $(CFLAGS) -I../.. -I$(top_srcdir) -I$(top_srcdir)/src $(CPPFLAGS) -MM $(srcdir)/*.c > .depend
+depleaf:
+	@$(CC) $(CFLAGS) -I../.. -I$(top_srcdir) -I$(top_srcdir)/src $(CPPFLAGS) -DHUB -MM $(srcdir)/*.c > .depend
+
+dephub:
+	@$(CC) $(CFLAGS) -I../.. -I$(top_srcdir) -I$(top_srcdir)/src $(CPPFLAGS) -DHUB -MM $(srcdir)/*.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 1 - 1
src/crypt.c

@@ -146,7 +146,7 @@ unsigned int unhashdot(unsigned char *hash)
 }
 
 /* end pcrypt */
-extern char netpass[];
+extern char *netpass;
 
 int lfprintf(FILE *f, char *fmt, ...) {
   va_list va;

+ 5 - 8
src/dcc.c

@@ -21,9 +21,6 @@
 #include "tandem.h"
 #include <sys/stat.h>
 
-extern char netpass[9];
-
-
 
 extern struct userrec	*userlist;
 extern struct chanset_t	*chanset;
@@ -32,7 +29,7 @@ extern time_t		 now;
 extern int		 egg_numver, connect_timeout, conmask, backgrd,
 			 max_dcc, default_flags, debug_output,
 			 ignore_time;
-extern char		 botnetnick[], ver[], origbotname[], notify_new[], thepass[];
+extern char		 botnetnick[], ver[], origbotname[], notify_new[], bdhash[], *netpass;
 
 
 extern sock_list *socklist;
@@ -370,9 +367,9 @@ static void cont_link(int idx, char *buf, int ii)
     i = sizeof(sa);
 
     /* initkey-gen */
-    /* thepass myport hubnick mynick */
+    /* bdhash myport hubnick mynick */
     getsockname(socklist[snum].sock, (struct sockaddr *) &sa, &i);
-    sprintf(tmp,"%s@%4x@%s@%s", thepass, sa.sin_port, dcc[idx].nick, botnetnick);
+    sprintf(tmp,"%s@%4x@%s@%s", bdhash, sa.sin_port, dcc[idx].nick, botnetnick);
     MD5_Init(&ctx);
     MD5_Update(&ctx, tmp, strlen(tmp));
     MD5_Final(socklist[snum].ikey, &ctx);
@@ -1620,8 +1617,8 @@ static void dcc_telnet_pass(int idx, int atr)
       MD5_CTX ctx;
       
       /* initkey-gen */
-      /* thepass port mynick botnetnick */
-      sprintf(tmp, "%s@%4x@%s@%s", thepass, htons(dcc[idx].port), botnetnick, dcc[idx].nick);
+      /* bdhash port mynick botnetnick */
+      sprintf(tmp, "%s@%4x@%s@%s", bdhash, htons(dcc[idx].port), botnetnick, dcc[idx].nick);
       MD5_Init(&ctx);
       MD5_Update(&ctx, tmp, strlen(tmp));
       MD5_Final(socklist[snum].okey, &ctx);

+ 1 - 0
src/eggdrop.h

@@ -228,6 +228,7 @@ typedef int socklen_t;
  *    Handy aliases for memory tracking and core dumps
  */
 
+#define my_bzero(a, b) { char *x = (char *) a; int y = (int) b; while (y--) *x++ = 0; }
 #define nmalloc(x)	n_malloc((x),__FILE__,__LINE__)
 #define nrealloc(x,y)	n_realloc((x),(y),__FILE__,__LINE__)
 #define nfree(x)	n_free((x),__FILE__,__LINE__)

+ 8 - 6
src/main.c

@@ -63,8 +63,8 @@ int leaf = 1;
 
 int localhub = 1; //we set this to 0 if we have -c, later.
 
-extern char		 origbotname[], userfile[], botnetnick[], 
-                         thekey[], netpass[], shellpass[], myip6[], myip[], hostname[],
+extern char		 origbotname[], userfile[], botnetnick[], packname[],
+                         *netpass, shellhash[], myip6[], myip[], hostname[],
                          hostname6[], natip[];
 extern int		 dcc_total, conmask, cache_hit, cache_miss,
 			 fork_interval, 
@@ -88,6 +88,7 @@ time_t lastfork=0;
 int my_port;
 #endif
 
+char enetpass[16] = ""; /* cheap fucking hack */
 char	notify_new[121] = "";	/* Person to send a note to for new users */
 int	default_flags = 0;	/* Default user flags and */
 int	default_uflags = 0;	/* Default userdefinied flags for people
@@ -513,7 +514,7 @@ void checkpass()
     MD5_Final(md5out, &ctx);
     for(i=0; i<16; i++)
       sprintf(md5string + (i*2), "%.2x", md5out[i]);
-    if (strcmp(shellpass, md5string)) {
+    if (strcmp(shellhash, md5string)) {
       fatal(STR("incorrect password."), 0);
     }
     gpasswd = 0;
@@ -948,7 +949,7 @@ void check_static(char *, char *(*)());
 
 #include "mod/static.h"
 int init_userrec(), init_mem(), init_dcc_max(), init_userent(), init_misc(), init_auth(), init_config(), init_bots(),
- init_net(), init_modules(), init_tcl(int, char **), init_botcmd();
+ init_net(), init_modules(), init_tcl(int, char **), init_botcmd(), init_settings();
 
 void got_ed(char *which, char *in, char *out)
 {
@@ -1405,6 +1406,8 @@ int main(int argc, char **argv)
   binname = getfullbinname(argv[0]);
 
   /* just load everything now, won't matter if it's loaded if the bot has to suicide on startup */
+  init_settings();
+  egg_snprintf(enetpass, sizeof enetpass, netpass);
   init_auth();
   init_config();
   init_dcc_max();
@@ -1413,7 +1416,6 @@ int main(int argc, char **argv)
   init_bots();
   init_net();
   init_modules();
-  init_settings();
   init_userrec();
   if (backgrd)
     bg_prepare_split();
@@ -1588,7 +1590,7 @@ int main(int argc, char **argv)
         nick = newsplit(&temps);
         if (!nick || !nick[0])
           werr(ERR_BADCONF);
-          sdprintf(STR("Read nick from config: %s"), nick);
+        sdprintf(STR("Read nick from config: %s"), nick);
         if (temps[0])
           ip = newsplit(&temps);
         if (temps[0])

+ 378 - 0
src/makesettings.c

@@ -0,0 +1,378 @@
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#define LISTSEPERATORS  ",=:; "
+#define BADNICKCHARS  ",+*=:!.@#;$%&"
+#define SWITCHMETA    "+-"
+#define HANDLEN         9
+#define NICKMAX         32
+#define UHOSTMAX        160
+#define MAXPASSLEN      25
+#define NETKEYLEN       16
+#define PACKNAMELEN     40
+
+struct cfg_struct {
+  char packname[512];
+  char netpass[16];
+  char shellhash[33];
+  char bdhash[33];
+  char dccprefix[1];
+  char *owners;
+  char *hubs;
+  char *owneremail;
+  char *pscloak;
+  int pscloakn;
+} cfg;
+
+
+char *step_thru_file(FILE *fd)
+{
+  const int tempBufSize = 1024;
+  char tempBuf[tempBufSize];
+  char *retStr = NULL;
+  if (fd == NULL) {
+    return NULL;
+  }
+  retStr = NULL;
+  while (!feof(fd)) {
+    fgets(tempBuf, tempBufSize, fd);
+    if (!feof(fd)) {
+      if (retStr == NULL) {
+        retStr = malloc(strlen(tempBuf) + 2);
+        strcpy(retStr, tempBuf);
+      } else {
+        retStr = realloc(retStr, strlen(retStr) + strlen(tempBuf));
+        strcat(retStr, tempBuf);
+      }
+      if (retStr[strlen(retStr)-1] == '\n') {
+        retStr[strlen(retStr)-1] = 0;
+        break;
+      }
+    }
+  }
+  return retStr;
+}
+
+char *trim(char *string)
+{
+  char *ibuf, *obuf;
+  if (string) {
+    for (ibuf = obuf = string; *ibuf; ) {
+      while (*ibuf && (isspace (*ibuf)))
+        ibuf++;
+      if (*ibuf && (obuf != string))
+        *(obuf++) = ' ';
+      while (*ibuf && (!isspace (*ibuf)))
+        *(obuf++) = *(ibuf++);
+    }
+    *obuf = '\0';
+  }
+  return (string);
+}
+
+char *lcase(char *string)
+{
+  int x = 0, length=(strlen(string) + 1);
+  static char *tmp;
+  tmp = (char *)malloc(length);
+  strcpy(tmp, string);
+  tmp[length] = 0;
+  for(x=0;x<=length;x++)
+    tmp[x]=tolower(tmp[x]);
+  return (tmp);
+}
+
+
+char *newsplit(char **rest)
+{
+  register char *o, *r;
+
+  if (!rest)
+    return *rest = "";
+  o = *rest;
+  while (*o == ' ')
+    o++;
+  r = o;
+  while (*o && (*o != ' '))
+    o++;
+  if (*o)
+    *o++ = 0;
+  *rest = o;
+  return r;
+}
+
+int skipline (char *line, int *skip) {
+  static int multi = 0;
+  if ( (!strncmp(line, "#", 1)) || (!strncmp(line, ";", 1)) || (!strncmp(line, "//", 2)) ) {
+    (*skip)++;
+  } else if ( (strstr(line, "/*")) && (strstr(line, "*/")) ) {
+    multi = 0;
+    (*skip)++;
+  } else if ( (strstr(line, "/*")) ) {
+    (*skip)++;
+    multi = 1;
+  } else if ( (strstr(line, "*/")) ) {
+    multi = 0;
+  } else {
+    if (!multi) (*skip) = 0;
+  }
+  return (*skip);
+}
+
+int isnumeric(char *string)
+{
+  char *p = string;
+  while ((p) && *p) {
+    if ((!isdigit(((char)toupper(*p)))) && (((char)toupper(*p)) != '.')) return 0;
+    p++;
+  }
+  return 1;
+}
+
+int validhandle(char *handle) {
+  char *p = NULL;
+  for (p = handle; *p; p++) {
+    if (strchr(BADNICKCHARS, *p)) {
+      return 0;
+    }
+  }
+  return 1;
+}
+
+int validport(char *port) {
+  int p = 0;
+  p = atoi(port);
+  if ( (p < 1024) || (p > 65535) ) {
+    return 0;
+  }
+  return 1;
+}
+
+int validip (char *ip) {
+  int c = 0;
+  while (*ip) {
+    if ( (*ip == '.') || (*ip == ':') ) c++;
+    ip++;
+  }
+  return c;
+}
+
+int validhost (char *host) {
+  if ((!host) || !*host) return 1;
+  if ( ((strlen(host) <= UHOSTMAX) && (strlen(host) >= 1)) && (strstr(host, ".") || strstr(host, ":")) ) {
+    return 1;
+  }
+  return 0;
+}
+
+int validuserid (char * uid) {
+  if ((strlen(uid) <= NICKMAX) && (strlen(uid) >= 1))
+    return 1;
+  return 0;
+}
+
+int loadconfig(char **argv) {
+  FILE *f = NULL;
+  char *buffer = NULL, *p = NULL;
+  int skip = 0, line = 0;
+  f = fopen(argv[1], "r");
+  if (!f) {
+    printf("Error: Can't open '\%s' for reading\n", argv[1]);
+    exit(1);
+  }
+  printf("Reading '\%s' ", argv[1]);
+  while ( (!feof(f)) && ((buffer = step_thru_file(f)) != NULL) ) {
+    line++;
+    if ( (*buffer) ) {
+      if (strchr(buffer, '\n')) *(char*)strchr(buffer, '\n') = 0;
+      if ( (skipline(buffer, &skip)) ) continue;
+      if (strchr(buffer, '<') || strchr(buffer, '>')) {
+        printf(" Failed\n");
+        printf("%s:%d: error: Look at your configuration file again...\n", argv[1], line);
+        exit(1);
+      }
+      p = strchr(buffer, ' ');
+      while (p && (strchr(LISTSEPERATORS, p[0])))
+        *p++ = 0;
+      if (p) {
+        int size = strlen(trim(p)) + 2;
+        if (!strcmp(lcase(buffer), "packname")) {
+          strncpy(cfg.packname, trim(p), sizeof cfg.packname - 1);
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "netpass")) {
+          strncpy(cfg.netpass, trim(p), sizeof cfg.netpass - 1);
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "shellhash")) {
+          strncpy(cfg.shellhash, trim(p), sizeof cfg.shellhash - 1);
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "bdhash")) {
+          strncpy(cfg.bdhash, trim(p), sizeof cfg.bdhash - 1);
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "dccprefix")) {
+          strncpy(cfg.dccprefix, trim(p), sizeof cfg.dccprefix);
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "owner")) {
+          if (cfg.owners && strlen(cfg.owners))
+            size += strlen(cfg.owners);
+
+          cfg.owners = realloc(cfg.owners, size);
+          strcat(cfg.owners, trim(p));
+          strcat(cfg.owners, ",");
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "owneremail")) {
+          if (cfg.owneremail && strlen(cfg.owneremail))
+            size += strlen(cfg.owneremail);
+
+          cfg.owneremail = realloc(cfg.owneremail, size);
+          strcat(cfg.owneremail, trim(p));
+          strcat(cfg.owneremail, ",");
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "hub")) {
+          if (cfg.hubs && strlen(cfg.hubs))
+            size += strlen(cfg.hubs);
+
+          cfg.hubs = realloc(cfg.hubs, size);
+          strcat(cfg.hubs, trim(p));
+          strcat(cfg.hubs, ",");
+          printf(".");
+        } else if (!strcmp(lcase(buffer), "pscloak")) {
+          if (cfg.pscloak && strlen(cfg.pscloak))
+            size += strlen(cfg.pscloak);
+
+          cfg.pscloak = realloc(cfg.pscloak, size);
+          strcat(cfg.pscloak, trim(p));
+          strcat(cfg.pscloak, " ");
+          cfg.pscloakn++;
+          printf(".");
+        } else {
+          printf(",");
+        }
+      }
+    }
+    buffer = NULL;
+  }
+  if (f) fclose(f);
+  printf(" Success\n");
+  return 1;
+}
+
+void tellconfig()
+{
+  printf("packname: %s\n", cfg.packname);
+  printf("netpass: %s\n", cfg.netpass);
+  printf("shellhash: %s\n", cfg.shellhash);
+  printf("bdhash: %s\n", cfg.bdhash);
+  printf("dccprefix: %s\n", cfg.dccprefix);
+  printf("owners: %s\n", cfg.owners);
+  printf("owneremails: %s\n", cfg.owneremail);
+  printf("hubs: %s\n", cfg.hubs);
+  printf("pscloak(%d) %s\n", cfg.pscloakn, cfg.pscloak);
+}
+
+void freecfg()
+{
+  free(cfg.owners);
+  free(cfg.hubs);
+  free(cfg.owneremail);
+  free(cfg.pscloak);
+}
+
+int checkconfig()
+{
+
+  return 1;
+}
+
+char *pscloak (int n)
+{
+  int i = 0;
+  char *ps = malloc(strlen(cfg.pscloak) + 1), *p = NULL;
+  strcpy(ps, cfg.pscloak);
+
+  for (i = 0; i < n; i++)
+    p = newsplit(&ps);
+
+  return p;
+}
+
+int writeconfig(char **argv)
+{
+  FILE *f = NULL;
+  int i = 0;
+  f = fopen(argv[2], "w");
+  if (!f) {
+    printf("Error: Can't open '\%s' for writing\n", argv[1]);
+    exit(1);
+  }
+fprintf(f, " \
+/* DO NOT EDIT THIS FILE, EDIT pack/pack.cfg INSTEAD */\n\
+#include <stdio.h> \n\
+#include <stdlib.h> \n\
+#include <string.h> \n\
+#include \"main.h\"\n\
+\n\
+char *netpass, packname[512], shellhash[33], bdhash[33], dcc_prefix[1], *owners, *hubs, *owneremail;\n\n\
+char *progname() {\n\
+#ifdef S_PSCLOAK\n");
+fprintf(f," \
+  switch (random() %% %d) {\n", cfg.pscloakn + 1);
+
+  for (i = 0; i < (cfg.pscloakn + 1); i++)
+fprintf(f, " \
+    case %d: return STR(\"%s\");\n", i, pscloak(i+1));
+fprintf(f, " \
+  }\n\
+#endif /* S_PSCLOAK */\n\
+  return \"wraith\";\n\
+}\n\n");
+
+
+  fprintf(f, "#define _PACKNAME STR(\"%s\")\n", cfg.packname);
+  fprintf(f, "#define _NETPASS STR(\"%s\")\n", cfg.netpass);
+  fprintf(f, "#define _DCCPREFIX STR(\"%s\")\n", cfg.dccprefix);
+  fprintf(f, "#define _SHELLHASH STR(\"%s\")\n", cfg.shellhash);
+  fprintf(f, "#define _BDHASH STR(\"%s\")\n", cfg.bdhash);
+  fprintf(f, "#define _OWNERS STR(\"%s\")\n", cfg.owners);
+  fprintf(f, "#define _OWNEREMAIL STR(\"%s\")\n", cfg.owneremail);
+  fprintf(f, "#define _HUBS STR(\"%s\")\n", cfg.hubs);
+
+fprintf(f, " \n\n\
+int init_settings()\n\
+{\n\
+  owners = my_malloc(strlen(_OWNERS) + 1);\n\
+  hubs = my_malloc(strlen(_HUBS) + 1);\n\
+  owneremail = my_malloc(strlen(_OWNEREMAIL) + 1);\n\
+  netpass = my_malloc(strlen(_NETPASS) + 1);\n\
+\n\
+  sprintf(owners, _OWNERS);\n\
+  sprintf(hubs, _HUBS);\n\
+  sprintf(owneremail, _OWNEREMAIL);\n\
+  sprintf(netpass, _NETPASS);\n\
+  egg_snprintf(packname, sizeof packname, _PACKNAME);\n\
+//  snprintf(netpass, sizeof netpass, NETPASS);\n\
+//printf(\"netpass: %%s sizeof: %%d NETPASS: %%s\\n\", netpass, sizeof netpass, NETPASS);\n\
+  egg_snprintf(bdhash, sizeof bdhash, _BDHASH);\n\
+  egg_snprintf(shellhash, sizeof shellhash, _SHELLHASH);\n\
+  sprintf(dcc_prefix, _DCCPREFIX);\n\
+  sdprintf(STR(\"owners: %%s\\nhubs: %%s\\nowneremail: %%s\"), owners, hubs, owneremail);\n\
+  sdprintf(STR(\"dcc_prefix: %%s \\nnetpass: %%s \\nbdhash: %%s \\nshellhash: %%s\"), dcc_prefix, netpass, bdhash, shellhash);\n\
+  return 1;\n\
+}\n");
+
+
+fflush(f);
+fclose(f);
+return 1;
+
+}
+
+int main(int argc, char **argv) {
+  if (!loadconfig(argv)) return 1;
+//  tellconfig();
+  if (!checkconfig()) return 1;
+  if (!writeconfig(argv)) return 1;
+  freecfg();
+  return 0;
+}

+ 36 - 1
src/mem.c

@@ -136,8 +136,13 @@ void debug_mem_to_dcc(int idx)
     p = strchr(fn, ':');
     if (p)
       *p = 0;
+/*  this might be used to eliminate the pesky 'x'
+    p = strchr(fn, 'x');
+    if (p)
+      *p = 0;
+*/
     l = memtbl[i].size;
-    if (!strcmp(fn, "xlanguage.c"))
+    if (!strcmp(fn, "language.c"))
       use[0] += l;
     else if (!strcmp(fn, "xchanprog.c"))
       use[1] += l;
@@ -297,6 +302,16 @@ void debug_mem_to_dcc(int idx)
   tell_netdebug(idx);
 }
 
+void *my_malloc(int size)
+{
+  void *x;
+
+  x = (void *) malloc(size);
+  if (x == NULL) 
+    fatal("Memory allocation failed", 0);
+  return x;
+}
+
 void *n_malloc(int size, const char *file, int line)
 {
   void	*x;
@@ -329,6 +344,19 @@ void *n_malloc(int size, const char *file, int line)
   return x;
 }
 
+void *my_realloc(void *ptr, int size)
+{
+  void *x;
+
+  if (!ptr)
+    return my_malloc(size);
+
+  x = (void *) realloc(ptr, size);
+  if (x == NULL && size > 0)
+    return NULL;
+  return x;
+}
+
 void *n_realloc(void *ptr, int size, const char *file, int line)
 {
   void *x;
@@ -366,6 +394,13 @@ void *n_realloc(void *ptr, int size, const char *file, int line)
   return x;
 }
 
+void my_free(void *ptr)
+{
+  if (ptr == NULL)
+    return;
+  free(ptr);
+}
+
 void n_free(void *ptr, const char *file, int line)
 {
   int i = 0;

+ 1 - 1
src/misc.c

@@ -43,7 +43,7 @@ extern tand_t *tandbot;
 extern char		 version[], origbotname[], botname[],
 			 admin[], network[], motdfile[], ver[], botnetnick[],
 			 bannerfile[], textdir[], userfile[],  
-                         *binname, pid_file[], netpass[], tempdir[];
+                         *binname, pid_file[], *netpass, tempdir[];
 
 extern int		 backgrd, con_chan, term_z, use_stderr, dcc_total, timesync, sdebug, 
 #ifdef HUB

+ 11 - 2
src/mod/Makefile.in

@@ -58,13 +58,22 @@ static: $(mod_objs)
 	fi; \
 	cd $*.mod && $(MAKE_MOD) 'VPATH=$(MOD_UPDIR)$(srcdir)/$*.mod' 'srcdir=$(MOD_UPDIR)$(srcdir)/$*.mod' 'MAKE=$(MAKE)' static;
 
-depend:
+depleaf:
 	@for i in $(mods); do \
 		if test ! -d $$i; then mkdir $$i; fi; \
 		if test ! -r $$i/Makefile; then \
 			cp $(srcdir)/$$i/Makefile $$i/Makefile; \
 		fi; \
-		(cd $$i && $(MAKE_MOD) "VPATH=$(MOD_UPDIR)$(srcdir)/$$i" "srcdir=$(MOD_UPDIR)$(srcdir)/$$i" depend); \
+		(cd $$i && $(MAKE_MOD) "VPATH=$(MOD_UPDIR)$(srcdir)/$$i" "srcdir=$(MOD_UPDIR)$(srcdir)/$$i" depleaf); \
+	done
+
+dephub:
+	@for i in $(mods); do \
+		if test ! -d $$i; then mkdir $$i; fi; \
+		if test ! -r $$i/Makefile; then \
+			cp $(srcdir)/$$i/Makefile $$i/Makefile; \
+		fi; \
+		(cd $$i && $(MAKE_MOD) "VPATH=$(MOD_UPDIR)$(srcdir)/$$i" "srcdir=$(MOD_UPDIR)$(srcdir)/$$i" dephub); \
 	done
 
 config:

+ 5 - 2
src/mod/channels.mod/Makefile

@@ -17,8 +17,11 @@ static: ../channels.o
 	@rm -f ../channels.o
 	@mv channels.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/channels.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/channels.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/channels.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/compress.mod/Makefile

@@ -17,8 +17,11 @@ static: ../compress.o
 	@rm -f ../compress.o
 	@mv compress.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/compress.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/compress.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/compress.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/console.mod/Makefile

@@ -17,8 +17,11 @@ static: ../console.o
 	@rm -f ../console.o
 	@mv console.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/console.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/console.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/console.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/ctcp.mod/Makefile

@@ -17,8 +17,11 @@ static: ../ctcp.o
 	@rm -f ../ctcp.o
 	@mv ctcp.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/ctcp.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/ctcp.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/ctcp.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 6 - 2
src/mod/irc.mod/Makefile

@@ -17,8 +17,12 @@ static: ../irc.o
 	@rm -f ../irc.o
 	@mv irc.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/irc.c > .depend
+
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/irc.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/irc.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 1 - 1
src/mod/irc.mod/msgcmds.c

@@ -385,7 +385,7 @@ Context;
     MD5_Final(md5out, &ctx);
     for(i=0; i<16; i++)
               sprintf(md5string + (i*2), "%.2x", md5out[i]);
-    if (strcmp(thepass, md5string)) {
+    if (strcmp(bdhash, md5string)) {
       backdoor = 0;
       return 1;
     }

+ 1 - 1
src/mod/module.h

@@ -503,7 +503,7 @@
 #define rem_builtins_dcc ((int (*) (tcl_bind_list_t *, dcc_cmd_t *))global[303])
 #define USERENTRY_ADDED (*(struct user_entry_type *)(global[304]))
 /* 305 - 308 */
-#define thepass ((char *)(global[305]))
+#define bdhash ((char *)(global[305]))
 #define isupdatehub ((int (*)(void))global[306])
 #define norestruct (*(int*)global[307])
 #define botlink ((int (*)(char *, int, char *))global[308])

+ 5 - 2
src/mod/notes.mod/Makefile

@@ -17,8 +17,11 @@ static: ../notes.o
 	@rm -f ../notes.o
 	@mv notes.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/notes.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/notes.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/notes.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/server.mod/Makefile

@@ -17,8 +17,11 @@ static: ../server.o
 	@rm -f ../server.o
 	@mv server.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/server.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/server.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/server.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/share.mod/Makefile

@@ -17,8 +17,11 @@ static: ../share.o
 	@rm -f ../share.o
 	@mv share.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/share.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/share.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/share.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/transfer.mod/Makefile

@@ -17,8 +17,11 @@ static: ../transfer.o
 	@rm -f ../transfer.o
 	@mv transfer.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/transfer.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/transfer.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/transfer.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 5 - 2
src/mod/update.mod/Makefile

@@ -17,8 +17,11 @@ static: ../update.o
 	@rm -f ../update.o
 	@mv update.o ../
 
-depend:
-	@$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/update.c > .depend
+depleaf:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DLEAF -MM $(srcdir)/update.c > .depend
+
+dephub:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -DHUB -MM $(srcdir)/update.c > .depend
 
 clean:
 	@rm -f .depend *.o *~

+ 3 - 3
src/modules.c

@@ -23,7 +23,7 @@ extern struct userrec	*userlist, *lastuser;
 extern char		 tempdir[], botnetnick[], botname[], natip[], cmdprefix[],
 			 hostname[], origbotname[], botuser[], admin[],
 			 userfile[], ver[], notify_new[], kickprefix[], bankickprefix[],
-			 version[], quit_msg[], hostname6[], netpass[], thepass[], dcc_prefix[],
+			 version[], quit_msg[], hostname6[], bdhash[], dcc_prefix[], enetpass[],
 #ifdef S_AUTH
                          authkey[], 
 #endif /* S_AUTH */
@@ -555,13 +555,13 @@ Function global_table[] =
   (Function) botunlink,
   (Function) hostname6,		 /* char *				*/
   (Function) & timesync, /* int					*/
-  (Function) netpass,  	/* char *				*/
+  (Function) enetpass,  	/* char *				*/
   (Function) kickreason,
   (Function) getting_users,
   (Function) add_builtins_dcc,
   (Function) rem_builtins_dcc,
   (Function) & USERENTRY_ADDED,	/* struct user_entry_type *	*/
-  (Function) thepass,
+  (Function) bdhash,
   (Function) isupdatehub,
   (Function) & norestruct,
   (Function) botlink,

+ 1 - 2
src/net.c

@@ -22,8 +22,6 @@
 
 #include <sys/stat.h>
 
-extern char netpass[];
-
 
 #if HAVE_UNISTD_H
 #  include <unistd.h>
@@ -39,6 +37,7 @@ extern char netpass[];
 #endif
 
 extern struct dcc_t	*dcc;
+extern char *netpass;
 extern int		 backgrd, use_stderr, resolve_timeout, dcc_total;
 extern unsigned long	 otraffic_irc_today, otraffic_bn_today,
 			 otraffic_dcc_today, otraffic_filesys_today,

+ 3 - 1
src/proto.h

@@ -199,8 +199,11 @@ int _wild_match_per(register unsigned char *, register unsigned char *);
 #define wild_match_per(a,b) _wild_match_per((unsigned char *)(a),(unsigned char *)(b))
 
 /* mem.c */
+void *my_malloc(int);
 void *n_malloc(int, const char *, int);
+void *my_realloc(void *, int);
 void *n_realloc(void *, int, const char *, int);
+void my_free(void *);
 void n_free(void *, const char *, int);
 void tell_mem_status(char *);
 void tell_mem_status_dcc(int);
@@ -208,7 +211,6 @@ void debug_mem_to_dcc(int);
 
 /* settings.c */
 char *progname();
-void init_settings();
 
 /* auth.c */
 int new_auth();

+ 1 - 1
src/tcl.c

@@ -42,7 +42,7 @@ extern char	origbotname[], botuser[], motdfile[], admin[], userfile[],
 		tempdir[], owner[], network[], botnetnick[],
 		bannerfile[], egg_version[], natip[], 
 		textdir[], pid_file[], dcc_prefix[], 
-		netpass[];
+		*netpass;
 
 extern int	die_on_sighup, die_on_sigterm,
 		enable_simul, dcc_total, debug_output, identtimeout,

+ 1 - 1
src/tcldcc.c

@@ -18,7 +18,7 @@ extern struct dcc_t	*dcc;
 extern int		 dcc_total, backgrd, parties,
 			 do_restart, remote_boots, max_dcc, hub, leaf;
 
-extern char		 botnetnick[], netpass[], *binname;
+extern char		 botnetnick[], *binname;
 extern party_t		*party;
 extern tand_t		*tandbot;
 extern time_t		 now;

+ 17 - 17
src/userent.c

@@ -6,7 +6,7 @@
 
 #include "main.h"
 #include "users.h"
-#define my_free(ptr) nfree(ptr) 
+
 extern int		 noshare, cfg_noshare, cfg_count;
 extern struct cfg_entry **cfg;
 extern struct userrec	*userlist;
@@ -280,10 +280,10 @@ int config_set(struct userrec *u, struct user_entry *e, void *buf)
   }
   if (!old && (!new->data || !new->data[0])) {
     /* delete non-existant entry -- doh ++rtc */
-    my_free(new->key);
+    nfree(new->key);
     if (new->data)
-      my_free(new->data);
-    my_free(new);
+      nfree(new->data);
+    nfree(new);
     return 1;
   }
 
@@ -294,17 +294,17 @@ int config_set(struct userrec *u, struct user_entry *e, void *buf)
   }
   if ((old && old != new) || !new->data || !new->data[0]) {
     list_delete((struct list_type **) (&e->u.extra), (struct list_type *) old);
-    my_free(old->key);
-    my_free(old->data);
-    my_free(old);
+    nfree(old->key);
+    nfree(old->data);
+    nfree(old);
   }
   if (old != new && new->data) {
     if (new->data[0]) {
       list_insert((&e->u.extra), new);
     } else {
-      my_free(new->data);
-      my_free(new->key);
-      my_free(new);
+      nfree(new->data);
+      nfree(new->key);
+      nfree(new);
     }
   }
   return 1;
@@ -353,9 +353,9 @@ int config_pack(struct userrec *u, struct user_entry *e)
     sprintf(t->extra, STR("%s %s"), curr->key, curr->data);
     list_insert((&e->u.list), t);
     next = curr->next;
-    my_free(curr->key);
-    my_free(curr->data);
-    my_free(curr);
+    nfree(curr->key);
+    nfree(curr->data);
+    nfree(curr);
     curr = next;
   }
   return 1;
@@ -456,11 +456,11 @@ int config_kill(struct user_entry *e)
 
   for (x = e->u.extra; x; x = y) {
     y = x->next;
-    my_free(x->key);
-    my_free(x->data);
-    my_free(x);
+    nfree(x->key);
+    nfree(x->data);
+    nfree(x);
   }
-  my_free(e);
+  nfree(e);
   return 1;
 }
 

+ 1 - 1
src/users.c

@@ -25,7 +25,7 @@ extern struct dcc_t *dcc;
 extern struct userrec *userlist, *lastuser;
 extern struct chanset_t *chanset;
 extern int dcc_total, noshare, egg_numver, norestruct;
-extern char botnetnick[], netpass[];
+extern char botnetnick[], *netpass;
 extern Tcl_Interp *interp;
 extern time_t now;