Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Tue, 2 Jan 2001 21:47:31 +0000 (21:47 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Tue, 2 Jan 2001 21:47:31 +0000 (21:47 +0000)
Log message:

Some efficiency enhancements in m_motd.c; a new way to set the PRNG's seed
and some randomness enhancements (feedback); featurization of many compile-
time options; a new feature flag to inhibit all display of something, like,
say, the random seed.

Testing:

Compiles, no warnings; runs without apparent problems.  Please brute-force
it to see if any of the features can be broken.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@353 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

22 files changed:
ChangeLog
config/config-sh.in
include/channel.h
include/ircd_features.h
include/motd.h
include/random.h
include/supported.h
ircd/Makefile.in
ircd/channel.c
ircd/chkconf.c
ircd/class.c
ircd/client.c
ircd/ircd.c
ircd/ircd_features.c
ircd/m_join.c
ircd/m_version.c
ircd/motd.c
ircd/random.c
ircd/s_auth.c
ircd/s_bsd.c
ircd/s_debug.c
ircd/s_user.c

index e9007aad75edf4e87e5d17f0bc79ac1dbab1a15a..2429d94b47605f4476a35eb1c3d1c1d467692a7b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,68 @@
+2001-01-02  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/s_user.c: retrieve MAXSILES and MAXSILELENGTH (now
+       AVBANLEN*MAXSILES) from features subsystem
+
+       * ircd/s_debug.c (debug_serveropts): CMDLINE_CONFIG doesn't go to
+       anything anymore
+
+       * ircd/s_bsd.c: retrieve HANGONGOODLINK and HANGONRETRYDELAY from
+       the features subsystem
+
+       * ircd/s_auth.c (start_auth): NODNS migrated to the features
+       subsystem
+
+       * ircd/random.c: created random_seed_set() function to set seed
+       value, along with some stuff to make ircrandom() a little more
+       random--state preserving, xor of time instead of direct usage,
+       etc.; it's still a pseudo-random number generator, though, and
+       hopefully I haven't broken the randomness
+
+       * ircd/m_version.c: FEATUREVALUES makes use of feature_int() calls
+
+       * ircd/m_join.c: use features interface to retrieve
+       MAXCHANNELSPERUSER
+
+       * ircd/ircd_features.c: add NODISP flag for super-secret features;
+       add a whole bunch of new features migrated over from make config
+
+       * ircd/ircd.c: use features interface to retrieve PINGFREQUENCY,
+       CONNECTTIMEOUT, and TIMESEC
+
+       * ircd/client.c (client_get_ping): use features interface to
+       retrieve PINGFREQUENCY
+
+       * ircd/class.c: use features interface to retrieve PINGFREQUENCY,
+       CONNECTFREQUENCY, MAXIMUM_LINKS, and DEFAULTMAXSENDQLENGTH
+
+       * ircd/chkconf.c (DEFAULTMAXSENDQLENGTH): since it's now in the
+       features subsystem, we have to add something explicit
+
+       * ircd/channel.c: use features interface to retrieve
+       KILLCHASETIMELIMIT, MAXBANLENGTH, MAXBANS, and MAXCHANNELSPERUSER;
+       note that MAXBANLENGTH is now calculated dynamically from MAXBANS
+       and AVBANLEN
+
+       * ircd/Makefile.in: run make depend
+
+       * include/supported.h (FEATURESVALUES): update to reference
+       feature settings
+
+       * include/random.h: add prototype for random_seed_set
+
+       * include/ircd_features.h: add several more features
+
+       * include/channel.h: move MAXBANS and MAXBANLENGTH into feature
+       subsystem
+
+       * config/config-sh.in: feature-ized some more stuff
+
+       * include/motd.h: some new elements in motd.h for motd.c changes
+
+       * ircd/motd.c: motd_cache() now searches a list of already cached
+       MOTD files; saves us from having duplicate caches in memory if
+       there are two identical T-lines for two different sites...
+
 2001-01-02  Perry Lorier <isomer@coders.net>
        * ircd/motd.c: don't core if the motd isn't found.  Bug found by
        Amarande.
index f5661c20b3285cca2c358b560a17fe155496a2d3..405741a71964c18394721937573c522ec61b6225 100644 (file)
@@ -69,7 +69,6 @@ comment 'Debugging (do not define this on production servers)'
       EXTRA_CPPFLAGS="-DNDEBUG $EXTRA_CPPFLAGS"
     fi
   fi
-  bool 'Are you testing on a host without DNS' NODNS
 endmenu
 
 mainmenu_option next_comment
@@ -178,8 +177,6 @@ comment 'Host specific defines'
     DOMAINNAME_DEFAULT=none
   fi
   define_string DOMAINNAME $DOMAINNAME_DEFAULT
-
-  string 'Please give a random seed of eight characters' RANDOM_SEED 12345678
 endmenu
 
 mainmenu_option next_comment
@@ -193,7 +190,6 @@ comment 'General defines'
     define_bool CHROOTDIR n
     define_int IRC_UID $IRC_UID
     define_int IRC_GID $IRC_GID
-    bool 'Allow to specify configuration file on command line' CMDLINE_CONFIG
     if [ "$CMDLINE_CONFIG" = "y" ]; then
       echo "   SECURITY: Then don't install the daemon SUID or SGID !"
     fi
@@ -236,21 +232,3 @@ comment 'Server characteristics'
     define_bool DEFAULT_LIST_PARAM n
   fi
 endmenu
-
-mainmenu_option next_comment
-comment 'Mandatory defines (you should leave these untouched)'
-  int 'Max auto connects per class (1!)' MAXIMUM_LINKS 1
-  int 'KILL nick chase time limit (30)' KILLCHASETIMELIMIT 30
-  int 'Max number of channels per user' MAXCHANNELSPERUSER 10
-  int 'Max number of silence masks (15!)' MAXSILES 15
-  int 'Expected average banmask length (40!)' AVBANLEN 40
-  eval define_macro MAXSILELENGTH \'\($AVBANLEN * MAXSILES\)\'
-  echo '* These are default values, used for class 0:'
-  int 'Max server idle time (60)' TIMESEC 60
-  int 'Class 0 ping frequency (120)' PINGFREQUENCY 120
-  int 'Class 0 connect frequency (600)' CONNECTFREQUENCY 600
-  int 'Min time before a link is good (300)' HANGONGOODLINK 300
-  int 'Wait before reconnecting to good link (10!)' HANGONRETRYDELAY 10
-  int 'connect(2) timeout (90!)' CONNECTTIMEOUT 90
-  int 'Max send queue (40000)' DEFAULTMAXSENDQLENGTH 40000
-endmenu
index 565548726ea15c69f655efbff5c0a4379b08aaea..87c51e95269349e54b9db1ee36af5cc560b6d7c9 100644 (file)
@@ -44,8 +44,6 @@ struct Client;
 
 #define KEYLEN          23
 #define CHANNELLEN      200
-#define MAXBANS         30
-#define MAXBANLENGTH    1024
 
 #define MAXJOINARGS    15 /* number of slots for join buffer */
 #define STARTJOINLEN   10 /* fuzzy numbers */
index fe194f478d20bb3dc8c10d091726009ddafc4f87..04f03afec87e2cb474206b85bb7b1bcb4ffa8627 100644 (file)
@@ -37,6 +37,23 @@ enum Feature {
   FEAT_IDLE_FROM_MSG,
   FEAT_HUB,
   FEAT_WALLOPS_OPER_ONLY,
+  FEAT_NODNS,
+  FEAT_RANDOM_SEED,
+
+  /* features that probably should not be touched */
+  FEAT_KILLCHASETIMELIMIT,
+  FEAT_MAXCHANNELSPERUSER,
+  FEAT_AVBANLEN,
+  FEAT_MAXBANS,
+  FEAT_MAXSILES,
+  FEAT_HANGONGOODLINK,
+  FEAT_HANGONRETRYDELAY,
+  FEAT_CONNECTTIMEOUT,
+  FEAT_TIMESEC,
+  FEAT_MAXIMUM_LINKS,
+  FEAT_PINGFREQUENCY,
+  FEAT_CONNECTFREQUENCY,
+  FEAT_DEFAULTMAXSENDQLENGTH,
 
   /* Some misc. default paths */
   FEAT_MPATH,
index 8bf6638997731f5820beac42165f8d3b497e7de8..ba2204a40ea20817bb176a9ead017e53279db938 100644 (file)
@@ -56,6 +56,11 @@ struct Motd {
 #define MOTD_MAXREMOTE 3
 
 struct MotdCache {
+  struct MotdCache*    next; /* these fields let us read MOTDs only once */
+  struct MotdCache**   prev_p;
+  int                  ref;
+  char*                        path;
+  int                  maxcount;
   struct tm            modtime;
   int                  count;
   char                 motd[1][MOTD_LINESIZE];
index 998106265cb19b6493114e60bb4dc5ac34044216..b6d305717a3876fe8a9bb4d94cb9abbf70ddad7e 100644 (file)
@@ -6,10 +6,15 @@
 #ifndef INCLUDED_random_h
 #define INCLUDED_random_h
 
+struct Client;
+
 /*
  * Proto types
  */
 
+extern int random_seed_set(struct Client* from, const char* const* fields,
+                          int count);
+
 extern unsigned int ircrandom(void);
 
 #endif /* INCLUDED_random_h */
index 520f4da2871c94b0f737f080f32f4c46945bf17a..4f73a0468d0717b9a39559334a920fc54707ec50 100644 (file)
                 " CHANTYPES=%s" \
                 " PREFIX=%s"
                  
-#define FEATURESVALUES MAXSILES,MAXMODEPARAMS,MAXCHANNELSPERUSER,MAXBANS, \
-        NICKLEN,TOPICLEN,TOPICLEN,"+#&","@+"
+#define FEATURESVALUES feature_int(FEAT_MAXSILES), MAXMODEPARAMS, \
+                      feature_int(FEAT_MAXCHANNELSPERUSER), \
+                      feature_int(FEAT_MAXBANS), NICKLEN, TOPICLEN, \
+                      TOPICLEN, "+#&", "@+"
 
 #endif /* INCLUDED_supported_h */
 
index 0aa7445fa0fe7fefbbc8ed3b4f0dd1eef3c5cb92..da39d2ed573fb1f139a2586440aea047ab60ac05 100644 (file)
@@ -303,11 +303,11 @@ channel.o: channel.c ../include/channel.h ../config/config.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
  ../include/hash.h ../include/ircd.h ../include/struct.h \
  ../include/ircd_alloc.h ../include/fda.h ../include/ircd_chattr.h \
- ../include/ircd_log.h ../include/ircd_reply.h \
- ../include/ircd_snprintf.h ../include/ircd_string.h ../include/list.h \
- ../include/match.h ../include/msg.h ../include/numeric.h \
- ../include/numnicks.h ../include/querycmds.h \
- ../include/ircd_features.h ../include/s_bsd.h ../include/s_conf.h \
+ ../include/ircd_features.h ../include/ircd_log.h \
+ ../include/ircd_reply.h ../include/ircd_snprintf.h \
+ ../include/ircd_string.h ../include/list.h ../include/match.h \
+ ../include/msg.h ../include/numeric.h ../include/numnicks.h \
+ ../include/querycmds.h ../include/s_bsd.h ../include/s_conf.h \
  ../include/s_debug.h ../include/s_misc.h ../include/s_user.h \
  ../include/send.h ../include/sprintf_irc.h ../include/support.h \
  ../include/sys.h ../include/whowas.h
@@ -315,9 +315,9 @@ class.o: class.c ../include/class.h ../include/client.h \
  ../include/ircd_defs.h ../config/config.h ../config/setup.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
  ../include/ircd.h ../include/struct.h ../include/ircd_alloc.h \
- ../include/fda.h ../include/ircd_reply.h ../include/list.h \
- ../include/numeric.h ../include/s_conf.h ../include/s_debug.h \
- ../include/send.h
+ ../include/fda.h ../include/ircd_features.h ../include/ircd_reply.h \
+ ../include/list.h ../include/numeric.h ../include/s_conf.h \
+ ../include/s_debug.h ../include/send.h
 client.o: client.c ../include/client.h ../include/ircd_defs.h \
  ../config/config.h ../config/setup.h ../include/dbuf.h \
  ../include/msgq.h ../include/ircd_handler.h ../include/class.h \
@@ -378,9 +378,9 @@ ircd_features.o: ircd_features.c ../config/config.h ../config/setup.h \
  ../include/ircd_alloc.h ../include/fda.h ../include/ircd_log.h \
  ../include/ircd_reply.h ../include/ircd_string.h \
  ../include/ircd_chattr.h ../include/match.h ../include/msg.h \
- ../include/numeric.h ../include/numnicks.h ../include/s_bsd.h \
- ../include/s_debug.h ../include/s_misc.h ../include/send.h \
- ../include/support.h ../include/sys.h
+ ../include/numeric.h ../include/numnicks.h ../include/random.h \
+ ../include/s_bsd.h ../include/s_debug.h ../include/s_misc.h \
+ ../include/send.h ../include/support.h ../include/sys.h
 ircd_log.o: ircd_log.c ../include/ircd_log.h ../include/client.h \
  ../include/ircd_defs.h ../config/config.h ../config/setup.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
@@ -587,7 +587,8 @@ m_join.o: m_join.c ../include/channel.h ../config/config.h \
  ../config/setup.h ../include/ircd_defs.h ../include/client.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
  ../include/gline.h ../include/hash.h ../include/ircd.h \
- ../include/struct.h ../include/ircd_chattr.h ../include/ircd_reply.h \
+ ../include/struct.h ../include/ircd_chattr.h \
+ ../include/ircd_features.h ../include/ircd_reply.h \
  ../include/ircd_string.h ../include/msg.h ../include/numeric.h \
  ../include/numnicks.h ../include/s_debug.h ../include/s_user.h \
  ../include/send.h
@@ -742,9 +743,10 @@ m_proto.o: m_proto.c ../include/client.h ../include/ircd_defs.h \
  ../include/msgq.h ../include/ircd_handler.h ../include/ircd.h \
  ../include/struct.h ../include/ircd_alloc.h ../include/fda.h \
  ../include/ircd_chattr.h ../include/ircd_reply.h \
- ../include/ircd_string.h ../include/numeric.h ../include/numnicks.h \
- ../include/s_debug.h ../include/s_misc.h ../include/send.h \
- ../include/supported.h ../include/channel.h ../include/version.h
+ ../include/ircd_string.h ../include/msg.h ../include/numeric.h \
+ ../include/numnicks.h ../include/s_debug.h ../include/s_misc.h \
+ ../include/send.h ../include/supported.h ../include/channel.h \
+ ../include/version.h
 m_quit.o: m_quit.c ../include/channel.h ../config/config.h \
  ../config/setup.h ../include/ircd_defs.h ../include/client.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
@@ -888,11 +890,12 @@ m_userip.o: m_userip.c ../include/client.h ../include/ircd_defs.h \
 m_version.o: m_version.c ../include/client.h ../include/ircd_defs.h \
  ../config/config.h ../config/setup.h ../include/dbuf.h \
  ../include/msgq.h ../include/ircd_handler.h ../include/hash.h \
- ../include/ircd.h ../include/struct.h ../include/ircd_reply.h \
- ../include/ircd_string.h ../include/ircd_chattr.h ../include/msg.h \
- ../include/numeric.h ../include/numnicks.h ../include/s_debug.h \
- ../include/s_user.h ../include/send.h ../include/supported.h \
- ../include/channel.h ../include/version.h
+ ../include/ircd.h ../include/struct.h ../include/ircd_features.h \
+ ../include/ircd_reply.h ../include/ircd_string.h \
+ ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \
+ ../include/numnicks.h ../include/s_debug.h ../include/s_user.h \
+ ../include/send.h ../include/supported.h ../include/channel.h \
+ ../include/version.h
 m_wallchops.o: m_wallchops.c ../include/channel.h ../config/config.h \
  ../config/setup.h ../include/ircd_defs.h ../include/client.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
@@ -977,8 +980,10 @@ parse.o: parse.c ../include/parse.h ../include/client.h \
  ../include/sys.h ../include/whocmds.h ../include/whowas.h
 querycmds.o: querycmds.c ../include/querycmds.h \
  ../include/ircd_features.h
-random.o: random.c ../include/random.h ../config/config.h \
- ../config/setup.h
+random.o: random.c ../include/random.h ../include/client.h \
+ ../include/ircd_defs.h ../config/config.h ../config/setup.h \
+ ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
+ ../include/ircd_log.h ../include/ircd_reply.h ../include/send.h
 res.o: res.c ../include/res.h ../include/client.h \
  ../include/ircd_defs.h ../config/config.h ../config/setup.h \
  ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \
index 3208d71492d8b8a1fdd31024859ebe3686f3f0a8..edb42297baa0546edde0243dbbb946fce6de852d 100644 (file)
@@ -26,6 +26,7 @@
 #include "ircd_alloc.h"
 #include "ircd_chattr.h"
 #include "ircd_defs.h"
+#include "ircd_features.h"
 #include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_snprintf.h"
@@ -148,7 +149,7 @@ struct Client* find_chasing(struct Client* sptr, const char* user, int* chasing)
   if (who)
     return who;
 
-  if (!(who = get_history(user, KILLCHASETIMELIMIT))) {
+  if (!(who = get_history(user, feature_int(FEAT_KILLCHASETIMELIMIT)))) {
     send_reply(sptr, ERR_NOSUCHNICK, user);
     return 0;
   }
@@ -339,7 +340,9 @@ int add_banid(struct Client *cptr, struct Channel *chptr, char *banid,
       banp = &(*banp)->next;
     }
   }
-  if (MyUser(cptr) && !removed_bans && (len > MAXBANLENGTH || (cnt >= MAXBANS)))
+  if (MyUser(cptr) && !removed_bans &&
+      (len > (feature_int(FEAT_AVBANLEN) * feature_int(FEAT_MAXBANS)) ||
+       (cnt >= feature_int(FEAT_MAXBANS))))
   {
     send_reply(cptr, ERR_BANLISTFULL, chptr->chname, banid);
     return -1;
@@ -1155,7 +1158,7 @@ void add_invite(struct Client *cptr, struct Channel *chptr)
    * Delete last link in chain if the list is max length
    */
   assert(list_length((cli_user(cptr))->invited) == (cli_user(cptr))->invites);
-  if ((cli_user(cptr))->invites>=MAXCHANNELSPERUSER)
+  if ((cli_user(cptr))->invites >= feature_int(FEAT_MAXCHANNELSPERUSER))
     del_invite(cptr, (cli_user(cptr))->invited->value.chptr);
   /*
    * Add client to channel invite list
@@ -2256,7 +2259,8 @@ mode_process_bans(struct ParseState *state)
        MyFree(ban->value.ban.banstr);
       } else {
        if (state->flags & MODE_PARSE_SET && MyUser(state->sptr) &&
-           (len > MAXBANLENGTH || count >= MAXBANS)) {
+           (len > (feature_int(FEAT_AVBANLEN) * feature_int(FEAT_MAXBANS)) ||
+            count >= feature_int(FEAT_MAXBANS))) {
          send_reply(state->sptr, ERR_BANLISTFULL, state->chptr->chname,
                     ban->value.ban.banstr);
          count--;
index 15e8ff48db620f358f306a159952f976729f7e9a..1df62142d5a0a7c74add276e2192c688aee044e2 100644 (file)
@@ -55,6 +55,8 @@
 #define CONF_KLINE              (CONF_KILL | CONF_IPKILL)
 #define CONF_CRULE              (CONF_CRULEALL | CONF_CRULEAUTO)
 
+/* DEFAULTMAXSENDQLENGTH went into the features subsystem... */
+#define DEFAULTMAXSENDQLENGTH 40000
 
 /*
  * For the connect rule patch..  these really should be in a header,
index a3f855f905408d568c2e89c1607a723e32277a53..feb5dd8e35b6985ce1f4f85d0efbd3871ee9256b 100644 (file)
@@ -22,6 +22,7 @@
 #include "client.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "list.h"
 #include "numeric.h"
@@ -70,10 +71,10 @@ void init_class(void)
   connClassList = (struct ConnectionClass*) make_class();
 
   ConClass(connClassList) = 0;
-  PingFreq(connClassList) = PINGFREQUENCY;
-  ConFreq(connClassList)  = CONNECTFREQUENCY;
-  MaxLinks(connClassList) = MAXIMUM_LINKS;
-  MaxSendq(connClassList) = DEFAULTMAXSENDQLENGTH;
+  PingFreq(connClassList) = feature_int(FEAT_PINGFREQUENCY);
+  ConFreq(connClassList)  = feature_int(FEAT_CONNECTFREQUENCY);
+  MaxLinks(connClassList) = feature_int(FEAT_MAXIMUM_LINKS);
+  MaxSendq(connClassList) = feature_int(FEAT_DEFAULTMAXSENDQLENGTH);
   connClassList->valid    = 1;
   Links(connClassList)    = 0;
   connClassList->next     = 0;
@@ -185,11 +186,11 @@ unsigned int get_client_ping(struct Client *acptr)
     }
   }
   else {
-    ping = PINGFREQUENCY;
+    ping = feature_int(FEAT_PINGFREQUENCY);
     Debug((DEBUG_DEBUG, "No Attached Confs for: %s", cli_name(acptr)));
   }
   if (ping <= 0)
-    ping = PINGFREQUENCY;
+    ping = feature_int(FEAT_PINGFREQUENCY);
   Debug((DEBUG_DEBUG, "Client %s Ping %d", cli_name(acptr), ping));
   return (ping);
 }
@@ -199,7 +200,7 @@ unsigned int get_con_freq(struct ConnectionClass * clptr)
   if (clptr)
     return (ConFreq(clptr));
   else
-    return (CONNECTFREQUENCY);
+    return feature_int(FEAT_CONNECTFREQUENCY);
 }
 
 /*
@@ -230,7 +231,7 @@ void add_class(unsigned int conClass, unsigned int ping, unsigned int confreq,
   ConFreq(p) = confreq;
   PingFreq(p) = ping;
   MaxLinks(p) = maxli;
-  MaxSendq(p) = (sendq > 0) ? sendq : DEFAULTMAXSENDQLENGTH;
+  MaxSendq(p) = (sendq > 0) ? sendq : feature_int(FEAT_DEFAULTMAXSENDQLENGTH);
   p->valid = 1;
   if (p != t)
     Links(p) = 0;
@@ -278,7 +279,7 @@ unsigned int get_sendq(struct Client *cptr)
       }
     }
   }
-  return DEFAULTMAXSENDQLENGTH;
+  return feature_int(FEAT_DEFAULTMAXSENDQLENGTH);
 }
 
 void class_send_meminfo(struct Client* cptr)
index b1ed01f9aa7b4608eadd37d55c098b0ed60c672c..0c7446517a56c04aef34be2540a2eeea8771ed28 100644 (file)
@@ -55,7 +55,7 @@ int client_get_ping(const struct Client* acptr)
     }
   }
   if (0 == ping)
-    ping = PINGFREQUENCY;
+    ping = feature_int(FEAT_PINGFREQUENCY);
 
   Debug((DEBUG_DEBUG, "Client %s Ping %d", cli_name(acptr), ping));
   return ping;
index 24d966de22ce7ff9ca73618cdc98bbfb7f42b10b..d60cc0c241326d64ff8f288b316bb1a22485ca72 100644 (file)
@@ -273,9 +273,11 @@ static time_t try_connections(void) {
  *--------------------------------------------------------------------------*/
 static time_t check_pings(void) {
   int expire     = 0; 
-  int next_check = CurrentTime + PINGFREQUENCY;
+  int next_check = CurrentTime;
   int max_ping   = 0;
   int i;
+
+  next_check += feature_int(FEAT_PINGFREQUENCY);
   
   /* Scan through the client table */
   for (i=0; i <= HighestFd; i++) {
@@ -293,7 +295,8 @@ static time_t check_pings(void) {
       continue;
     }
 
-    max_ping = IsRegistered(cptr) ? client_get_ping(cptr) : CONNECTTIMEOUT;
+    max_ping = IsRegistered(cptr) ? client_get_ping(cptr) :
+      feature_int(FEAT_CONNECTTIMEOUT);
    
     Debug((DEBUG_DEBUG, "check_pings(%s)=status:%s limit: %d current: %d",
           cli_name(cptr), (cli_flags(cptr) & FLAGS_PINGSENT) ? "[Ping Sent]" : "[]", 
@@ -478,7 +481,7 @@ static void event_loop(void) {
     if (delay < 1)
       read_message(1);
     else
-      read_message(IRCD_MIN(delay, TIMESEC));
+      read_message(IRCD_MIN(delay, feature_int(FEAT_TIMESEC)));
 
     /* ...perhaps should not do these loops every time, but only if there is
      * some chance of something happening (but, note that conf->hold times may
index 7c8e9fb171159f69a02aaf5b9422a797ce51a3dd..9e6983b86dc9fdb124157e6dbdb85db2d88c7ace 100644 (file)
@@ -31,6 +31,7 @@
 #include "msg.h"
 #include "numeric.h"
 #include "numnicks.h"
+#include "random.h"    /* random_seed_set */
 #include "s_bsd.h"
 #include "s_debug.h"
 #include "s_misc.h"
@@ -189,6 +190,7 @@ typedef void (*feat_report_call)(struct Client*, int);
 
 #define FEAT_OPER   0x0100     /* set to display only to opers */
 #define FEAT_MYOPER 0x0200     /* set to display only to local opers */
+#define FEAT_NODISP 0x0400     /* feature must never be displayed */
 
 #define FEAT_READ   0x1000     /* feature is read-only (for now, perhaps?) */
 
@@ -234,6 +236,23 @@ static struct FeatureDesc {
   F_B(IDLE_FROM_MSG, 0, 1),
   F_B(HUB, 0, 0),
   F_B(WALLOPS_OPER_ONLY, 0, 0),
+  F_B(NODNS, 0, 0),
+  F_N(RANDOM_SEED, FEAT_NODISP, random_seed_set, 0, 0, 0, 0, 0),
+
+  /* features that probably should not be touched */
+  F_I(KILLCHASETIMELIMIT, 0, 30),
+  F_I(MAXCHANNELSPERUSER, 0, 10),
+  F_I(AVBANLEN, 0, 40),
+  F_I(MAXBANS, 0, 30),
+  F_I(MAXSILES, 0, 15),
+  F_I(HANGONGOODLINK, 0, 300),
+  F_I(HANGONRETRYDELAY, 0, 10),
+  F_I(CONNECTTIMEOUT, 0, 90),
+  F_I(TIMESEC, 0, 60),
+  F_I(MAXIMUM_LINKS, 0, 1),
+  F_I(PINGFREQUENCY, 0, 120),
+  F_I(CONNECTFREQUENCY, 0, 600),
+  F_I(DEFAULTMAXSENDQLENGTH, 0, 40000),
 
   /* Some misc. default paths */
   F_S(MPATH, FEAT_CASE | FEAT_MYOPER, "ircd.motd"),
@@ -481,7 +500,8 @@ feature_get(struct Client* from, const char* const* fields, int count)
   if (count < 1) /* check parameters */
     need_more_params(from, "GET");
   else if ((feat = feature_desc(from, fields[0]))) {
-    if ((feat->flags & FEAT_MYOPER && !MyOper(from)) ||
+    if ((feat->flags & FEAT_NODISP) ||
+       (feat->flags & FEAT_MYOPER && !MyOper(from)) ||
        (feat->flags & FEAT_OPER && !IsAnOper(from))) /* check privs */
       return send_reply(from, ERR_NOPRIVILEGES);
 
@@ -565,7 +585,8 @@ feature_report(struct Client* to)
   int i;
 
   for (i = 0; features[i].type; i++) {
-    if ((features[i].flags & FEAT_MYOPER && !MyOper(to)) ||
+    if ((features[i].flags & FEAT_NODISP) ||
+       (features[i].flags & FEAT_MYOPER && !MyOper(to)) ||
        (features[i].flags & FEAT_OPER && !IsAnOper(to)))
       continue; /* skip this one */
 
index 437a52f2bbb58be6ee6009f3049427898c268d38..f07d1f1fe493f3bb627daab0b764321d55998fa2 100644 (file)
@@ -93,6 +93,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_chattr.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
@@ -217,7 +218,7 @@ int m_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     } else
       flags = IsModelessChannel(name) ? CHFL_DEOPPED : CHFL_CHANOP;
 
-    if (cli_user(sptr)->joined >= MAXCHANNELSPERUSER &&
+    if (cli_user(sptr)->joined >= feature_int(FEAT_MAXCHANNELSPERUSER) &&
        !HasPriv(sptr, PRIV_CHAN_LIMIT)) {
       send_reply(sptr, ERR_TOOMANYCHANNELS, chptr ? chptr->chname : name);
       break; /* no point processing the other channels */
index 1366879cb1ee9b1a8455378c1f31fc5b8edbc854..4893f01e6b826c4cb1136ede7d12b8cd2098c776 100644 (file)
@@ -90,6 +90,7 @@
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
index 4fe4a56f870d19fee4884624d88fe8f54c5d5173..f32bfb4638e36d360df9becf65426067ec5c1b3f 100644 (file)
 #include <sys/stat.h>
 
 static struct {
-  struct Motd* local;
-  struct Motd* remote;
-  struct Motd* other;
-  struct Motd* freelist;
+  struct Motd*     local;
+  struct Motd*     remote;
+  struct Motd*     other;
+  struct Motd*     freelist;
+  struct MotdCache* cachelist;
 } MotdList;
 
 /* Create a struct Motd and initialize it */
@@ -118,6 +119,16 @@ motd_cache(struct Motd *motd)
   if (motd->cache)
     return motd->cache;
 
+  /* try to find it in the list of cached files... */
+  for (cache = MotdList.cachelist; cache; cache = cache->next) {
+    if (!strcmp(cache->path, motd->path) &&
+       cache->maxcount == motd->maxcount) { /* found one... */
+      cache->ref++; /* increase reference count... */
+      motd->cache = cache; /* remember cache... */
+      return motd->cache; /* return it */
+    }
+  }
+
   /* gotta read in the file, now */
   if (!(file = fbopen(motd->path, "r"))) {
     Debug((DEBUG_ERROR, "Couldn't open \"%s\": %s", motd->path,
@@ -135,10 +146,14 @@ motd_cache(struct Motd *motd)
   cache = (struct MotdCache *)MyMalloc(sizeof(struct MotdCache) +
                                       (MOTD_LINESIZE * (MOTD_MAXLINES - 1)));
 
+  cache->ref = 1;
+  DupString(cache->path, motd->path);
+  cache->maxcount = motd->maxcount;
+
   cache->modtime = *localtime((time_t *) &sb.st_mtime); /* store modtime */
 
   cache->count = 0;
-  while (cache->count < motd->maxcount && fbgets(line, sizeof(line), file)) {
+  while (cache->count < cache->maxcount && fbgets(line, sizeof(line), file)) {
     /* copy over line, stopping when we overflow or hit line end */
     for (tmp = line, i = 0;
         i < (MOTD_LINESIZE - 1) && *tmp && *tmp != '\r' && *tmp != '\n';
@@ -156,6 +171,13 @@ motd_cache(struct Motd *motd)
                                              (MOTD_LINESIZE *
                                               (cache->count - 1)));
 
+  /* now link it in... */
+  motd->cache->next = MotdList.cachelist;
+  motd->cache->prev_p = &MotdList.cachelist;
+  if (MotdList.cachelist)
+    MotdList.cachelist->prev_p = &motd->cache->next;
+  MotdList.cachelist = motd->cache;
+
   return motd->cache;
 }
 
@@ -171,7 +193,15 @@ motd_decache(struct Motd *motd)
 
   motd->cache = 0; /* zero the cache */
 
-  MyFree(cache); /* very simple for a reason... */
+  if (!--cache->ref) { /* reduce reference count... */
+    if (cache->next) /* ref is 0, delink from list and free */
+      cache->next->prev_p = cache->prev_p;
+    *cache->prev_p = cache->next;
+
+    MyFree(cache->path); /* free path info... */
+
+    MyFree(cache); /* very simple for a reason... */
+  }
 }
 
 /* This function destroys a struct Motd, destroying the cache if needed */
@@ -303,6 +333,9 @@ motd_init(void)
   motd_cache(MotdList.remote); /* init remote and cache it */
 
   MotdList.other = 0; /* no T-lines processed yet */
+
+  MotdList.freelist = 0;
+  MotdList.cachelist = 0;
 }
 
 /* This routine adds a MOTD */
index 0fab4deecf9c3394269be2a462516bb71480e3f2..528b8d42c6add083305ecb7e898fa93711bda87e 100644 (file)
  * $Id$
  */
 #include "random.h"
-#include "config.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/time.h>
+#include "client.h"
+#include "ircd_log.h"
+#include "ircd_reply.h"
+#include "send.h"
 
 #include <string.h>
+#include <sys/time.h>
+
+
+char localkey[9] = "12345678";
+
+/* This devious-looking construct rolls a character to the left by r bits */
+#define char_roll(c, r)        (((c) << (r)) | ((c) >> (8 - (r))))
+
+/* this routine is intended to be called by the feature subsystem; it takes
+ * a key as found in the .conf and mashes it up for the seed for the random
+ * number generator.
+ */
+int
+random_seed_set(struct Client* from, const char* const* fields, int count)
+{
+  const char *p = 0;
+  int len, i, roll = 0;
+
+  if (count < 1) {
+    if (from) /* send an error */
+      return need_more_params(from, "SET");
+    else {
+      log_write(LS_CONFIG, L_ERROR, 0, "Not enough fields in F line");
+      return 0;
+    }
+  }
+
+  len = strlen(fields[0]);
 
-char localkey[9] = RANDOM_SEED;
+  /* logic is: go through loop at least 8 times, but use all bits of seed */
+  for (i = 0; i < (len < 8 ? 8 : len); i++, p++) {
+    if (!(i % len)) { /* if we've exceeded the string length, reset */
+      p = fields[0];
+      roll++; /* so latter part of string looks different from former */
+    }
+
+    /* set the appropriate location of localkey according to the following
+     * rules: first, roll current value by an amount depending on how many
+     * times we've touched this character.  Then take seed value and roll
+     * it by an amount depending upon how many times we've touched that
+     * character.  Finally, xor the values together.
+     */
+    localkey[i % 8] = char_roll(localkey[i % 8], (i / 8) % 8) ^
+      char_roll(*p, roll % 8);
+  }
+
+  return 1;
+}
+
+/* this is like memcpy except it xors the areas in memory. */
+static void
+memxor(void *dest, void *src, int n)
+{
+  unsigned char *d = (unsigned char *)dest;
+  unsigned char *s = (unsigned char *)src;
+
+  while (--n)
+    d[n] ^= s[n];
+}
 
 /*
  * MD5 transform algorithm, taken from code written by Colin Plumb,
@@ -39,6 +96,12 @@ char localkey[9] = RANDOM_SEED;
  * record: Cleaned up to work with ircd.  RANDOM_TOKEN is defined in
  * setup.h by the make script; if people start to "guess" your cookies,
  * consider recompiling your server with a different random token.
+ *
+ * Kev: Now the seed comes from the feature subsystem and is fed into a
+ * mash routine (random_set_seed) that depends on previous values of the
+ * localkey array; also, part of the output of the RNG is fed back into
+ * the localkey array.  Finally, the time values are xor'd with the local
+ * key to enhance non-determinability of the data fed into the MD5 core.
  */
 
 /* The four core functions - F1 is optimized somewhat */
@@ -73,11 +136,12 @@ unsigned int ircrandom(void)
   unsigned char in[16];
   struct timeval tv;
 
-  gettimeofday(&tv, NULL);
+  gettimeofday(&tv, 0);
 
   memcpy((void *)in, (void *)localkey, 8);
-  memcpy((void *)(in + 8), (void *)&tv.tv_sec, 4);
-  memcpy((void *)(in + 12), (void *)&tv.tv_usec, 4);
+  memcpy((void *)(in + 8), (void *)localkey, 8);
+  memxor((void *)(in + 8), (void *)&tv.tv_sec, 4);
+  memxor((void *)(in + 12), (void *)&tv.tv_usec, 4);
 
   a = 0x67452301;
   b = 0xefcdab89;
@@ -152,9 +216,18 @@ unsigned int ircrandom(void)
   MD5STEP(F4, c, d, a, b, (int)in[2] + 0x2ad7d2bb, 15);
   MD5STEP(F4, b, c, d, a, (int)in[9] + 0xeb86d391, 21);
 
+  /* This feeds part of the output of the random number generator into the
+   * seed to further obscure any patterns
+   */
+  memxor((void *)localkey, (void *)&a, 4);
+  memxor((void *)(localkey + 4), (void *)&b, 4);
+
   /*
    * We have 4 unsigned longs generated by the above sequence; this scrambles
    * them together so that if there is any pattern, it will be obscured.
+   *
+   * a and b are now part of the state of the random number generator;
+   * returning them is a security hazard.
    */
-  return (a ^ b ^ c ^ d);
+  return (c ^ d);
 }
index 00ecdab43258546cb664438843bce2db26dbeb73..28158f7766a904b782bacccee7abe1c01ddc8ce8 100644 (file)
@@ -522,31 +522,31 @@ void start_auth(struct Client* client)
   auth = make_auth_request(client);
   assert(0 != auth);
 
-#if !defined(NODNS)
-  if (LOOPBACK == inet_netof(cli_ip(client))) {
-    strcpy(cli_sockhost(client), cli_name(&me));
-  }
-  else {
-    struct DNSQuery query;
-
-    query.vptr     = auth;
-    query.callback = auth_dns_callback;
-
-    if (IsUserPort(auth->client))
-      sendheader(client, REPORT_DO_DNS);
+  if (!feature_bool(FEAT_NODNS)) {
+    if (LOOPBACK == inet_netof(cli_ip(client)))
+      strcpy(cli_sockhost(client), cli_name(&me));
+    else {
+      struct DNSQuery query;
 
-    cli_dns_reply(client) = gethost_byaddr((const char*) &(cli_ip(client)), &query);
+      query.vptr     = auth;
+      query.callback = auth_dns_callback;
 
-    if (cli_dns_reply(client)) {
-      ++(cli_dns_reply(client))->ref_count;
-      ircd_strncpy(cli_sockhost(client), cli_dns_reply(client)->hp->h_name, HOSTLEN);
       if (IsUserPort(auth->client))
-       sendheader(client, REPORT_FIN_DNSC);
+       sendheader(client, REPORT_DO_DNS);
+
+      cli_dns_reply(client) = gethost_byaddr((const char*) &(cli_ip(client)),
+                                            &query);
+
+      if (cli_dns_reply(client)) {
+       ++(cli_dns_reply(client))->ref_count;
+       ircd_strncpy(cli_sockhost(client), cli_dns_reply(client)->hp->h_name,
+                    HOSTLEN);
+       if (IsUserPort(auth->client))
+         sendheader(client, REPORT_FIN_DNSC);
+      } else
+       SetDNSPending(auth);
     }
-    else
-      SetDNSPending(auth);
   }
-#endif
 
   if (start_auth_query(auth))
     link_auth_request(auth, &AuthPollList);
index 6a5904f16d667a0e4b102ebacd6a3439cea0ca58..e53658e122e2c34014cab87695796bcd7ddf86e6 100644 (file)
@@ -476,8 +476,9 @@ void close_connection(struct Client *cptr)
        * CONF_ILLEGAL). But only do this if it was a "good" link.
        */
       aconf->hold = CurrentTime;
-      aconf->hold += (aconf->hold - cli_since(cptr) > HANGONGOODLINK) ?
-                     HANGONRETRYDELAY : ConfConFreq(aconf);
+      aconf->hold += ((aconf->hold - cli_since(cptr) >
+                      feature_int(FEAT_HANGONGOODLINK)) ?
+                     feature_int(FEAT_HANGONRETRYDELAY) : ConfConFreq(aconf));
       if (nextconnect > aconf->hold)
         nextconnect = aconf->hold;
     }
index c28038aa3fbfbe7751b6c53130148c6d66d3173b..96d986e6e87df66253c18f91abc3762f8ac4cd0f 100644 (file)
@@ -83,9 +83,6 @@ const char* debug_serveropts(void)
 #ifdef  CHROOTDIR
   AddC('c');
 #endif
-#ifdef  CMDLINE_CONFIG
-  AddC('C');
-#endif
 #ifdef  DEBUGMODE
   AddC('D');
 #endif
index f483a0ee7dd57ce696d9f431961295dd1ab24ca1..e8d00b7ac59953fce61c2b140446954880daf076 100644 (file)
@@ -1528,7 +1528,8 @@ int add_silence(struct Client* sptr, const char* mask)
     if (MyUser(sptr))
     {
       len += strlen(lp->value.cp);
-      if ((len > MAXSILELENGTH) || (++cnt >= MAXSILES))
+      if ((len > (feature_int(FEAT_AVBANLEN) * feature_int(FEAT_MAXSILES))) ||
+         (++cnt >= feature_int(FEAT_MAXSILES)))
       {
         send_reply(sptr, ERR_SILELISTFULL, mask);
         return -1;