[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2007-12-11 23:38:46
|
Committer : zolty CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2007-12-11 23:38:38 UTC Modified files: ChangeLog ChangeLog.es config.h.in configure doc/Makefile.in include/channel.h include/dbuf.h include/gline.h include/ircd_crypt.h include/ircd_events.h include/ircd_features.h include/numeric.h include/patchlevel.h include/res.h include/s_user.h ircd/channel.c ircd/class.c ircd/dbuf.c ircd/engine_poll.c ircd/gline.c ircd/hash.c ircd/ircd_events.c ircd/ircd_features.c ircd/ircd_lexer.l ircd/ircd_parser.y ircd/ircd_snprintf.c ircd/ircd_string.c ircd/listener.c ircd/m_admin.c ircd/m_asll.c ircd/m_burst.c ircd/m_cap.c ircd/m_connect.c ircd/m_gline.c ircd/m_join.c ircd/m_list.c ircd/m_lusers.c ircd/m_mode.c ircd/m_names.c ircd/m_nick.c ircd/m_privs.c ircd/m_server.c ircd/m_silence.c ircd/m_stats.c ircd/m_user.c ircd/m_version.c ircd/m_who.c ircd/msgq.c ircd/numnicks.c ircd/parse.c ircd/s_auth.c ircd/s_bsd.c ircd/s_conf.c ircd/s_debug.c ircd/s_err.c ircd/s_misc.c ircd/s_user.c ircd/send.c ircd/umkpasswd.c ircd/uping.c ircd/version.c.SH ircd/whowas.c ircd/test/ircd_in_addr_t.c Log message: Author: zoltan <zo...@ir...> Log message: 2007-11-11 Toni Garc�a <zo...@ir...> 1.0.beta10 * Sincronizacion Undernet ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.58 ircd-ircdev/ChangeLog:1.59 --- ircd-ircdev/ChangeLog:1.58 Sun Nov 11 13:53:01 2007 +++ ircd-ircdev/ChangeLog Tue Dec 11 15:38:20 2007 @@ -1,10 +1,13 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.58 2007/11/11 21:53:01 zolty Exp $ +# $Id: ChangeLog,v 1.59 2007/12/11 23:38:20 zolty Exp $ # # Insert new changes at beginning of the change list. # +2007-12-12 Toni Garc�a <zo...@ir...> 1.0.beta10 + * Undernet synchronization + 2007-11-11 Toni Garc�a <zo...@ir...> 1.0.beta9 * SSL Support 2007-09-20 Toni Garc�a <zo...@ir...> 1.0.beta8 Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.58 ircd-ircdev/ChangeLog.es:1.59 --- ircd-ircdev/ChangeLog.es:1.58 Sun Nov 11 13:53:02 2007 +++ ircd-ircdev/ChangeLog.es Tue Dec 11 15:38:21 2007 @@ -1,10 +1,13 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.58 2007/11/11 21:53:02 zolty Exp $ +# $Id: ChangeLog.es,v 1.59 2007/12/11 23:38:21 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2007-11-11 Toni Garc�a <zo...@ir...> 1.0.beta10 + * Sincronizacion Undernet + 2007-11-11 Toni Garc�a <zo...@ir...> 1.0.beta9 * Soporte SSL Index: ircd-ircdev/config.h.in diff -u ircd-ircdev/config.h.in:1.14 ircd-ircdev/config.h.in:1.15 --- ircd-ircdev/config.h.in:1.14 Sun Nov 11 13:53:02 2007 +++ ircd-ircdev/config.h.in Tue Dec 11 15:38:21 2007 @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: config.h.in,v 1.14 2007/11/11 21:53:02 zolty Exp $ + * $Id: config.h.in,v 1.15 2007/12/11 23:38:21 zolty Exp $ * */ #ifndef INCLUDED_config_h Index: ircd-ircdev/configure diff -u ircd-ircdev/configure:1.24 ircd-ircdev/configure:1.25 --- ircd-ircdev/configure:1.24 Sun Nov 11 13:53:02 2007 +++ ircd-ircdev/configure Tue Dec 11 15:38:21 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 1.2 . +# From configure.ac Revision: 1.3 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for IRC-Dev IRC Daemon 1.0.beta. # Index: ircd-ircdev/doc/Makefile.in diff -u ircd-ircdev/doc/Makefile.in:1.5 ircd-ircdev/doc/Makefile.in:1.6 --- ircd-ircdev/doc/Makefile.in:1.5 Sun Apr 22 06:56:19 2007 +++ ircd-ircdev/doc/Makefile.in Tue Dec 11 15:38:23 2007 @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# $Id: Makefile.in,v 1.5 2007/04/22 13:56:19 zolty Exp $ +# $Id: Makefile.in,v 1.6 2007/12/11 23:38:23 zolty Exp $ # #### Start of system configuration section. #### @@ -31,6 +31,8 @@ RM = @RMPROG@ @SET_MAKE@ +DATAROOTDIR = @datarootdir@ +DATADIR = @datadir@ MANDIR = @mandir@ #### End of system configuration section. #### Index: ircd-ircdev/include/channel.h diff -u ircd-ircdev/include/channel.h:1.18 ircd-ircdev/include/channel.h:1.19 --- ircd-ircdev/include/channel.h:1.18 Sat Jul 21 16:51:39 2007 +++ ircd-ircdev/include/channel.h Tue Dec 11 15:38:23 2007 @@ -22,7 +22,7 @@ */ /** @file * @brief Channel management and maintenance. - * @version $Id: channel.h,v 1.18 2007/07/21 23:51:39 zolty Exp $ + * @version $Id: channel.h,v 1.19 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_channel_h #define INCLUDED_channel_h @@ -188,6 +188,7 @@ #define LISTARG_TOPICLIMITS 0x0001 #define LISTARG_SHOWSECRET 0x0002 #define LISTARG_NEGATEWILDCARD 0x0004 +#define LISTARG_SHOWMODES 0x0008 /** * Maximum acceptable lag time in seconds: A channel younger than Index: ircd-ircdev/include/dbuf.h diff -u ircd-ircdev/include/dbuf.h:1.6 ircd-ircdev/include/dbuf.h:1.7 --- ircd-ircdev/include/dbuf.h:1.6 Thu Apr 19 15:53:46 2007 +++ ircd-ircdev/include/dbuf.h Tue Dec 11 15:38:23 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Interfaces and declarations for dealing with data buffers. - * @version $Id: dbuf.h,v 1.6 2007/04/19 22:53:46 zolty Exp $ + * @version $Id: dbuf.h,v 1.7 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_dbuf_h #define INCLUDED_dbuf_h @@ -34,8 +34,8 @@ /* * These two globals should be considered read only */ -extern int DBufAllocCount; -extern int DBufUsedCount; +extern unsigned int DBufAllocCount; +extern unsigned int DBufUsedCount; struct DBufBuffer; Index: ircd-ircdev/include/gline.h diff -u ircd-ircdev/include/gline.h:1.6 ircd-ircdev/include/gline.h:1.7 --- ircd-ircdev/include/gline.h:1.6 Thu Apr 19 15:53:46 2007 +++ ircd-ircdev/include/gline.h Tue Dec 11 15:38:23 2007 @@ -23,7 +23,7 @@ */ /** @file * @brief Structures and APIs for G-line manipulation. - * @version $Id: gline.h,v 1.6 2007/04/19 22:53:46 zolty Exp $ + * @version $Id: gline.h,v 1.7 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_gline_h #define INCLUDED_gline_h @@ -42,18 +42,36 @@ #define GLINE_MAX_EXPIRE 604800 /**< max expire: 7 days */ +/** Local state of a G-line. */ +enum GlineLocalState { + GLOCAL_GLOBAL, /**< G-line state unmodified locally. */ + GLOCAL_ACTIVATED, /**< G-line state locally activated. */ + GLOCAL_DEACTIVATED /**< G-line state locally deactivated. */ +}; + /** Description of a G-line. */ struct Gline { - struct Gline *gl_next; /**< Next G-line in linked list. */ - struct Gline**gl_prev_p; /**< Previous pointer to this G-line. */ - char *gl_user; /**< Username mask (or channel/realname mask). */ - char *gl_host; /**< Host prtion of mask. */ - char *gl_reason; /**< Reason for G-line. */ - time_t gl_expire; /**< Expiration timestamp. */ - time_t gl_lastmod; /**< Last modification timestamp. */ - struct irc_in_addr gl_addr; /**< IP address (for IP-based G-lines). */ - unsigned char gl_bits; /**< Usable bits in gl_addr. */ - unsigned int gl_flags; /**< G-line status flags. */ + struct Gline *gl_next; /**< Next G-line in linked list. */ + struct Gline**gl_prev_p; /**< Previous pointer to this G-line. */ + char *gl_user; /**< Username mask (or channel/realname mask). */ + char *gl_host; /**< Host prtion of mask. */ + char *gl_reason; /**< Reason for G-line. */ + time_t gl_expire; /**< Expiration timestamp. */ + time_t gl_lastmod; /**< Last modification timestamp. */ + time_t gl_lifetime; /**< Record expiration timestamp. */ + struct irc_in_addr gl_addr; /**< IP address (for IP-based G-lines). */ + unsigned char gl_bits; /**< Usable bits in gl_addr. */ + unsigned int gl_flags; /**< G-line status flags. */ + enum GlineLocalState gl_state;/**< G-line local state. */ +}; + +/** Action to perform on a G-line. */ +enum GlineAction { + GLINE_ACTIVATE, /**< G-line should be activated. */ + GLINE_DEACTIVATE, /**< G-line should be deactivated. */ + GLINE_LOCAL_ACTIVATE, /**< G-line should be locally activated. */ + GLINE_LOCAL_DEACTIVATE, /**< G-line should be locally deactivated. */ + GLINE_MODIFY /**< G-line should be modified. */ }; #define GLINE_ACTIVE 0x0001 /**< G-line is active. */ @@ -69,14 +87,22 @@ #define GLINE_OPERFORCE 0x0400 /**< Oper forcing G-line to be set. */ #define GLINE_REALNAME 0x0800 /**< G-line matches only the realname field. */ +#define GLINE_EXPIRE 0x1000 /**< Expiration time update */ +#define GLINE_LIFETIME 0x2000 /**< Record lifetime update */ +#define GLINE_REASON 0x4000 /**< Reason update */ + /** Controllable flags that can be set on an actual G-line. */ #define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME) /** Mask for G-line activity flags. */ #define GLINE_ACTMASK (GLINE_ACTIVE | GLINE_LDEACT) +/** Mask for G-line update flags. */ +#define GLINE_UPDATE (GLINE_EXPIRE | GLINE_LIFETIME | GLINE_REASON) + /** Test whether \a g is active. */ -#define GlineIsActive(g) (((g)->gl_flags & GLINE_ACTMASK) == \ - GLINE_ACTIVE) +#define GlineIsActive(g) ((((g)->gl_flags & GLINE_ACTIVE) && \ + (g)->gl_state != GLOCAL_DEACTIVATED) || \ + (g)->gl_state == GLOCAL_ACTIVATED) /** Test whether \a g is remotely (globally) active. */ #define GlineIsRemActive(g) ((g)->gl_flags & GLINE_ACTIVE) /** Test whether \a g is an IP-based G-line. */ @@ -97,17 +123,21 @@ /** Return last modification time of a G-line. */ #define GlineLastMod(g) ((g)->gl_lastmod) -extern int gline_propagate(struct Client *cptr, struct Client *sptr, - struct Gline *gline); extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost, char *reason, time_t expire, time_t lastmod, - unsigned int flags); + time_t lifetime, unsigned int flags); extern int gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline, time_t lastmod, unsigned int flags); extern int gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline, time_t lastmod, unsigned int flags); +extern int gline_modify(struct Client *cptr, struct Client *sptr, + struct Gline *gline, enum GlineAction action, + char *reason, time_t expire, time_t lastmod, + time_t lifetime, unsigned int flags); +extern int gline_destroy(struct Client *cptr, struct Client *sptr, + struct Gline *gline); extern struct Gline *gline_find(char *userhost, unsigned int flags); extern struct Gline *gline_lookup(struct Client *cptr, unsigned int flags); extern void gline_free(struct Gline *gline); Index: ircd-ircdev/include/ircd_crypt.h diff -u ircd-ircdev/include/ircd_crypt.h:1.3 ircd-ircdev/include/ircd_crypt.h:1.4 --- ircd-ircdev/include/ircd_crypt.h:1.3 Thu Apr 19 15:53:46 2007 +++ ircd-ircdev/include/ircd_crypt.h Tue Dec 11 15:38:23 2007 @@ -20,7 +20,7 @@ */ /** @file * @brief Core password encryption and hashing APIs. - * @version $Id: ircd_crypt.h,v 1.3 2007/04/19 22:53:46 zolty Exp $ + * @version $Id: ircd_crypt.h,v 1.4 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_ircd_crypt_h #define INCLUDED_ircd_crypt_h @@ -37,7 +37,7 @@ char* crypt_token; /* what identifies a password string as belonging to this mechanism */ - int crypt_token_size; /* how long is the token */ + unsigned int crypt_token_size; /* how long is the token */ }; typedef struct crypt_mech_s crypt_mech_t; Index: ircd-ircdev/include/ircd_events.h diff -u ircd-ircdev/include/ircd_events.h:1.6 ircd-ircdev/include/ircd_events.h:1.7 --- ircd-ircdev/include/ircd_events.h:1.6 Sun Nov 11 13:53:05 2007 +++ ircd-ircdev/include/ircd_events.h Tue Dec 11 15:38:23 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Interface and public definitions for event loop. - * @version $Id: ircd_events.h,v 1.6 2007/11/11 21:53:05 zolty Exp $ + * @version $Id: ircd_events.h,v 1.7 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_ircd_events_h #define INCLUDED_ircd_events_h @@ -213,9 +213,9 @@ /** List of all event generators. */ struct Generators { - struct Socket* g_socket; /**< list of socket generators */ - struct Signal* g_signal; /**< list of signal generators */ - struct Timer* g_timer; /**< list of timer generators */ + struct GenHeader* g_socket; /**< list of socket generators */ + struct GenHeader* g_signal; /**< list of signal generators */ + struct GenHeader* g_timer; /**< list of timer generators */ }; /** Returns 1 if successfully initialized, 0 if not. @@ -295,7 +295,8 @@ void timer_chg(struct Timer* timer, enum TimerType type, time_t value); void timer_run(void); /** Retrieve the next timer's expiration time from Generators \a gen. */ -#define timer_next(gen) ((gen)->g_timer ? (gen)->g_timer->t_expire : 0) + +#define timer_next(gen) ((gen)->g_timer ? ((struct Timer*)(gen)->g_timer)->t_expire : 0) void signal_add(struct Signal* signal, EventCallBack call, void* data, int sig); Index: ircd-ircdev/include/ircd_features.h diff -u ircd-ircdev/include/ircd_features.h:1.21 ircd-ircdev/include/ircd_features.h:1.22 --- ircd-ircdev/include/ircd_features.h:1.21 Sun Nov 11 13:53:05 2007 +++ ircd-ircdev/include/ircd_features.h Tue Dec 11 15:38:23 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Public interfaces and declarations for dealing with configurable features. - * @version $Id: ircd_features.h,v 1.21 2007/11/11 21:53:05 zolty Exp $ + * @version $Id: ircd_features.h,v 1.22 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_features_h #define INCLUDED_features_h @@ -64,6 +64,7 @@ FEAT_LOCAL_CHANNELS, FEAT_TOPIC_BURST, FEAT_USER_GLIST, + FEAT_DISABLE_GLINES, /* features that probably should not be touched */ FEAT_KILLCHASETIMELIMIT, @@ -223,5 +224,6 @@ extern int feature_int(enum Feature feat); extern int feature_bool(enum Feature feat); extern const char *feature_str(enum Feature feat); +extern unsigned int feature_uint(enum Feature feat); #endif /* INCLUDED_features_h */ Index: ircd-ircdev/include/numeric.h diff -u ircd-ircdev/include/numeric.h:1.18 ircd-ircdev/include/numeric.h:1.19 --- ircd-ircdev/include/numeric.h:1.18 Sun Nov 11 13:53:05 2007 +++ ircd-ircdev/include/numeric.h Tue Dec 11 15:38:23 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Declarations of numeric replies and supporting functions. - * @version $Id: numeric.h,v 1.18 2007/11/11 21:53:05 zolty Exp $ + * @version $Id: numeric.h,v 1.19 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_numeric_h #define INCLUDED_numeric_h @@ -342,6 +342,7 @@ /* ERR_BADMASK 415 IRCnet extension */ #define ERR_QUERYTOOLONG 416 /* Undernet extension */ /* ERR_TOOMANYMATCHES 416 IRCnet extension */ +#define ERR_INPUTTOOLONG 417 /* ERR_LENGTHTRUNCATED 419 aircd */ #define ERR_UNKNOWNCOMMAND 421 Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.57 ircd-ircdev/include/patchlevel.h:1.58 --- ircd-ircdev/include/patchlevel.h:1.57 Sun Nov 11 13:53:05 2007 +++ ircd-ircdev/include/patchlevel.h Tue Dec 11 15:38:23 2007 @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: patchlevel.h,v 1.57 2007/11/11 21:53:05 zolty Exp $ + * $Id: patchlevel.h,v 1.58 2007/12/11 23:38:23 zolty Exp $ * */ -#define PATCHLEVEL "9" +#define PATCHLEVEL "10" #define RELEASE "1.0.beta" Index: ircd-ircdev/include/res.h diff -u ircd-ircdev/include/res.h:1.10 ircd-ircdev/include/res.h:1.11 --- ircd-ircdev/include/res.h:1.10 Thu Apr 26 12:17:31 2007 +++ ircd-ircdev/include/res.h Tue Dec 11 15:38:23 2007 @@ -22,7 +22,7 @@ */ /** @file * @brief IRC resolver API. - * @version $Id: res.h,v 1.10 2007/04/26 19:17:31 zolty Exp $ + * @version $Id: res.h,v 1.11 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_res_h @@ -150,7 +150,7 @@ && ((ADDR)->in6_16[5] == 0 \ || (ADDR)->in6_16[5] == 65535)) /** Evaluate to non-zero if \a ADDR is a valid address (not all 0s and not all 1s). */ -#define irc_in_addr_valid(ADDR) (((ADDR)->in6_16[0] && ~(ADDR)->in6_16[0]) \ +#define irc_in_addr_valid(ADDR) (((ADDR)->in6_16[0] && ((ADDR)->in6_16[0] != 65535)) \ || (ADDR)->in6_16[1] != (ADDR)->in6_16[0] \ || (ADDR)->in6_16[2] != (ADDR)->in6_16[0] \ || (ADDR)->in6_16[3] != (ADDR)->in6_16[0] \ @@ -160,8 +160,9 @@ || (ADDR)->in6_16[7] != (ADDR)->in6_16[0]) /** Evaluate to non-zero if \a ADDR (of type struct irc_in_addr) is an IPv4 address. */ #define irc_in_addr_is_ipv4(ADDR) (!(ADDR)->in6_16[0] && !(ADDR)->in6_16[1] && !(ADDR)->in6_16[2] \ - && !(ADDR)->in6_16[3] && !(ADDR)->in6_16[4] && (ADDR)->in6_16[6] \ - && (!(ADDR)->in6_16[5] || (ADDR)->in6_16[5] == 65535)) + && !(ADDR)->in6_16[3] && !(ADDR)->in6_16[4] \ + && ((!(ADDR)->in6_16[5] && (ADDR)->in6_16[6]) \ + || (ADDR)->in6_16[5] == 65535)) /** Evaluate to non-zero if \a A is a different IP than \a B. */ #define irc_in_addr_cmp(A,B) (irc_in_addr_is_ipv4(A) ? ((A)->in6_16[6] != (B)->in6_16[6] \ || (A)->in6_16[7] != (B)->in6_16[7] || !irc_in_addr_is_ipv4(B)) \ Index: ircd-ircdev/include/s_user.h diff -u ircd-ircdev/include/s_user.h:1.12 ircd-ircdev/include/s_user.h:1.13 --- ircd-ircdev/include/s_user.h:1.12 Thu Apr 26 12:17:31 2007 +++ ircd-ircdev/include/s_user.h Tue Dec 11 15:38:23 2007 @@ -21,7 +21,7 @@ */ /** @file s_user.h * @brief Miscellaneous user-related helper functions. - * @version $Id: s_user.h,v 1.12 2007/04/26 19:17:31 zolty Exp $ + * @version $Id: s_user.h,v 1.13 2007/12/11 23:38:23 zolty Exp $ */ #ifndef INCLUDED_s_user_h #define INCLUDED_s_user_h @@ -72,6 +72,10 @@ #define MATCH_SERVER 1 /**< flag for relay_masked_message (etc) to indicate the mask matches a server name */ #define MATCH_HOST 2 /**< flag for relay_masked_message (etc) to indicate the mask matches host name */ +/* used for parsing user modes */ +#define ALLOWMODES_ANY 0 /**< Allow any user mode */ +#define ALLOWMODES_DEFAULT 1 /**< Only allow the subset of modes that are legit defaults */ + /* used in set_nick_name */ #define NICK_EQUIVALENT 0x01 /** < Equivalent */ #define NICK_RENAMED 0x02 /** < Rename */ @@ -122,7 +126,7 @@ extern int hide_hostmask(struct Client *cptr, const char *vhost, unsigned int flags); extern int set_user_mode(struct Client *cptr, struct Client *sptr, - int parc, char *parv[]); + int parc, char *parv[], int allow_modes); extern int is_silenced(struct Client *sptr, struct Client *acptr); extern int hunt_server_cmd(struct Client *from, const char *cmd, const char *tok, struct Client *one, Index: ircd-ircdev/ircd/channel.c diff -u ircd-ircdev/ircd/channel.c:1.33 ircd-ircdev/ircd/channel.c:1.34 --- ircd-ircdev/ircd/channel.c:1.33 Thu Sep 20 14:00:31 2007 +++ ircd-ircdev/ircd/channel.c Tue Dec 11 15:38:23 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Channel management and maintanance - * @version $Id: channel.c,v 1.33 2007/09/20 21:00:31 zolty Exp $ + * @version $Id: channel.c,v 1.34 2007/12/11 23:38:23 zolty Exp $ */ #include "config.h" @@ -1429,8 +1429,8 @@ { struct Invite **uprev = &cli_user(cptr)->invited; struct Invite *inv; - int max = feature_int(FEAT_MAXCHANNELSPERUSER); - int count = 0; + unsigned int max = feature_uint(FEAT_MAXCHANNELSPERUSER); + unsigned int count = 0; /* See if the user is already invited. */ while ((inv = *uprev) != NULL) @@ -2344,8 +2344,8 @@ MODE_DELJOINS, 'D', 0x0, 0x0 }; - unsigned int add; - int i, bufpos = 0, len; + unsigned int add, i, len; + int bufpos = 0; int *flag_p; char *key = 0, limitbuf[20]; #if defined(UNDERNET) @@ -2407,9 +2407,10 @@ return; } -/** Simple function to invalidate bans +/** Simple function to invalidate a channel's ban cache. * - * This function sets all bans as being valid. + * This function marks all members of the channel as being neither + * banned nor banned. * * @param chan The channel to operate on. */ @@ -2438,13 +2439,16 @@ /* What we've done for mode_parse so far... */ #define DONE_LIMIT 0x01 /**< We've set the limit */ -#define DONE_KEY 0x02 /**< We've set the key */ +#define DONE_KEY_ADD 0x02 /**< We've set the key */ #define DONE_BANLIST 0x04 /**< We've sent the ban list */ #define DONE_NOTOPER 0x08 /**< We've sent a "Not oper" error */ #define DONE_BANCLEAN 0x10 /**< We've cleaned bans... */ +#define DONE_KEY_DEL 0x80 /**< We've removed the key */ #if defined(UNDERNET) -#define DONE_UPASS 0x20 /**< We've set user pass */ -#define DONE_APASS 0x40 /**< We've set admin pass */ +#define DONE_UPASS_ADD 0x20 /**< We've set user pass */ +#define DONE_APASS_ADD 0x40 /**< We've set admin pass */ +#define DONE_UPASS_DEL 0x100 /**< We've removed the user pass */ +#define DONE_APASS_DEL 0x200 /**< We've removed the admin pass */ #endif struct ParseState { @@ -2600,9 +2604,19 @@ return; } - if (state->done & DONE_KEY) /* allow key to be set only once */ - return; - state->done |= DONE_KEY; + /* allow removing and then adding key, but not adding and then removing */ + if (state->dir == MODE_ADD) + { + if (state->done & DONE_KEY_ADD) + return; + state->done |= DONE_KEY_ADD; + } + else + { + if (state->done & (DONE_KEY_ADD | DONE_KEY_DEL)) + return; + state->done |= DONE_KEY_DEL; + } /* clean up the key string */ clean_key(t_str); @@ -2703,9 +2717,19 @@ return; } - if (state->done & DONE_UPASS) /* allow upass to be set only once */ - return; - state->done |= DONE_UPASS; + /* allow removing and then adding upass, but not adding and then removing */ + if (state->dir == MODE_ADD) + { + if (state->done & DONE_UPASS_ADD) + return; + state->done |= DONE_UPASS_ADD; + } + else + { + if (state->done & (DONE_UPASS_ADD | DONE_UPASS_DEL)) + return; + state->done |= DONE_UPASS_DEL; + } /* clean up the upass string */ clean_key(t_str); @@ -2840,9 +2864,19 @@ } } - if (state->done & DONE_APASS) /* allow apass to be set only once */ - return; - state->done |= DONE_APASS; + /* allow removing and then adding apass, but not adding and then removing */ + if (state->dir == MODE_ADD) + { + if (state->done & DONE_APASS_ADD) + return; + state->done |= DONE_APASS_ADD; + } + else + { + if (state->done & (DONE_APASS_ADD | DONE_APASS_DEL)) + return; + state->done |= DONE_APASS_DEL; + } /* clean up the apass string */ clean_key(t_str); @@ -2975,9 +3009,9 @@ assert(newban->flags & (BAN_ADD|BAN_DEL)); if (newban->flags & BAN_ADD) { size_t totlen = 0; - /* If a less specific entry is found, fail. */ + /* If a less specific *active* entry is found, fail. */ for (ban = *banlist; ban; ban = ban->next) { - if (!bmatch(ban, newban)) { + if (!bmatch(ban, newban) && !(ban->flags & BAN_DEL)) { if (do_free) free_ban(newban); return 1; @@ -3668,14 +3702,14 @@ if (state.chptr->mode.limit && !(state.done & DONE_LIMIT)) modebuf_mode_uint(state.mbuf, MODE_DEL | MODE_LIMIT, state.chptr->mode.limit); - if (*state.chptr->mode.key && !(state.done & DONE_KEY)) + if (*state.chptr->mode.key && !(state.done & DONE_KEY_DEL)) modebuf_mode_string(state.mbuf, MODE_DEL | MODE_KEY, state.chptr->mode.key, 0); #if defined(UNDERNET) - if (*state.chptr->mode.upass && !(state.done & DONE_UPASS)) + if (*state.chptr->mode.upass && !(state.done & DONE_UPASS_DEL)) modebuf_mode_string(state.mbuf, MODE_DEL | MODE_UPASS, state.chptr->mode.upass, 0); - if (*state.chptr->mode.apass && !(state.done & DONE_APASS)) + if (*state.chptr->mode.apass && !(state.done & DONE_APASS_DEL)) modebuf_mode_string(state.mbuf, MODE_DEL | MODE_APASS, state.chptr->mode.apass, 0); #endif @@ -3856,7 +3890,7 @@ { char chanlist[BUFSIZE]; int chanlist_i = 0; - int i; + unsigned int i; if (!jbuf->jb_count || jbuf->jb_type == JOINBUF_TYPE_PARTALL || jbuf->jb_type == JOINBUF_TYPE_JOIN) Index: ircd-ircdev/ircd/class.c diff -u ircd-ircdev/ircd/class.c:1.13 ircd-ircdev/ircd/class.c:1.14 --- ircd-ircdev/ircd/class.c:1.13 Thu Apr 19 15:53:47 2007 +++ ircd-ircdev/ircd/class.c Tue Dec 11 15:38:24 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of connection class handling functions. - * @version $Id: class.c,v 1.13 2007/04/19 22:53:47 zolty Exp $ + * @version $Id: class.c,v 1.14 2007/12/11 23:38:24 zolty Exp $ */ #include "config.h" @@ -106,7 +106,7 @@ 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); + MaxSendq(connClassList) = feature_uint(FEAT_DEFAULTMAXSENDQLENGTH); connClassList->valid = 1; Links(connClassList) = 1; } @@ -229,7 +229,7 @@ PingFreq(p) = ping; MaxLinks(p) = maxli; MaxSendq(p) = (sendq > 0U) ? - sendq : feature_int(FEAT_DEFAULTMAXSENDQLENGTH); + sendq : feature_uint(FEAT_DEFAULTMAXSENDQLENGTH); p->valid = 1; } @@ -294,7 +294,7 @@ } } } - return feature_int(FEAT_DEFAULTMAXSENDQLENGTH); + return feature_uint(FEAT_DEFAULTMAXSENDQLENGTH); } /** Report connection class memory statistics to a client. Index: ircd-ircdev/ircd/dbuf.c diff -u ircd-ircdev/ircd/dbuf.c:1.6 ircd-ircdev/ircd/dbuf.c:1.7 --- ircd-ircdev/ircd/dbuf.c:1.6 Thu Apr 19 15:53:47 2007 +++ ircd-ircdev/ircd/dbuf.c Tue Dec 11 15:38:24 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of functions dealing with data buffers. - * @version $Id: dbuf.c,v 1.6 2007/04/19 22:53:47 zolty Exp $ + * @version $Id: dbuf.c,v 1.7 2007/12/11 23:38:24 zolty Exp $ */ #include "config.h" @@ -47,11 +47,11 @@ /** Number of dbufs allocated. * This should only be modified by dbuf.c. */ -int DBufAllocCount = 0; +unsigned int DBufAllocCount = 0; /** Number of dbufs in use. * This should only be modified by dbuf.c. */ -int DBufUsedCount = 0; +unsigned int DBufUsedCount = 0; /** List of allocated but unused DBuf structures. */ static struct DBufBuffer *dbufFreeList = 0; @@ -92,7 +92,7 @@ dbufFreeList = db->next; ++DBufUsedCount; } - else if (DBufAllocCount * DBUF_SIZE < feature_int(FEAT_BUFFERPOOL)) { + else if (DBufAllocCount * DBUF_SIZE < feature_uint(FEAT_BUFFERPOOL)) { db = (struct DBufBuffer*) MyMalloc(sizeof(struct DBufBuffer)); assert(0 != db); ++DBufAllocCount; Index: ircd-ircdev/ircd/engine_poll.c diff -u ircd-ircdev/ircd/engine_poll.c:1.6 ircd-ircdev/ircd/engine_poll.c:1.7 --- ircd-ircdev/ircd/engine_poll.c:1.6 Thu Apr 19 15:53:47 2007 +++ ircd-ircdev/ircd/engine_poll.c Tue Dec 11 15:38:24 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief POSIX poll() event engine. - * @version $Id: engine_poll.c,v 1.6 2007/04/19 22:53:47 zolty Exp $ + * @version $Id: engine_poll.c,v 1.7 2007/12/11 23:38:24 zolty Exp $ */ #include "config.h" @@ -171,7 +171,7 @@ static int engine_add(struct Socket* sock) { - int i; + unsigned int i; assert(0 != sock); @@ -279,7 +279,7 @@ { int wait; int nfds; - int i; + unsigned int i; int errcode; socklen_t codesize; struct Socket *sock; Index: ircd-ircdev/ircd/gline.c diff -u ircd-ircdev/ircd/gline.c:1.21 ircd-ircdev/ircd/gline.c:1.22 --- ircd-ircdev/ircd/gline.c:1.21 Thu Sep 20 14:00:31 2007 +++ ircd-ircdev/ircd/gline.c Tue Dec 11 15:38:24 2007 @@ -23,7 +23,7 @@ */ /** @file * @brief Implementation of Gline manipulation functions. - * @version $Id: gline.c,v 1.21 2007/09/20 21:00:31 zolty Exp $ + * @version $Id: gline.c,v 1.22 2007/12/11 23:38:24 zolty Exp $ */ #include "config.h" @@ -71,6 +71,34 @@ /** List of BadChan G-lines. */ static struct Gline* BadChanGlineList = 0; +/** Iterate through \a list of G-lines. Use this like a for loop, + * i.e., follow it with braces and use whatever you passed as \a gl + * as a single G-line to be acted upon. + * + * @param[in] list List of G-lines to iterate over. + * @param[in] gl Name of a struct Gline pointer variable that will be made to point to the G-lines in sequence. + * @param[in] next Name of a scratch struct Gline pointer variable. + */ +/* There is some subtlety here with the boolean operators: + * (x || 1) is used to continue in a logical-and series even when !x. + * (x && 0) is used to continue in a logical-or series even when x. + */ +#define gliter(list, gl, next) \ + /* Iterate through the G-lines in the list */ \ + for ((gl) = (list); (gl); (gl) = (next)) \ + /* Figure out the next pointer in list... */ \ + if ((((next) = (gl)->gl_next) || 1) && \ + /* Then see if it's expired */ \ + (gl)->gl_lifetime <= CurrentTime) \ + /* Record has expired, so free the G-line */ \ + gline_free((gl)); \ + /* See if we need to expire the G-line */ \ + else if ((((gl)->gl_expire > CurrentTime) || \ + (((gl)->gl_flags &= ~GLINE_ACTIVE) && 0) || \ + ((gl)->gl_state = GLOCAL_GLOBAL)) && 0) \ + ; /* empty statement */ \ + else + /** Count number of users who match \a mask. * @param[in] mask user\@host or user\@ip mask to check. * @return Count of matching users. @@ -99,6 +127,31 @@ return count; } +/** Count number of users with a realname matching \a mask. + * @param[in] mask Wildcard mask to match against realnames. + * @return Count of matching users. + */ +static int +count_realnames(const char *mask) +{ + struct Client *acptr; + int minlen; + int count; + char cmask[BUFSIZE]; + + count = 0; + matchcomp(cmask, &minlen, NULL, mask); + for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) { + if (!IsUser(acptr)) + continue; + if (strlen(cli_info(acptr)) < (unsigned int)minlen) + continue; + if (!matchexec(cli_info(acptr), cmask, minlen)) + count++; + } + return count; +} + /** Find canonical user and host for a string. * If \a userhost starts with '$', assign \a userhost to *user_p and NULL to *host_p. * Otherwise, if \a userhost contains '@', assign the earlier part of it to *user_p and the rest to *host_p. @@ -141,44 +194,23 @@ */ static struct Gline * make_gline(char *user, char *host, char *reason, time_t expire, time_t lastmod, - unsigned int flags) + time_t lifetime, unsigned int flags) { - struct Gline *gline, *sgline, *after = 0; - - if (!(flags & GLINE_BADCHAN)) { /* search for overlapping glines first */ - - for (gline = GlobalGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) - gline_free(gline); - else if (((gline->gl_flags & GLINE_LOCAL) != (flags & GLINE_LOCAL)) || - (gline->gl_host && !host) || (!gline->gl_host && host)) - continue; - else if (!mmatch(gline->gl_user, user) /* gline contains new mask */ - && (gline->gl_host == NULL || !mmatch(gline->gl_host, host))) { - if (expire <= gline->gl_expire) /* will expire before wider gline */ - return 0; - else - after = gline; /* stick new gline after this one */ - } else if (!mmatch(user, gline->gl_user) /* new mask contains gline */ - && (gline->gl_host==NULL || !mmatch(host, gline->gl_host)) - && gline->gl_expire <= expire) /* old expires before new */ - gline_free(gline); /* save some memory */ - } - } + struct Gline *gline; gline = (struct Gline *)MyMalloc(sizeof(struct Gline)); /* alloc memory */ assert(0 != gline); DupString(gline->gl_reason, reason); /* initialize gline... */ gline->gl_expire = expire; + gline->gl_lifetime = lifetime; gline->gl_lastmod = lastmod; gline->gl_flags = flags & GLINE_MASK; + gline->gl_state = GLOCAL_GLOBAL; /* not locally modified */ if (flags & GLINE_BADCHAN) { /* set a BADCHAN gline */ DupString(gline->gl_user, user); /* first, remember channel */ - gline->gl_host = 0; + gline->gl_host = NULL; gline->gl_next = BadChanGlineList; /* then link it into list */ gline->gl_prev_p = &BadChanGlineList; @@ -195,19 +227,11 @@ if (*user != '$' && ipmask_parse(host, &gline->gl_addr, &gline->gl_bits)) gline->gl_flags |= GLINE_IPMASK; - if (after) { - gline->gl_next = after->gl_next; - gline->gl_prev_p = &after->gl_next; - if (after->gl_next) - after->gl_next->gl_prev_p = &gline->gl_next; - after->gl_next = gline; - } else { - gline->gl_next = GlobalGlineList; /* then link it into list */ - gline->gl_prev_p = &GlobalGlineList; - if (GlobalGlineList) - GlobalGlineList->gl_prev_p = &gline->gl_next; - GlobalGlineList = gline; - } + gline->gl_next = GlobalGlineList; /* then link it into list */ + gline->gl_prev_p = &GlobalGlineList; + if (GlobalGlineList) + GlobalGlineList->gl_prev_p = &gline->gl_next; + GlobalGlineList = gline; } return gline; @@ -227,6 +251,9 @@ struct Client *acptr; int fd, retval = 0, tval; + if (feature_bool(FEAT_DISABLE_GLINES)) + return 0; /* G-lines are disabled */ + if (GlineIsBadChan(gline)) /* no action taken on badchan glines */ return 0; if (!GlineIsActive(gline)) /* no action taken on inactive glines */ @@ -359,24 +386,17 @@ int gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline) { - if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod)) + if (GlineIsLocal(gline)) return 0; - if (gline->gl_lastmod) - sendcmdto_serv(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s", - GlineIsRemActive(gline) ? '+' : '-', gline->gl_user, - gline->gl_host ? "@" : "", - gline->gl_host ? gline->gl_host : "", - gline->gl_expire - CurrentTime, gline->gl_lastmod, - gline->gl_reason); - else - sendcmdto_serv(sptr, CMD_GLINE, cptr, - (GlineIsRemActive(gline) ? - "* +%s%s%s %Tu :%s" : "* -%s%s%s"), - gline->gl_user, - gline->gl_host ? "@" : "", - gline->gl_host ? gline->gl_host : "", - gline->gl_expire - CurrentTime, gline->gl_reason); + assert(gline->gl_lastmod); + + sendcmdto_serv(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s", + GlineIsRemActive(gline) ? '+' : '-', gline->gl_user, + gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : "", + gline->gl_expire - CurrentTime, gline->gl_lastmod, + gline->gl_lifetime, gline->gl_reason); return 0; } @@ -392,14 +412,16 @@ * @param[in] sptr Client that originated the G-line. * @param[in] userhost Text mask for the G-line. * @param[in] reason Reason for G-line. - * @param[in] expire Duration of G-line in seconds. + * @param[in] expire Expiration time of G-line. * @param[in] lastmod Last modification time of G-line. + * @param[in] lifetime Lifetime of G-line. * @param[in] flags Bitwise combination of GLINE_* flags. * @return Zero or CPTR_KILLED, depending on whether \a sptr is suicidal. */ int gline_add(struct Client *cptr, struct Client *sptr, char *userhost, - char *reason, time_t expire, time_t lastmod, unsigned int flags) + char *reason, time_t expire, time_t lastmod, time_t lifetime, + unsigned int flags) { struct Gline *agline; char uhmask[USERLEN + HOSTLEN + 2]; @@ -409,15 +431,19 @@ assert(0 != userhost); assert(0 != reason); + Debug((DEBUG_DEBUG, "gline_add(\"%s\", \"%s\", \"%s\", \"%s\", %Tu, %Tu " + "%Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), userhost, reason, + expire, lastmod, lifetime, flags)); + if (*userhost == '#' || *userhost == '&') { if ((flags & GLINE_LOCAL) && !HasPriv(sptr, PRIV_LOCAL_BADCHAN)) return send_reply(sptr, ERR_NOPRIVILEGES); flags |= GLINE_BADCHAN; user = userhost; - host = 0; + host = NULL; } else if (*userhost == '$') { - switch (*userhost == '$' ? userhost[1] : userhost[3]) { + switch (userhost[1]) { case 'R': flags |= GLINE_REALNAME; break; default: /* uh, what to do here? */ @@ -425,18 +451,21 @@ -- hikari */ if (IsServer(cptr)) return protocol_violation(sptr,"%s has been smoking the sweet leaf and sent me a whacky gline",cli_name(sptr)); - else { - sendto_opmask(NULL, SNO_GLINE, "%s has been smoking the sweet leaf and sent me a whacky gline", cli_name(sptr)); - return 0; - } - break; + sendto_opmask(NULL, SNO_GLINE, "%s has been smoking the sweet leaf and sent me a whacky gline", cli_name(sptr)); + return 0; + } + user = userhost; + host = NULL; + if (MyUser(sptr) || (IsUser(sptr) && flags & GLINE_LOCAL)) { + tmp = count_realnames(userhost + 2); + if ((tmp >= feature_int(FEAT_GLINEMAXUSERCOUNT)) + && !(flags & GLINE_OPERFORCE)) + return send_reply(sptr, ERR_TOOMANYUSERS, tmp); } - user = (*userhost =='$' ? userhost : userhost+2); - host = 0; } else { canon_userhost(userhost, &user, &host, "*"); if (sizeof(uhmask) < - ircd_snprintf(0, uhmask, sizeof(uhmask), "%s@%s", user, host)) + (unsigned int)ircd_snprintf(0, uhmask, sizeof(uhmask), "%s@%s", user, host)) return send_reply(sptr, ERR_LONGMASK); else if (MyUser(sptr) || (IsUser(sptr) && flags & GLINE_LOCAL)) { switch (gline_checkmask(host)) { @@ -459,13 +488,17 @@ * You cannot set a negative (or zero) expire time, nor can you set an * expiration time for greater than GLINE_MAX_EXPIRE. */ - if (!(flags & GLINE_FORCE) && (expire <= 0 || expire > GLINE_MAX_EXPIRE)) { + if (!(flags & GLINE_FORCE) && + (expire <= CurrentTime || expire > CurrentTime + GLINE_MAX_EXPIRE)) { if (!IsServer(sptr) && MyConnect(sptr)) send_reply(sptr, ERR_BADEXPIRE, expire); return 0; } - expire += CurrentTime; /* convert from lifetime to timestamp */ + if (!lifetime) /* no lifetime set, use expiration time */ + lifetime = expire; + + /* lifetime is already an absolute timestamp */ /* Inform ops... */ sendto_opmask(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE : @@ -488,10 +521,12 @@ expire + TSoffset, reason); /* make the gline */ - agline = make_gline(user, host, reason, expire, lastmod, flags); + agline = make_gline(user, host, reason, expire, lastmod, lifetime, flags); - if (!agline) /* if it overlapped, silently return */ - return 0; + /* since we've disabled overlapped G-line checking, agline should + * never be NULL... + */ + assert(agline); gline_propagate(cptr, sptr, agline); @@ -625,12 +660,243 @@ return 0; } +/** Modify a global G-line. + * @param[in] cptr Client that sent us the G-line modification. + * @param[in] sptr Client that originated the G-line modification. + * @param[in] gline G-line being modified. + * @param[in] action Resultant status of the G-line. + * @param[in] reason Reason for G-line. + * @param[in] expire Expiration time of G-line. + * @param[in] lastmod Last modification time of G-line. + * @param[in] lifetime Lifetime of G-line. + * @param[in] flags Bitwise combination of GLINE_* flags. + * @return Zero or CPTR_KILLED, depending on whether \a sptr is suicidal. + */ +int +gline_modify(struct Client *cptr, struct Client *sptr, struct Gline *gline, + enum GlineAction action, char *reason, time_t expire, + time_t lastmod, time_t lifetime, unsigned int flags) +{ + char buf[BUFSIZE], *op = ""; + int pos = 0; + + assert(gline); + assert(!GlineIsLocal(gline)); + + Debug((DEBUG_DEBUG, "gline_modify(\"%s\", \"%s\", \"%s%s%s\", %s, \"%s\", " + "%Tu, %Tu, %Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), + gline->gl_user, gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : "", + action == GLINE_ACTIVATE ? "GLINE_ACTIVATE" : + (action == GLINE_DEACTIVATE ? "GLINE_DEACTIVATE" : + (action == GLINE_LOCAL_ACTIVATE ? "GLINE_LOCAL_ACTIVATE" : + (action == GLINE_LOCAL_DEACTIVATE ? "GLINE_LOCAL_DEACTIVATE" : + (action == GLINE_MODIFY ? "GLINE_MODIFY" : "<UNKNOWN>")))), + reason, expire, lastmod, lifetime, flags)); + + /* First, let's check lastmod... */ + if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE) { + if (GlineLastMod(gline) > lastmod) { /* we have a more recent version */ + if (IsBurstOrBurstAck(cptr)) + return 0; /* middle of a burst, it'll resync on its own */ + return gline_resend(cptr, gline); /* resync the server */ + } else if (GlineLastMod(gline) == lastmod) + return 0; /* we have that version of the G-line... */ + } + + /* All right, we know that there's a change of some sort. What is it? */ + /* first, check out the expiration time... */ + if ((flags & GLINE_EXPIRE) && expire) { + if (!(flags & GLINE_FORCE) && + (expire <= CurrentTime || expire > CurrentTime + GLINE_MAX_EXPIRE)) { + if (!IsServer(sptr) && MyConnect(sptr)) /* bad expiration time */ + send_reply(sptr, ERR_BADEXPIRE, expire); + return 0; + } + } else + flags &= ~GLINE_EXPIRE; + + /* Now check to see if there's any change... */ + if ((flags & GLINE_EXPIRE) && expire == gline->gl_expire) { + flags &= ~GLINE_EXPIRE; /* no change to expiration time... */ + expire = 0; + } + + /* Next, check out lifetime--this one's a bit trickier... */ + if (!(flags & GLINE_LIFETIME) || !lifetime) + lifetime = gline->gl_lifetime; /* use G-line lifetime */ + + lifetime = IRCD_MAX(lifetime, expire); /* set lifetime to the max */ + + /* OK, let's see which is greater... */ + if (lifetime > gline->gl_lifetime) + flags |= GLINE_LIFETIME; /* have to update lifetime */ + else { + flags &= ~GLINE_LIFETIME; /* no change to lifetime */ + lifetime = 0; + } + + /* Finally, let's see if the reason needs to be updated */ + if ((flags & GLINE_REASON) && reason && + !ircd_strcmp(gline->gl_reason, reason)) + flags &= ~GLINE_REASON; /* no changes to the reason */ + + /* OK, now let's take a look at the action... */ + if ((action == GLINE_ACTIVATE && (gline->gl_flags & GLINE_ACTIVE)) || + (action == GLINE_DEACTIVATE && !(gline->gl_flags & GLINE_ACTIVE)) || + (action == GLINE_LOCAL_ACTIVATE && + (gline->gl_state == GLOCAL_ACTIVATED)) || + (action == GLINE_LOCAL_DEACTIVATE && + (gline->gl_state == GLOCAL_DEACTIVATED)) || + /* can't activate an expired G-line */ + IRCD_MAX(gline->gl_expire, expire) <= CurrentTime) + action = GLINE_MODIFY; /* no activity state modifications */ + + Debug((DEBUG_DEBUG, "About to perform changes; flags 0x%04x, action %s", + flags, action == GLINE_ACTIVATE ? "GLINE_ACTIVATE" : + (action == GLINE_DEACTIVATE ? "GLINE_DEACTIVATE" : + (action == GLINE_LOCAL_ACTIVATE ? "GLINE_LOCAL_ACTIVATE" : + (action == GLINE_LOCAL_DEACTIVATE ? "GLINE_LOCAL_DEACTIVATE" : + (action == GLINE_MODIFY ? "GLINE_MODIFY" : "<UNKNOWN>")))))); + + /* If there are no changes to perform, do no changes */ + if (!(flags & GLINE_UPDATE) && action == GLINE_MODIFY) + return 0; + + /* Now we know what needs to be changed, so let's process the changes... */ + + /* Start by updating lastmod, if indicated... */ + if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE) + gline->gl_lastmod = lastmod; + + /* Then move on to activity status changes... */ + switch (action) { + case GLINE_ACTIVATE: /* Globally activating G-line */ + gline->gl_flags |= GLINE_ACTIVE; /* make it active... */ + gline->gl_state = GLOCAL_GLOBAL; /* reset local activity state */ + pos += ircd_snprintf(0, buf, sizeof(buf), " globally activating G-line"); + op = "+"; /* operation for G-line propagation */ + break; + + case GLINE_DEACTIVATE: /* Globally deactivating G-line */ + gline->gl_flags &= ~GLINE_ACTIVE; /* make it inactive... */ + gline->gl_state = GLOCAL_GLOBAL; /* reset local activity state */ + pos += ircd_snprintf(0, buf, sizeof(buf), " globally deactivating G-line"); + op = "-"; /* operation for G-line propagation */ + break; + + case GLINE_LOCAL_ACTIVATE: /* Locally activating G-line */ + gline->gl_state = GLOCAL_ACTIVATED; /* make it locally active */ + pos += ircd_snprintf(0, buf, sizeof(buf), " locally activating G-line"); + break; + + case GLINE_LOCAL_DEACTIVATE: /* Locally deactivating G-line */ + gline->gl_state = GLOCAL_DEACTIVATED; /* make it locally inactive */ + pos += ircd_snprintf(0, buf, sizeof(buf), " locally deactivating G-line"); + break; + + case GLINE_MODIFY: /* no change to activity status */ + break; + } + + /* Handle expiration changes... */ + if (flags & GLINE_EXPIRE) { + gline->gl_expire = expire; /* save new expiration time */ + if (pos < BUFSIZE) + pos += ircd_snprintf(0, buf + pos, sizeof(buf) - pos, + "%s%s changing expiration time to %Tu", + pos ? ";" : "", + pos && !(flags & (GLINE_LIFETIME | GLINE_REASON)) ? + " and" : "", expire); + } + + /* Next, handle lifetime changes... */ + if (flags & GLINE_LIFETIME) { + gline->gl_lifetime = lifetime; /* save new lifetime */ + if (pos < BUFSIZE) + pos += ircd_snprintf(0, buf + pos, sizeof(buf) - pos, + "%s%s extending record lifetime to %Tu", + pos ? ";" : "", pos && !(flags & GLINE_REASON) ? + " and" : "", lifetime); + } + + /* Now, handle reason changes... */ + if (flags & GLINE_REASON) { + MyFree(gline->gl_reason); /* release old reason */ + DupString(gline->gl_reason, reason); /* store new reason */ + if (pos < BUFSIZE) + pos += ircd_snprintf(0, buf + pos, sizeof(buf) - pos, + "%s%s changing reason to \"%s\"", + pos ? ";" : "", pos ? " and" : "", reason); + } + + /* All right, inform ops... */ + sendto_opmask(0, SNO_GLINE, "%s modifying global %s for %s%s%s:%s", + (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ? + cli_name(sptr) : cli_name((cli_user(sptr))->server), + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", + gline->gl_user, gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : "", buf); + + /* and log the change */ + log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE, + "%#C modifying global %s for %s%s%s:%s", sptr, + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user, + gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "", + buf); + + /* We'll be simple for this release, but we can update this to change + * the propagation syntax on future updates + */ + if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE) + sendcmdto_serv(sptr, CMD_GLINE, cptr, + "* %s%s%s%s%s %Tu %Tu %Tu :%s", + flags & GLINE_OPERFORCE ? "!" : "", op, + gline->gl_user, gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : "", + gline->gl_expire - CurrentTime, gline->gl_lastmod, + gline->gl_lifetime, gline->gl_reason); + + /* OK, let's do the G-line... */ + return do_gline(cptr, sptr, gline); +} + +/** Destroy a local G-line. + * @param[in] cptr Peer that gave us the message. + * @param[in] sptr Client that initiated the destruction. + * @param[in] gline G-line to destroy. + * @return Zero. + */ +int +gline_destroy(struct Client *cptr, struct Client *sptr, struct Gline *gline) +{ + assert(gline); + assert(GlineIsLocal(gline)); + + /* Inform ops and log it */ + sendto_opmask(0, SNO_GLINE, "%s removing local %s for %s%s%s", + (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ? + cli_name(sptr) : cli_name((cli_user(sptr))->server), + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", + gline->gl_user, gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : ""); + log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE, + "%#C removing local %s for %s%s%s", sptr, + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user, + gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : ""); + + gline_free(gline); /* get rid of the G-line */ + + return 0; /* convenience return */ +} + /** Find a G-line for a particular mask, guided by certain flags. * Certain bits in \a flags are interpreted specially: * <dl> * <dt>GLINE_ANY</dt><dd>Search both BadChans and user G-lines.</dd> * <dt>GLINE_BADCHAN</dt><dd>Search BadChans.</dd> * <dt>GLINE_GLOBAL</dt><dd>Only match global G-lines.</dd> + * <dt>GLINE_LOCAL</dt><dd>Only match local G-lines.</dd> * <dt>GLINE_LASTMOD</dt><dd>Only match G-lines with a last modification time.</dd> * <dt>GLINE_EXACT</dt><dd>Require an exact match of G-line mask.</dd> * <dt>anything else</dt><dd>Search user G-lines.</dd> @@ -642,18 +908,15 @@ struct Gline * gline_find(char *userhost, unsigned int flags) { - struct Gline *gline; + struct Gline *gline = 0; struct Gline *sgline; char *user, *host, *t_uh; if (flags & (GLINE_BADCHAN | GLINE_ANY)) { - for (gline = BadChanGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) - gline_free(gline); - else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) || - (flags & GLINE_LASTMOD && !gline->gl_lastmod)) + gliter(BadChanGlineList, gline, sgline) { + if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) || + (flags & GLINE_LOCAL && gline->gl_flags & GLINE_GLOBAL) || + (flags & GLINE_LASTMOD && !gline->gl_lastmod)) continue; else if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) : match(gline->gl_user, userhost)) == 0) @@ -668,13 +931,10 @@ DupString(t_uh, userhost); canon_userhost(t_uh, &user, &host, "*"); - for (gline = GlobalGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) - gline_free(gline); - else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) || - (flags & GLINE_LASTMOD && !gline->gl_lastmod)) + gliter(GlobalGlineList, gline, sgline) { + if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) || + (flags & GLINE_LOCAL && gline->gl_flags & GLINE_GLOBAL) || + (flags & GLINE_LASTMOD && !gline->gl_lastmod)) continue; else if (flags & GLINE_EXACT) { if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0) @@ -685,7 +945,7 @@ if (((gline->gl_host && host && match(gline->gl_host, host) == 0) || (!gline->gl_host && !host)) && (match(gline->gl_user, user) == 0)) - break; + break; } } @@ -706,14 +966,7 @@ struct Gline *gline; struct Gline *sgline; - for (gline = GlobalGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) { - gline_free(gline); - continue; - } - + gliter(GlobalGlineList, gline, sgline) { if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) || (flags & GLINE_LASTMOD && !gline->gl_lastmod)) continue; @@ -773,30 +1026,22 @@ struct Gline *gline; struct Gline *sgline; - for (gline = GlobalGlineList; gline; gline = sgline) { /* all glines */ - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */ - gline_free(gline); - else if (!GlineIsLocal(gline) && gline->gl_lastmod) - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s", + gliter(GlobalGlineList, gline, sgline) { + if (!GlineIsLocal(gline) && gline->gl_lastmod) + sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s", GlineIsRemActive(gline) ? '+' : '-', gline->gl_user, gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "", gline->gl_expire - CurrentTime, gline->gl_lastmod, - gline->gl_reason); + gline->gl_lifetime, gline->gl_reason); } - for (gline = BadChanGlineList; gline; gline = sgline) { /* all glines */ - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */ - gline_free(gline); - else if (!GlineIsLocal(gline) && gline->gl_lastmod) - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s", + gliter(BadChanGlineList, gline, sgline) { + if (!GlineIsLocal(gline) && gline->gl_lastmod) + sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu %Tu :%s", GlineIsRemActive(gline) ? '+' : '-', gline->gl_user, gline->gl_expire - CurrentTime, gline->gl_lastmod, - gline->gl_reason); + gline->gl_lifetime, gline->gl_reason); } } @@ -811,12 +1056,12 @@ if (GlineIsLocal(gline) || !gline->gl_lastmod) return 0; - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s", + sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s", GlineIsRemActive(gline) ? '+' : '-', gline->gl_user, gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "", gline->gl_expire - CurrentTime, gline->gl_lastmod, - gline->gl_reason); + gline->gl_lifetime, gline->gl_reason); return 0; } @@ -842,34 +1087,33 @@ send_reply(sptr, RPL_GLIST, gline->gl_user, gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "", - gline->gl_expire + TSoffset, + gline->gl_expire + TSoffset, gline->gl_lastmod, + gline->gl_lifetime + TSoffset, GlineIsLocal(gline) ? cli_name(&me) : "*", - GlineIsActive(gline) ? '+' : '-', gline->gl_reason); + gline->gl_state == GLOCAL_ACTIVATED ? ">" : + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""), + GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason); } else { - for (gline = GlobalGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) - gline_free(gline); - else - send_reply(sptr, RPL_GLIST, gline->gl_user, - gline->gl_host ? "@" : "", - gline->gl_host ? gline->gl_host : "", - gline->gl_expire + TSoffset, - GlineIsLocal(gline) ? cli_name(&me) : "*", - GlineIsActive(gline) ? '+' : '-', gline->gl_reason); + gliter(GlobalGlineList, gline, sgline) { + send_reply(sptr, RPL_GLIST, gline->gl_user, + gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : "", + gline->gl_expire + TSoffset, gline->gl_lastmod, + gline->gl_lifetime + TSoffset, + GlineIsLocal(gline) ? cli_name(&me) : "*", + gline->gl_state == GLOCAL_ACTIVATED ? ">" : + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""), + GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason); } - for (gline = BadChanGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) - gline_free(gline); - else - send_reply(sptr, RPL_GLIST, gline->gl_user, "", "", - gline->gl_expire + TSoffset, - GlineIsLocal(gline) ? cli_name(&me) : "*", - GlineIsActive(gline) ? '+' : '-', gline->gl_reason); + gliter(BadChanGlineList, gline, sgline) { + send_reply(sptr, RPL_GLIST, gline->gl_user, "", "", + gline->gl_expire + TSoffset, gline->gl_lastmod, + gline->gl_lifetime + TSoffset, + GlineIsLocal(gline) ? cli_name(&me) : "*", + gline->gl_state == GLOCAL_ACTIVATED ? ">" : + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""), + GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason); } } @@ -889,18 +1133,16 @@ struct Gline *gline; struct Gline *sgline; - for (gline = GlobalGlineList; gline; gline = sgline) { - sgline = gline->gl_next; - - if (gline->gl_expire <= CurrentTime) - gline_free(gline); - else - send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, - gline->gl_host ? "@" : "", - gline->gl_host ? gline->gl_host : "", - gline->gl_expire + TSoffset, - GlineIsActive(gline) ? '+' : '-', - gline->gl_reason); + gliter(GlobalGlineList, gline, sgline) { + send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, + gline->gl_host ? "@" : "", + gline->gl_host ? gline->gl_host : "", + gline->gl_expire + TSoffset, gline->gl_lastmod, + gline->gl_lifetime + TSoffset, + gline->gl_state == GLOCAL_ACTIVATED ? ">" : + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""), + GlineIsRemActive(gline) ? '+' : '-', + gline->gl_reason); } } @@ -914,13 +1156,21 @@ struct Gline *gline; unsigned int gl = 0; - for (gline = GlobalGlineList; gline; gline = gline->gl_next) - { + for (gline = GlobalGlineList; gline; gline = gline->gl_next) { gl++; *gl_size += sizeof(struct Gline); *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0; *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0; *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0; } + + for (gline = BadChanGlineList; gline; gline = gline->gl_next) { + gl++; + *gl_size += sizeof(struct Gline); + *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0; + *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0; + *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0; + } + return gl; } Index: ircd-ircdev/ircd/hash.c diff -u ircd-ircdev/ircd/hash.c:1.15 ircd-ircdev/ircd/hash.c:1.16 --- ircd-ircdev/ircd/hash.c:1.15 Thu Sep 20 14:00:31 2007 +++ ircd-ircdev/ircd/hash.c Tue Dec 11 15:38:24 2007 @@ -22,7 +22,7 @@ */ /** @file * @brief Hash table management. - * @version $Id: hash.c,v 1.15 2007/09/20 21:00:31 zolty Exp $ + * @version $Id: hash.c,v 1.16 2007/12/11 23:38:24 zolty Exp $ * * This file used to use some very complicated hash function. Now it * uses CRC-32, but effectively remaps each input byte according to a @@ -523,7 +523,17 @@ && ((args->flags & LISTARG_SHOWSECRET) || ShowChannel(cptr, chptr))) { - send_reply(cptr, RPL_LIST, chptr->chname, chptr->users, chptr->topic); + if (args->flags & LISTARG_SHOWMODES) { + char modebuf[MODEBUFLEN]; + char parabuf[MODEBUFLEN]; + + modebuf[0] = modebuf[1] = parabuf[0] = '\0'; + channel_modes(cptr, modebuf, parabuf, sizeof(parabuf), chptr, NULL); + send_reply(cptr, RPL_LIST | SND_EXPLICIT, "%s %u %s %s :%s", + chptr->chname, chptr->users, modebuf, parabuf, chptr->topic); + } else { + send_reply(cptr, RPL_LIST, chptr->chname, chptr->users, chptr->topic); + } } } /* If, at the end of the bucket, client sendq is more than half Index: ircd-ircdev/ircd/ircd_events.c diff -u ircd-ircdev/ircd/ircd_events.c:1.11 ircd-ircdev/ircd/ircd_events.c:1.12 --- ircd-ircdev/ircd/ircd_events.c:1.11 Thu Sep 20 14:00:31 2007 +++ ircd-ircdev/ircd/ircd_events.c Tue Dec 11 15:38:24 2007 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of event loop mid-layer. - * @version $Id: ircd_events.c,v 1.11 2007/09/20 21:00:31 zolty Exp $ + * @version $Id: ircd_events.c,v 1.12 2007/12/11 23:38:24 zolty Exp $ */ #include "config.h" @@ -317,7 +317,7 @@ static void timer_enqueue(struct Timer* timer) { - struct Timer** ptr_p; + struct GenHeader** ptr_p; assert(0 != timer); assert(0 == timer->t_header.gh_prev_p); /* not already on queue */ @@ -336,16 +336,16 @@ /* Find a slot to insert timer */ for (ptr_p = &evI... [truncated message content] |