[IRC-Dev CVS] [CVS] Module ircdh: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2003-01-18 19:54:08
|
CVSROOT : /cvsroot/irc-dev Module : ircdh Commit time: 2003-01-18 19:53:59 UTC Modified files: ChangeLog include/handlers.h include/msg.h include/patchlevel.h ircd/Makefile.in ircd/ircd.c ircd/m_connect.c ircd/m_server.c ircd/parse.c ircd/s_debug.c ircd/s_serv.c Added files: include/jupe.h ircd/jupe.c ircd/m_account.c ircd/m_asll.c ircd/m_clearmode.c ircd/m_get.c ircd/m_jupe.c ircd/m_opmode.c ircd/m_privs.c ircd/m_reset.c ircd/m_set.c Log message: 2003-01-18 Toni Garcia <zo...@ir...> 1.0.alpha13 * Nuevos comandos: ACCOUNT, JUPE, CLEARMODE, OPMODE, SET, RESET, PRIV, ASLL. ---------------------- diff included ---------------------- Index: ircdh/ChangeLog diff -u ircdh/ChangeLog:1.7 ircdh/ChangeLog:1.8 --- ircdh/ChangeLog:1.7 Sat Jan 18 11:09:00 2003 +++ ircdh/ChangeLog Sat Jan 18 11:53:48 2003 @@ -1,3 +1,8 @@ +2003-01-18 Toni Garcia <zo...@ir...> 1.0.alpha13 + * Nuevos comandos: ACCOUNT, JUPE, CLEARMODE, OPMODE, SET, RESET, + PRIV, ASLL. + + 2003-01-18 Toni Garcia <zo...@ir...> 1.0.alpha12 * {*watch*}: Adapto el codigo del watch al ircd. Index: ircdh/include/handlers.h diff -u ircdh/include/handlers.h:1.2 ircdh/include/handlers.h:1.3 --- ircdh/include/handlers.h:1.2 Sat Jan 18 11:09:03 2003 +++ ircdh/include/handlers.h Sat Jan 18 11:53:48 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: handlers.h,v 1.2 2003/01/18 19:09:03 zolty Exp $ + * $Id: handlers.h,v 1.3 2003/01/18 19:53:48 zolty Exp $ */ #ifndef INCLUDED_handlers_h #define INCLUDED_handlers_h @@ -103,6 +103,7 @@ extern int m_invite(struct Client *, struct Client *, int, char *[]); extern int m_ison(struct Client *, struct Client *, int, char *[]); extern int m_join(struct Client *, struct Client *, int, char *[]); +extern int m_jupe(struct Client *, struct Client *, int, char *[]); extern int m_kick(struct Client *, struct Client *, int, char *[]); extern int m_links(struct Client *, struct Client *, int, char *[]); extern int m_links_redirect(struct Client *, struct Client *, int, char *[]); @@ -147,22 +148,30 @@ * Comandos de usuario privilegiado (Ircop & Helper) */ extern int mo_admin(struct Client *, struct Client *, int, char *[]); +extern int mo_asll(struct Client *, struct Client *, int, char *[]); +extern int mo_clearmode(struct Client *, struct Client *, int, char *[]); extern int mo_close(struct Client *, struct Client *, int, char *[]); extern int mo_connect(struct Client *, struct Client *, int, char *[]); #ifdef BDD extern int mo_dbq(struct Client *, struct Client *, int, char *[]); #endif extern int mo_die(struct Client *, struct Client *, int, char *[]); +extern int mo_get(struct Client *, struct Client *, int, char *[]); extern int mo_gline(struct Client *, struct Client *, int, char *[]); extern int mo_info(struct Client *, struct Client *, int, char *[]); +extern int mo_jupe(struct Client *, struct Client *, int, char *[]); extern int mo_kill(struct Client *, struct Client *, int, char *[]); extern int mo_notice(struct Client *, struct Client *, int, char *[]); extern int mo_oper(struct Client *, struct Client *, int, char *[]); +extern int mo_opmode(struct Client *, struct Client *, int, char *[]); extern int mo_ping(struct Client *, struct Client *, int, char *[]); +extern int mo_privs(struct Client *, struct Client *, int, char *[]); extern int mo_privmsg(struct Client *, struct Client *, int, char *[]); extern int mo_rehash(struct Client *, struct Client *, int, char *[]); +extern int mo_reset(struct Client *, struct Client *, int, char *[]); extern int mo_restart(struct Client *, struct Client *, int, char *[]); extern int mo_rping(struct Client *, struct Client *, int, char *[]); +extern int mo_set(struct Client *, struct Client *, int, char *[]); extern int mo_settime(struct Client *, struct Client *, int, char *[]); extern int mo_squit(struct Client *, struct Client *, int, char *[]); extern int mo_stats(struct Client *, struct Client *, int, char *[]); @@ -183,12 +192,15 @@ /* * Comandos servidor <=> servidor */ +extern int ms_account(struct Client *, struct Client *, int, char *[]); extern int ms_admin(struct Client *, struct Client *, int, char *[]); +extern int ms_asll(struct Client *, struct Client *, int, char *[]); extern int ms_away(struct Client *, struct Client *, int, char *[]); #ifdef BDD extern int ms_bmode(struct Client *, struct Client *, int, char *[]); #endif extern int ms_burst(struct Client *, struct Client *, int, char *[]); +extern int ms_clearmode(struct Client *, struct Client *, int, char *[]); extern int ms_connect(struct Client *, struct Client *, int, char *[]); extern int ms_create(struct Client *, struct Client *, int, char *[]); #ifdef BDD @@ -204,6 +216,7 @@ extern int ms_info(struct Client *, struct Client *, int, char *[]); extern int ms_invite(struct Client *, struct Client *, int, char *[]); extern int ms_join(struct Client *, struct Client *, int, char *[]); +extern int ms_jupe(struct Client *, struct Client *, int, char *[]); extern int ms_kick(struct Client *, struct Client *, int, char *[]); extern int ms_kill(struct Client *, struct Client *, int, char *[]); extern int ms_links(struct Client *, struct Client *, int, char *[]); @@ -214,6 +227,7 @@ extern int ms_nick(struct Client *, struct Client *, int, char *[]); extern int ms_notice(struct Client *, struct Client *, int, char *[]); extern int ms_oper(struct Client *, struct Client *, int, char *[]); +extern int ms_opmode(struct Client *, struct Client *, int, char *[]); extern int ms_part(struct Client *, struct Client *, int, char *[]); extern int ms_ping(struct Client *, struct Client *, int, char *[]); extern int ms_pong(struct Client *, struct Client *, int, char *[]); Index: ircdh/include/jupe.h diff -u /dev/null ircdh/include/jupe.h:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/include/jupe.h Sat Jan 18 11:53:48 2003 @@ -0,0 +1,73 @@ +/* + * IRC - Internet Relay Chat, include/jupe.h + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: jupe.h,v 1.1 2003/01/18 19:53:48 zolty Exp $ + */ +#ifndef INCLUDED_jupe_h +#define INCLUDED_jupe_h +#ifndef INCLUDED_sys_types_h +#include <sys/types.h> +#define INCLUDED_sys_types_h +#endif + + +struct Client; + +#define JUPE_MAX_EXPIRE 604800 /* max expire: 7 days */ + +struct Jupe { + struct Jupe *ju_next; + struct Jupe **ju_prev_p; + char *ju_server; + char *ju_reason; + time_t ju_expire; + time_t ju_lastmod; + unsigned int ju_flags; +}; + +#define JUPE_ACTIVE 0x0001 +#define JUPE_LOCAL 0x0002 +#define JUPE_LDEACT 0x0004 /* locally deactivated */ + +#define JUPE_MASK (JUPE_ACTIVE | JUPE_LOCAL) +#define JUPE_ACTMASK (JUPE_ACTIVE | JUPE_LDEACT) + +#define JupeIsActive(j) (((j)->ju_flags & JUPE_ACTMASK) == JUPE_ACTIVE) +#define JupeIsRemActive(j) ((j)->ju_flags & JUPE_ACTIVE) +#define JupeIsLocal(j) ((j)->ju_flags & JUPE_LOCAL) + +#define JupeServer(j) ((j)->ju_server) +#define JupeReason(j) ((j)->ju_reason) +#define JupeLastMod(j) ((j)->ju_lastmod) + +extern int jupe_add(struct Client *cptr, struct Client *sptr, char *server, + char *reason, time_t expire, time_t lastmod, unsigned int flags); +extern int jupe_activate(struct Client *cptr, struct Client *sptr, + struct Jupe *jupe, time_t lastmod, unsigned int flags); +extern int jupe_deactivate(struct Client *cptr, struct Client *sptr, + struct Jupe *jupe, time_t lastmod, unsigned int flags); +extern struct Jupe *jupe_find(char *server); +extern void jupe_free(struct Jupe *jupe); +extern void jupe_burst(struct Client *cptr); +extern int jupe_resend(struct Client *cptr, struct Jupe *jupe); +extern int jupe_list(struct Client *sptr, char *server); +extern int jupe_memory_count(size_t *ju_size); + +#endif /* INCLUDED_jupe_h */ Index: ircdh/include/msg.h diff -u ircdh/include/msg.h:1.4 ircdh/include/msg.h:1.5 --- ircdh/include/msg.h:1.4 Sat Jan 18 11:09:03 2003 +++ ircdh/include/msg.h Sat Jan 18 11:53:48 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: msg.h,v 1.4 2003/01/18 19:09:03 zolty Exp $ + * $Id: msg.h,v 1.5 2003/01/18 19:53:48 zolty Exp $ */ #ifndef INCLUDED_msg_h #define INCLUDED_msg_h @@ -318,12 +318,40 @@ #define TOK_PROTO "PROTO" #define CMD_PROTO MSG_PROTO, TOK_PROTO +#define MSG_JUPE "JUPE" /* JUPE */ +#define TOK_JUPE "JU" +#define CMD_JUPE MSG_JUPE, TOK_JUPE + #define MSG_OPMODE "OPMODE" /* OPMO */ #define TOK_OPMODE "OM" #define CMD_OPMODE MSG_OPMODE, TOK_OPMODE +#define MSG_CLEARMODE "CLEARMODE" /* CLMO */ +#define TOK_CLEARMODE "CM" +#define CMD_CLEARMODE MSG_CLEARMODE, TOK_CLEARMODE + +#define MSG_ACCOUNT "ACCOUNT" /* ACCO */ +#define TOK_ACCOUNT "AC" +#define CMD_ACCOUNT MSG_ACCOUNT, TOK_ACCOUNT + +#define MSG_ASLL "ASLL" /* ASLL */ +#define TOK_ASLL "LL" +#define CMD_ASLL MSG_ASLL, TOK_ASLL + #define MSG_POST "POST" /* POST */ #define TOK_POST "POST" + +#define MSG_SET "SET" /* SET */ +#define TOK_SET "SET" + +#define MSG_RESET "RESET" /* RESE */ +#define TOK_RESET "RESET" + +#define MSG_GET "GET" /* GET */ +#define TOK_GET "GET" + +#define MSG_PRIVS "PRIVS" /* PRIV */ +#define TOK_PRIVS "PRIVS" # if defined(BDD) #define MSG_DB "DB" /* Base de Datos ESNET */ Index: ircdh/include/patchlevel.h diff -u ircdh/include/patchlevel.h:1.7 ircdh/include/patchlevel.h:1.8 --- ircdh/include/patchlevel.h:1.7 Sat Jan 18 11:09:03 2003 +++ ircdh/include/patchlevel.h Sat Jan 18 11:53:48 2003 @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: patchlevel.h,v 1.7 2003/01/18 19:09:03 zolty Exp $ + * $Id: patchlevel.h,v 1.8 2003/01/18 19:53:48 zolty Exp $ * */ -#define PATCHLEVEL ".alpha12" +#define PATCHLEVEL ".alpha13" #define RELEASE "1.0" Index: ircdh/ircd/Makefile.in diff -u ircdh/ircd/Makefile.in:1.9 ircdh/ircd/Makefile.in:1.10 --- ircdh/ircd/Makefile.in:1.9 Sat Jan 18 11:09:04 2003 +++ ircdh/ircd/Makefile.in Sat Jan 18 11:53:48 2003 @@ -99,12 +99,16 @@ ircd_string.c \ ircd_tea.c \ ircd_xopen.c \ + jupe.c \ list.c \ listener.c \ + m_account.c \ m_admin.c \ + m_asll.c \ m_away.c \ m_bmode.c \ m_burst.c \ + m_clearmode.c \ m_close.c \ m_config.c \ m_connect.c \ @@ -119,13 +123,15 @@ m_die.c \ m_endburst.c \ m_error.c \ - m_gline.c \ + m_get.c \ m_ghost.c \ + m_gline.c \ m_help.c \ m_info.c \ m_invite.c \ m_ison.c \ m_join.c \ + m_jupe.c \ m_kick.c \ m_kill.c \ m_links.c \ @@ -138,19 +144,23 @@ m_nick.c \ m_notice.c \ m_oper.c \ + m_opmode.c \ m_part.c \ m_pass.c \ m_ping.c \ m_pong.c \ m_privmsg.c \ + m_privs.c \ m_proto.c \ m_quit.c \ m_rehash.c \ m_rename.c \ + m_reset.c \ m_restart.c \ m_rping.c \ m_rpong.c \ m_server.c \ + m_set.c \ m_settime.c \ m_silence.c \ m_squit.c \ Index: ircdh/ircd/ircd.c diff -u ircdh/ircd/ircd.c:1.7 ircdh/ircd/ircd.c:1.8 --- ircdh/ircd/ircd.c:1.7 Sat Jan 18 11:09:05 2003 +++ ircdh/ircd/ircd.c Sat Jan 18 11:53:49 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: ircd.c,v 1.7 2003/01/18 19:09:05 zolty Exp $ + * $Id: ircd.c,v 1.8 2003/01/18 19:53:49 zolty Exp $ */ #include "config.h" @@ -34,7 +34,7 @@ #include "ircd_reply.h" #include "ircd_signal.h" #include "ircd_string.h" -//#include "jupe.h" +#include "jupe.h" #include "list.h" #include "match.h" #include "motd.h" @@ -247,7 +247,7 @@ time_t next = 0; struct ConnectionClass *cltmp; struct ConfItem *con_conf = 0; -// struct Jupe* ajupe; + struct Jupe *ajupe; unsigned int con_class = 0; assert(ET_EXPIRE == ev_type(ev)); @@ -261,12 +261,9 @@ if (!(aconf->status & CONF_SERVER) || aconf->port == 0) continue; -#if 0 -/* FIXME-ZOLTAN */ /* Also skip juped servers */ if ((ajupe = jupe_find(aconf->name)) && JupeIsActive(ajupe)) continue; -#endif /* Skip this entry if the use of it is still on hold until * future. Otherwise handle this entry (and set it on hold until next Index: ircdh/ircd/jupe.c diff -u /dev/null ircdh/ircd/jupe.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/jupe.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,341 @@ +/* + * IRC - Internet Relay Chat, ircd/jupe.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Finland + * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: jupe.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ +#include "config.h" + +#include "jupe.h" +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_alloc.h" +#include "ircd_features.h" +#include "ircd_log.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "match.h" +#include "msg.h" +#include "numeric.h" +#include "numnicks.h" +#include "s_bsd.h" +#include "s_misc.h" +#include "send.h" +#include "struct.h" +#include "support.h" +#include "sys.h" /* FALSE bleah */ + +#include <assert.h> +#include <string.h> + +static struct Jupe *GlobalJupeList = 0; + +static struct Jupe *make_jupe(char *server, char *reason, time_t expire, + time_t lastmod, unsigned int flags) +{ + struct Jupe *ajupe; + + ajupe = (struct Jupe *)MyMalloc(sizeof(struct Jupe)); /* alloc memory */ + assert(0 != ajupe); + + DupString(ajupe->ju_server, server); /* copy vital information */ + DupString(ajupe->ju_reason, reason); + ajupe->ju_expire = expire; + ajupe->ju_lastmod = lastmod; + ajupe->ju_flags = flags & JUPE_MASK; /* set jupe flags */ + + ajupe->ju_next = GlobalJupeList; /* link it into the list */ + ajupe->ju_prev_p = &GlobalJupeList; + if (GlobalJupeList) + GlobalJupeList->ju_prev_p = &ajupe->ju_next; + GlobalJupeList = ajupe; + + return ajupe; +} + +static int do_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe) +{ + struct Client *acptr; + + if (!JupeIsActive(jupe)) /* no action to be taken on inactive jupes */ + return 0; + + acptr = FindServer(jupe->ju_server); + + /* server isn't online or isn't local or is me */ + if (!acptr || !MyConnect(acptr) || IsMe(acptr)) + return 0; + + return exit_client_msg(cptr, acptr, &me, "Juped: %s", jupe->ju_reason); +} + +static void +propagate_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe) +{ + if (JupeIsLocal(jupe)) /* don't propagate local jupes */ + return; + + sendcmdto_serv_butone(sptr, CMD_JUPE, cptr, "* %c%s %Tu %Tu :%s", + JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server, + jupe->ju_expire - CurrentTime, jupe->ju_lastmod, jupe->ju_reason); +} + +int +jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason, + time_t expire, time_t lastmod, unsigned int flags) +{ + struct Jupe *ajupe; + + assert(0 != server); + assert(0 != reason); + + /* + * You cannot set a negative (or zero) expire time, nor can you set an + * expiration time for greater than JUPE_MAX_EXPIRE. + */ + if (expire <= 0 || expire > JUPE_MAX_EXPIRE) + { + if (!IsServer(cptr) && MyConnect(cptr)) + send_reply(cptr, ERR_BADEXPIRE, expire); + return 0; + } + + expire += CurrentTime; /* convert from lifetime to timestamp */ + + /* Inform ops and log it */ + sendto_opmask_butone(0, SNO_NETWORK, "%s adding %sJUPE for %s, expiring at " + "%Tu: %s", + feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr) ? + cli_name(sptr) : cli_name((cli_user(sptr))->server), + flags & JUPE_LOCAL ? "local " : "", server, expire + TSoffset, reason); + + log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, + "%#C adding %sJUPE for %s, expiring at %Tu: %s", sptr, + flags & JUPE_LOCAL ? "local " : "", server, expire + TSoffset, reason); + + /* make the jupe */ + ajupe = make_jupe(server, reason, expire, lastmod, flags); + + propagate_jupe(cptr, sptr, ajupe); + + return do_jupe(cptr, sptr, ajupe); /* remove server if necessary */ +} + +int +jupe_activate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe, + time_t lastmod, unsigned int flags) +{ + unsigned int saveflags = 0; + + assert(0 != jupe); + + saveflags = jupe->ju_flags; + + if (flags & JUPE_LOCAL) + jupe->ju_flags &= ~JUPE_LDEACT; + else + { + jupe->ju_flags |= JUPE_ACTIVE; + + if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */ + jupe->ju_lastmod++; + else + jupe->ju_lastmod = lastmod; + } + + if ((saveflags & JUPE_ACTMASK) == JUPE_ACTIVE) + return 0; /* was active to begin with */ + + /* Inform ops and log it */ + sendto_opmask_butone(0, SNO_NETWORK, "%s activating JUPE for %s, expiring " + "at %Tu: %s", + feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr) ? + cli_name(sptr) : cli_name((cli_user(sptr))->server), + jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason); + + log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, + "%#C activating JUPE for %s, expiring at %Tu: %s", sptr, + jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason); + + if (!(flags & JUPE_LOCAL)) /* don't propagate local changes */ + propagate_jupe(cptr, sptr, jupe); + + return do_jupe(cptr, sptr, jupe); +} + +int +jupe_deactivate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe, + time_t lastmod, unsigned int flags) +{ + unsigned int saveflags = 0; + + assert(0 != jupe); + + saveflags = jupe->ju_flags; + + if (!JupeIsLocal(jupe)) + { + if (flags & JUPE_LOCAL) + jupe->ju_flags |= JUPE_LDEACT; + else + { + jupe->ju_flags &= ~JUPE_ACTIVE; + + if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */ + jupe->ju_lastmod++; + else + jupe->ju_lastmod = lastmod; + } + + if ((saveflags & JUPE_ACTMASK) != JUPE_ACTIVE) + return 0; /* was inactive to begin with */ + } + + /* Inform ops and log it */ + sendto_opmask_butone(0, SNO_NETWORK, "%s %s JUPE for %s, expiring at %Tu: " + "%s", + feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr) ? + cli_name(sptr) : cli_name((cli_user(sptr))->server), + JupeIsLocal(jupe) ? "removing local" : "deactivating", + jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason); + + log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, + "%#C %s JUPE for %s, expiring at %Tu: %s", sptr, + JupeIsLocal(jupe) ? "removing local" : "deactivating", + jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason); + + if (JupeIsLocal(jupe)) + jupe_free(jupe); + else if (!(flags & JUPE_LOCAL)) /* don't propagate local changes */ + propagate_jupe(cptr, sptr, jupe); + + return 0; +} + +struct Jupe *jupe_find(char *server) +{ + struct Jupe *jupe; + struct Jupe *sjupe; + + for (jupe = GlobalJupeList; jupe; jupe = sjupe) + { /* go through jupes */ + sjupe = jupe->ju_next; + + if (jupe->ju_expire <= CurrentTime) /* expire any that need expiring */ + jupe_free(jupe); + else if (0 == ircd_strcmp(server, jupe->ju_server)) /* found it yet? */ + return jupe; + } + + return 0; +} + +void jupe_free(struct Jupe *jupe) +{ + assert(0 != jupe); + + *jupe->ju_prev_p = jupe->ju_next; /* squeeze this jupe out */ + if (jupe->ju_next) + jupe->ju_next->ju_prev_p = jupe->ju_prev_p; + + MyFree(jupe->ju_server); /* and free up the memory */ + MyFree(jupe->ju_reason); + MyFree(jupe); +} + +void jupe_burst(struct Client *cptr) +{ + struct Jupe *jupe; + struct Jupe *sjupe; + + for (jupe = GlobalJupeList; jupe; jupe = sjupe) + { /* go through jupes */ + sjupe = jupe->ju_next; + + if (jupe->ju_expire <= CurrentTime) /* expire any that need expiring */ + jupe_free(jupe); + else if (!JupeIsLocal(jupe)) /* forward global jupes */ + sendcmdto_one(&me, CMD_JUPE, cptr, "* %c%s %Tu %Tu :%s", + JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server, + jupe->ju_expire - CurrentTime, jupe->ju_lastmod, jupe->ju_reason); + } +} + +int jupe_resend(struct Client *cptr, struct Jupe *jupe) +{ + if (JupeIsLocal(jupe)) /* don't propagate local jupes */ + return 0; + + sendcmdto_one(&me, CMD_JUPE, cptr, "* %c%s %Tu %Tu :%s", + JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server, + jupe->ju_expire - CurrentTime, jupe->ju_lastmod, jupe->ju_reason); + + return 0; +} + +int jupe_list(struct Client *sptr, char *server) +{ + struct Jupe *jupe; + struct Jupe *sjupe; + + if (server) + { + if (!(jupe = jupe_find(server))) /* no such jupe */ + return send_reply(sptr, ERR_NOSUCHJUPE, server); + + /* send jupe information along */ + send_reply(sptr, RPL_JUPELIST, jupe->ju_server, jupe->ju_expire + TSoffset, + JupeIsLocal(jupe) ? cli_name(&me) : "*", + JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason); + } + else + { + for (jupe = GlobalJupeList; jupe; jupe = sjupe) + { /* go through jupes */ + sjupe = jupe->ju_next; + + if (jupe->ju_expire <= CurrentTime) /* expire any that need expiring */ + jupe_free(jupe); + else /* send jupe information along */ + send_reply(sptr, RPL_JUPELIST, jupe->ju_server, + jupe->ju_expire + TSoffset, + JupeIsLocal(jupe) ? cli_name(&me) : "*", + JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason); + } + } + + /* end of jupe information */ + return send_reply(sptr, RPL_ENDOFJUPELIST); +} + +int jupe_memory_count(size_t *ju_size) +{ + struct Jupe *jupe; + unsigned int ju = 0; + + for (jupe = GlobalJupeList; jupe; jupe = jupe->ju_next) + { + ju++; + ju_size += sizeof(struct Jupe); + ju_size += jupe->ju_server ? (strlen(jupe->ju_server) + 1) : 0; + ju_size += jupe->ju_reason ? (strlen(jupe->ju_reason) + 1) : 0; + } + return ju; +} Index: ircdh/ircd/m_account.c diff -u /dev/null ircdh/ircd/m_account.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/m_account.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,135 @@ +/* + * IRC - Internet Relay Chat, ircd/m_account.c + * Copyright (C) 2002 Kevin L. Mitchell <kl...@mi...> + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: m_account.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#include "config.h" + +#include "client.h" +#include "ircd.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "msg.h" +#include "numnicks.h" +#include "s_user.h" +#include "send.h" + +#include <assert.h> + +/* + * ms_account - server message handler + * + * parv[0] = sender prefix + * parv[1] = numeric of client to act on + * parv[2] = account name (12 characters or less) + */ +int ms_account(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + struct Client *acptr; + + if (parc < 3) + return need_more_params(sptr, "ACCOUNT"); + + if (!IsServer(sptr)) + return protocol_violation(cptr, "ACCOUNT from non-server %s", + cli_name(sptr)); + + if (!(acptr = findNUser(parv[1]))) + return 0; /* Ignore ACCOUNT for a user that QUIT; probably crossed */ + + if (IsAccount(acptr)) + return protocol_violation(cptr, "ACCOUNT for already registered user %s " + "(%s -> %s)", cli_name(acptr), cli_user(acptr)->account, parv[2]); + + assert(0 == cli_user(acptr)->account[0]); + + if (strlen(parv[2]) > ACCOUNTLEN) + { + return protocol_violation(cptr, + "Received account (%s) longer than %d for %s; ignoring.", parv[2], + ACCOUNTLEN, cli_name(acptr)); + } + + ircd_strncpy(cli_user(acptr)->account, parv[2], ACCOUNTLEN); + hide_hostmask(acptr, FLAGS_ACCOUNT); + + sendcmdto_serv_butone(sptr, CMD_ACCOUNT, cptr, "%C %s", acptr, + cli_user(acptr)->account); + + return 0; +} Index: ircdh/ircd/m_asll.c diff -u /dev/null ircdh/ircd/m_asll.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/m_asll.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,183 @@ +/* + * IRC - Internet Relay Chat, ircd/m_asll.c + * Copyright (C) 2002 Alex Badea <va...@p1...> + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: m_asll.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#include "config.h" + +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "numeric.h" +#include "numnicks.h" +#include "match.h" +#include "msg.h" +#include "send.h" +#include "s_bsd.h" +#include "s_user.h" + +#include <assert.h> +#include <stdlib.h> + +static int send_asll_reply(struct Client *from, struct Client *to, char *server, + int rtt, int up, int down) +{ + sendcmdto_one(from, CMD_NOTICE, to, + (up + || down) ? "%C :AsLL for %s -- RTT: %ims Upstream: %ims Downstream: %ims" + : rtt ? "%C :AsLL for %s -- RTT: %ims [no asymm info]" : + "%C :AsLL for %s -- [unknown]", to, server, rtt, up, down); + return 0; +} + +/* + * ms_asll - server message handler + */ +int ms_asll(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + char *mask; + struct Client *acptr; + int i; + + if (parc < 2) + return need_more_params(sptr, "ASLL"); + + if (parc > 5) + { + if (!(acptr = findNUser(parv[1]))) + return 0; + if (MyUser(acptr)) + send_asll_reply(sptr, acptr, parv[2], atoi(parv[3]), atoi(parv[4]), + atoi(parv[5])); + else + sendcmdto_prio_one(sptr, CMD_ASLL, acptr, "%C %s %s %s %s", + acptr, parv[2], parv[3], parv[4], parv[5]); + return 0; + } + + if (hunt_server_prio_cmd(sptr, CMD_ASLL, cptr, 1, "%s %C", 2, parc, + parv) != HUNTED_ISME) + return 0; + mask = parv[1]; + + for (i = 0; i <= HighestFd; i++) + { + acptr = LocalClientArray[i]; + if (!acptr || !IsServer(acptr) || !MyConnect(acptr) + || match(mask, cli_name(acptr))) + continue; + sendcmdto_prio_one(&me, CMD_ASLL, sptr, "%C %s %i %i %i", sptr, + cli_name(acptr), cli_serv(acptr)->asll_rtt, + cli_serv(acptr)->asll_to, cli_serv(acptr)->asll_from); + } + return 0; +} + +/* + * mo_asll - oper message handler + */ +int mo_asll(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + char *mask; + struct Client *acptr; + int i; + + if (parc < 2) + return need_more_params(sptr, "ASLL"); + + if (parc == 2 && MyUser(sptr)) + parv[parc++] = cli_name(&me); + + if (hunt_server_prio_cmd(sptr, CMD_ASLL, cptr, 1, "%s %C", 2, parc, + parv) != HUNTED_ISME) + return 0; + mask = parv[1]; + + for (i = 0; i <= HighestFd; i++) + { + acptr = LocalClientArray[i]; + if (!acptr || !IsServer(acptr) || !MyConnect(acptr) + || match(mask, cli_name(acptr))) + continue; + send_asll_reply(&me, sptr, cli_name(acptr), cli_serv(acptr)->asll_rtt, + cli_serv(acptr)->asll_to, cli_serv(acptr)->asll_from); + } + return 0; +} Index: ircdh/ircd/m_clearmode.c diff -u /dev/null ircdh/ircd/m_clearmode.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/m_clearmode.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,323 @@ +/* + * IRC - Internet Relay Chat, ircd/m_tmpl.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: m_clearmode.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#include "config.h" + +#include "client.h" +#include "channel.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_alloc.h" +#include "ircd_features.h" +#include "ircd_log.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "list.h" +#include "msg.h" +#include "numeric.h" +#include "numnicks.h" +#include "s_conf.h" +#include "send.h" +#include "support.h" + +#include <assert.h> + +/* + * do_clearmode(struct Client *cptr, struct Client *sptr, + * struct Channel *chptr, char *control) + * + * This is the function that actually clears the channel modes. + */ +static int +do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, + char *control) +{ + static int flags[] = { + MODE_CHANOP, 'o', + MODE_VOICE, 'v', + MODE_PRIVATE, 'p', + MODE_SECRET, 's', + MODE_MODERATED, 'm', + MODE_TOPICLIMIT, 't', + MODE_INVITEONLY, 'i', + MODE_NOPRIVMSGS, 'n', + MODE_KEY, 'k', + MODE_BAN, 'b', + MODE_LIMIT, 'l', + MODE_REGONLY, 'r', + 0x0, 0x0 + }; + int *flag_p; + unsigned int del_mode = 0; + char control_buf[20]; + int control_buf_i = 0; + struct ModeBuf mbuf; + struct SLink *link, *next; + struct Membership *member; + + /* Um...yeah, like it's supposed to have any modes at all. */ + if (IsModelessChannel(chptr->chname)) + return 0; + + /* Ok, so what are we supposed to get rid of? */ + for (; *control; control++) + { + for (flag_p = flags; flag_p[0]; flag_p += 2) + if (*control == flag_p[1]) + { + del_mode |= flag_p[0]; + break; + } + } + + if (!del_mode) + return 0; /* nothing to remove; ho hum. */ + + modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */ + MODEBUF_DEST_OPMODE | /* Treat it like an OPMODE */ + MODEBUF_DEST_HACK4)); /* Generate a HACK(4) notice */ + + modebuf_mode(&mbuf, MODE_DEL | (del_mode & chptr->mode.mode)); + chptr->mode.mode &= ~del_mode; /* and of course actually delete them */ + + /* If we're removing invite, remove all the invites */ + if (del_mode & MODE_INVITEONLY) + mode_invite_clear(chptr); + + /* + * If we're removing the key, note that; note that we can't clear + * the key until after modebuf_* are done with it + */ + if (del_mode & MODE_KEY && *chptr->mode.key) + modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key, 0); + + /* If we're removing the limit, note that and clear the limit */ + if (del_mode & MODE_LIMIT && chptr->mode.limit) + { + modebuf_mode_uint(&mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit); + chptr->mode.limit = 0; /* not referenced, so safe */ + } + + /* + * Go through and mark the bans for deletion; note that we can't + * free them until after modebuf_* are done with them + */ + if (del_mode & MODE_BAN) + { + for (link = chptr->banlist; link; link = next) + { + next = link->next; + + modebuf_mode_string(&mbuf, MODE_DEL | MODE_BAN, /* delete ban */ + link->value.ban.banstr, 1); + + MyFree(link->value.ban.who); /* free up who string */ + free_link(link); /* and of course the link itself */ + } + + chptr->banlist = 0; + } + + /* Deal with users on the channel */ + if (del_mode & (MODE_BAN | MODE_CHANOP | MODE_VOICE)) + for (member = chptr->members; member; member = member->next_member) + { + if (IsZombie(member)) /* we ignore zombies */ + continue; + + if (del_mode & MODE_BAN) /* If we cleared bans, clear the valid flags */ + ClearBanValid(member); + + /* Drop channel operator status */ + if (IsChanOp(member) && del_mode & MODE_CHANOP) + { + modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user); + member->status &= ~CHFL_CHANOP; + } + + /* Drop voice */ + if (HasVoice(member) && del_mode & MODE_VOICE) + { + modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user); + member->status &= ~CHFL_VOICE; + } + } + + /* And flush the modes to the channel */ + modebuf_flush(&mbuf); + + /* Finally, we can clear the key... */ + if (del_mode & MODE_KEY) + chptr->mode.key[0] = '\0'; + + /* Ok, build control string again */ + for (flag_p = flags; flag_p[0]; flag_p += 2) + if (del_mode & flag_p[0]) + control_buf[control_buf_i++] = flag_p[1]; + + control_buf[control_buf_i] = '\0'; + + /* Log it... */ + log_write(LS_OPERMODE, L_INFO, LOG_NOSNOTICE, "%#C CLEARMODE %H %s", sptr, + chptr, control_buf); + + /* Then send it */ + if (!IsLocalChannel(chptr->chname)) + sendcmdto_serv_butone(sptr, CMD_CLEARMODE, cptr, "%H %s", chptr, + control_buf); + + return 0; +} + +/* + * ms_clearmode - server message handler + * + * parv[0] = Send prefix + * parv[1] = Channel name + * parv[2] = Control string + */ +int +ms_clearmode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + struct Channel *chptr; + + if (parc < 3) + return need_more_params(sptr, "CLEARMODE"); + + if (!IsPrivileged(sptr)) + { + protocol_violation(sptr, "No priviledges on source for CLEARMODE, desync?"); + return send_reply(sptr, ERR_NOPRIVILEGES); + } + + if (!IsChannelName(parv[1]) || IsLocalChannel(parv[1]) || + !(chptr = FindChannel(parv[1]))) + return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); + + return do_clearmode(cptr, sptr, chptr, parv[2]); +} + +/* + * mo_clearmode - oper message handler + * + * parv[0] = Send prefix + * parv[1] = Channel name + * parv[2] = Control string + */ +int +mo_clearmode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + struct Channel *chptr; + char *control = "ovpsmikbl"; /* default control string */ + char *chname, *qreason; + int force = 0; + + if (!feature_bool(FEAT_CONFIG_OPERCMDS)) + return send_reply(sptr, ERR_DISABLED, "CLEARMODE"); + + if (parc < 2) + return need_more_params(sptr, "CLEARMODE"); + + if (parc > 2) + control = parv[2]; + + chname = parv[1]; + if (*chname == '!') + { + chname++; + if (!HasPriv(sptr, + IsLocalChannel(chname) ? PRIV_FORCE_LOCAL_OPMODE : PRIV_FORCE_OPMODE)) + return send_reply(sptr, ERR_NOPRIVILEGES); + force = 1; + } + + if (!HasPriv(sptr, IsLocalChannel(chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE)) + return send_reply(sptr, ERR_NOPRIVILEGES); + + if (('#' != *chname && '&' != *chname) || !(chptr = FindChannel(chname))) + return send_reply(sptr, ERR_NOSUCHCHANNEL, chname); + + if (!force && (qreason = find_quarantine(chptr->chname))) + return send_reply(sptr, ERR_QUARANTINED, chptr->chname, qreason); + + return do_clearmode(cptr, sptr, chptr, control); +} Index: ircdh/ircd/m_connect.c diff -u ircdh/ircd/m_connect.c:1.2 ircdh/ircd/m_connect.c:1.3 --- ircdh/ircd/m_connect.c:1.2 Sat Jan 18 11:09:06 2003 +++ ircdh/ircd/m_connect.c Sat Jan 18 11:53:49 2003 @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: m_connect.c,v 1.2 2003/01/18 19:09:06 zolty Exp $ + * $Id: m_connect.c,v 1.3 2003/01/18 19:53:49 zolty Exp $ */ /* @@ -89,7 +89,7 @@ #include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" -//#include "jupe.h" +#include "jupe.h" #include "match.h" #include "msg.h" #include "numeric.h" @@ -118,7 +118,7 @@ const char *rule; struct ConfItem *aconf; struct Client *acptr; -// struct Jupe *ajupe; + struct Jupe *ajupe; assert(0 != cptr); assert(0 != sptr); @@ -176,15 +176,12 @@ /* * Check to see if the server is juped; if it is, disallow the connect */ -#if 0 -/* FIXME-ZOLTAN */ if ((ajupe = jupe_find(aconf->name)) && JupeIsActive(ajupe)) { sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Connect: Server %s is juped: %s", sptr, JupeServer(ajupe), JupeReason(ajupe)); return 0; } -#endif /* * Allow opers to /connect foo.* 0 bah.* to connect foo and bah @@ -242,7 +239,7 @@ const char *rule; struct ConfItem *aconf; struct Client *acptr; -// struct Jupe* ajupe; + struct Jupe *ajupe; assert(0 != cptr); assert(cptr == sptr); @@ -324,15 +321,13 @@ /* * Check to see if the server is juped; if it is, disallow the connect */ -#if 0 -/* FIXME-ZOLTAN */ if ((ajupe = jupe_find(aconf->name)) && JupeIsActive(ajupe)) { sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Connect: Server %s is juped: %s", sptr, JupeServer(ajupe), JupeReason(ajupe)); return 0; } -#endif + /* * Get port number from user, if given. If not specified, * use the default from configuration structure. If missing Index: ircdh/ircd/m_get.c diff -u /dev/null ircdh/ircd/m_get.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/m_get.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,102 @@ +/* + * IRC - Internet Relay Chat, ircd/m_get.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: m_get.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#include "config.h" + +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_features.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "numeric.h" +#include "numnicks.h" +#include "send.h" + +#include <assert.h> + +/* + * mo_get - oper message handler + */ +int mo_get(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + return feature_get(sptr, (const char *const *)parv + 1, parc - 1); +} Index: ircdh/ircd/m_jupe.c diff -u /dev/null ircdh/ircd/m_jupe.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/m_jupe.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,294 @@ +/* + * IRC - Internet Relay Chat, ircd/m_jupe.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: m_jupe.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#include "config.h" + +#include "client.h" +#include "jupe.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_features.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "match.h" +#include "msg.h" +#include "numeric.h" +#include "numnicks.h" +#include "s_conf.h" +#include "s_misc.h" +#include "send.h" +#include "support.h" + +#include <assert.h> +#include <stdlib.h> +#include <string.h> + +/* + * ms_jupe - server message handler + * + * parv[0] = Send prefix + * + * From server: + * + * parv[1] = Target: server numeric or * + * parv[2] = (+|-)<server name> + * parv[3] = Expiration offset + * parv[4] = Last modification time + * parv[5] = Comment + * + */ +int ms_jupe(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + struct Client *acptr = 0; + struct Jupe *ajupe; + unsigned int flags = 0; + time_t expire_off, lastmod; + char *server = parv[2], *target = parv[1], *reason = parv[5]; + + if (parc < 6) + return need_more_params(sptr, "JUPE"); + + if (!(target[0] == '*' && target[1] == '\0')) + { + if (!(acptr = FindNServer(target))) + return 0; /* no such server */ + + if (!IsMe(acptr)) + { /* manually propagate, since we don't set it */ + sendcmdto_one(sptr, CMD_JUPE, acptr, "%s %s %s %s :%s", target, server, + parv[3], parv[4], reason); + return 0; + } + + flags |= JUPE_LOCAL; + } + + if (*server == '-') + server++; + else if (*server == '+') + { + flags |= JUPE_ACTIVE; + server++; + } + + expire_off = atoi(parv[3]); + lastmod = atoi(parv[4]); + + ajupe = jupe_find(server); + + if (ajupe) + { + if (JupeIsLocal(ajupe) && !(flags & JUPE_LOCAL)) /* global over local */ + jupe_free(ajupe); + else if (JupeLastMod(ajupe) < lastmod) + { /* new modification */ + if (flags & JUPE_ACTIVE) + return jupe_activate(cptr, sptr, ajupe, lastmod, flags); + else + return jupe_deactivate(cptr, sptr, ajupe, lastmod, flags); + } + else if (JupeLastMod(ajupe) == lastmod || IsBurstOrBurstAck(cptr)) + return 0; + else + return jupe_resend(cptr, ajupe); /* other server desynched WRT jupes */ + } + + return jupe_add(cptr, sptr, server, reason, expire_off, lastmod, flags); +} + +/* + * mo_jupe - oper message handler + * + * parv[0] = Send prefix + * parv[1] = [[+|-]<server name>] + * + * Local (to me) style: + * + * parv[2] = [Expiration offset] + * parv[3] = [Comment] + * + * Global (or remote local) style: + * + * parv[2] = [target] + * parv[3] = [Expiration offset] + * parv[4] = [Comment] + * + */ +int mo_jupe(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + struct Client *acptr = 0; + struct Jupe *ajupe; + unsigned int flags = 0; + time_t expire_off; + char *server = parv[1], *target = 0, *reason; + + if (parc < 2) + return jupe_list(sptr, 0); + + if (*server == '+') + { + flags |= JUPE_ACTIVE; + server++; + } + else if (*server == '-') + server++; + else + return jupe_list(sptr, server); + + if (!feature_bool(FEAT_CONFIG_OPERCMDS)) + return send_reply(sptr, ERR_DISABLED, "JUPE"); + + if (parc == 4) + { + expire_off = atoi(parv[2]); + reason = parv[3]; + flags |= JUPE_LOCAL; + } + else if (parc > 4) + { + target = parv[2]; + expire_off = atoi(parv[3]); + reason = parv[4]; + } + else + return need_more_params(sptr, "JUPE"); + + if (target) + { + if (!(target[0] == '*' && target[1] == '\0')) + { + if (!(acptr = find_match_server(target))) + return send_reply(sptr, ERR_NOSUCHSERVER, target); + + if (!IsMe(acptr)) + { /* manually propagate, since we don't set it */ + if (!HasPriv(sptr, PRIV_GLINE)) + return send_reply(sptr, ERR_NOPRIVILEGES); + + sendcmdto_one(sptr, CMD_JUPE, acptr, "%C %c%s %s %Tu :%s", acptr, + flags & JUPE_ACTIVE ? '+' : '-', server, parv[3], TStime(), reason); + return 0; + } + else if (!HasPriv(sptr, PRIV_LOCAL_GLINE)) + return send_reply(sptr, ERR_NOPRIVILEGES); + + flags |= JUPE_LOCAL; + } + else if (!HasPriv(sptr, PRIV_GLINE)) + return send_reply(sptr, ERR_NOPRIVILEGES); + } + + ajupe = jupe_find(server); + + if (ajupe) + { + if (JupeIsLocal(ajupe) && !(flags & JUPE_LOCAL)) /* global over local */ + jupe_free(ajupe); + else + { + if (flags & JUPE_ACTIVE) + return jupe_activate(cptr, sptr, ajupe, TStime(), flags); + else + return jupe_deactivate(cptr, sptr, ajupe, TStime(), flags); + } + } + + return jupe_add(cptr, sptr, server, reason, expire_off, TStime(), flags); +} + +/* + * m_jupe - user message handler + * + * parv[0] = Send prefix + * + * From user: + * + * parv[1] = [<server name>] + * + */ +int m_jupe(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + if (parc < 2) + return jupe_list(sptr, 0); + + return jupe_list(sptr, parv[1]); +} Index: ircdh/ircd/m_opmode.c diff -u /dev/null ircdh/ircd/m_opmode.c:1.1 --- /dev/null Sat Jan 18 11:54:01 2003 +++ ircdh/ircd/m_opmode.c Sat Jan 18 11:53:49 2003 @@ -0,0 +1,180 @@ +/* + * IRC - Internet Relay Chat, ircd/m_tmpl.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: m_opmode.c,v 1.1 2003/01/18 19:53:49 zolty Exp $ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are ... [truncated message content] |