+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.
EXTRA_CPPFLAGS="-DNDEBUG $EXTRA_CPPFLAGS"
fi
fi
- bool 'Are you testing on a host without DNS' NODNS
endmenu
mainmenu_option next_comment
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
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
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
#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 */
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,
#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];
#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 */
" 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 */
../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
../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 \
../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 \
../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
../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 \
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 \
../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 \
#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"
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;
}
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;
* 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
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--;
#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,
#include "client.h"
#include "ircd.h"
#include "ircd_alloc.h"
+#include "ircd_features.h"
#include "ircd_reply.h"
#include "list.h"
#include "numeric.h"
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;
}
}
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);
}
if (clptr)
return (ConFreq(clptr));
else
- return (CONNECTFREQUENCY);
+ return feature_int(FEAT_CONNECTFREQUENCY);
}
/*
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;
}
}
}
- return DEFAULTMAXSENDQLENGTH;
+ return feature_int(FEAT_DEFAULTMAXSENDQLENGTH);
}
void class_send_meminfo(struct Client* cptr)
}
}
if (0 == ping)
- ping = PINGFREQUENCY;
+ ping = feature_int(FEAT_PINGFREQUENCY);
Debug((DEBUG_DEBUG, "Client %s Ping %d", cli_name(acptr), ping));
return ping;
*--------------------------------------------------------------------------*/
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++) {
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]" : "[]",
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
#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"
#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?) */
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"),
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);
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 */
#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"
} 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 */
#include "client.h"
#include "hash.h"
#include "ircd.h"
+#include "ircd_features.h"
#include "ircd_reply.h"
#include "ircd_string.h"
#include "msg.h"
#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 */
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,
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';
(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;
}
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 */
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 */
* $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,
* 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 */
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;
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);
}
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);
* 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;
}
#ifdef CHROOTDIR
AddC('c');
#endif
-#ifdef CMDLINE_CONFIG
- AddC('C');
-#endif
#ifdef DEBUGMODE
AddC('D');
#endif
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;