From 80881d85337d93d70b67a505ae5178199b1b3155 Mon Sep 17 00:00:00 2001 From: Perry Lorier Date: Mon, 20 Nov 2000 19:02:17 +0000 Subject: [PATCH] Author: Isomer Log message: * ircd/ircd_reply.c: added 'protocol_violation', thus alerting us to problems in the server<->server protocol. * ircd/m_connect.c: allow remote connects with a port of '0' meaning to use the port in the config file. * ircd/m_create.c: Enable hacking protection, lets see how far we get. * ircd/m_error.c: The RFC says never accept ERROR from unreg'd clients, so we don't any more. * ircd/m_kill.c: The kill path is now made up of numnicks of servers, and the user@host is displayed of the victim. * ircd/m_map.c: reloaded 'dump_map'. * ircd/m_trace.c: allow per class T: * ircd/m_stats.c: allow local opers /remote stats anywhere on the 'net. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@308 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 24 +++++++++- doc/example.conf | 2 + doc/rfc1459.unet | 3 +- include/handlers.h | 2 +- include/ircd_reply.h | 1 + include/map.h | 17 ------- ircd/Makefile.in | 25 ++--------- ircd/ircd_reply.c | 22 +++++++++ ircd/m_away.c | 2 +- ircd/m_burst.c | 2 +- ircd/m_clearmode.c | 4 +- ircd/m_connect.c | 15 ++++++- ircd/m_create.c | 14 +++--- ircd/m_destruct.c | 6 +-- ircd/m_desynch.c | 4 +- ircd/m_endburst.c | 5 +-- ircd/m_error.c | 49 -------------------- ircd/m_invite.c | 11 ++--- ircd/m_join.c | 3 +- ircd/m_kill.c | 8 ++-- ircd/m_map.c | 61 ++++++++++++++++++++++++- ircd/m_motd.c | 36 +++++++-------- ircd/m_notice.c | 2 +- ircd/m_pass.c | 8 +++- ircd/m_pong.c | 2 +- ircd/m_quit.c | 7 ++- ircd/m_rehash.c | 2 + ircd/m_rping.c | 3 -- ircd/m_server.c | 2 +- ircd/m_silence.c | 5 +-- ircd/m_topic.c | 4 +- ircd/m_version.c | 5 --- ircd/m_wallops.c | 2 +- ircd/map.c | 105 ------------------------------------------- ircd/parse.c | 7 ++- ircd/s_stats.c | 12 +++-- 36 files changed, 205 insertions(+), 277 deletions(-) delete mode 100644 include/map.h delete mode 100644 ircd/map.c diff --git a/ChangeLog b/ChangeLog index 34c5891..0af5a67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,26 @@ -2000-10-30 Isomer +2000-11-19 Isomer + * ircd/ircd_reply.c: added 'protocol_violation', thus alerting us + to problems in the server<->server protocol. + + * ircd/m_connect.c: allow remote connects with a port of '0' + meaning to use the port in the config file. + + * ircd/m_create.c: Enable hacking protection, lets see how far we + get. + + * ircd/m_error.c: The RFC says never accept ERROR from unreg'd + clients, so we don't any more. + + * ircd/m_kill.c: The kill path is now made up of numnicks of servers, + and the user@host is displayed of the victim. + + * ircd/m_map.c: reloaded 'dump_map'. + + * ircd/m_trace.c: allow per class T: + + * ircd/m_stats.c: allow local opers /remote stats anywhere on the 'net. + +2000-11-17 Isomer * ircd/m_topic.c: Fixed bug where we'd only send to clients topics that were the *same* instead of different. Oh the embarrasment! diff --git a/doc/example.conf b/doc/example.conf index 72f1a49..aa29ead 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -185,6 +185,8 @@ I:*@193.37.*::*@*.london.ac.uk::10 # It is possible to show a different Message of the Day to a connecting # client depending on its origin. # T:: +# or: +# T:: # # DPATH/net_com.motd contains a special MOTD where users are encouraged # to register their domains and get their own I: lines if they're in diff --git a/doc/rfc1459.unet b/doc/rfc1459.unet index 99794a6..84d106a 100644 --- a/doc/rfc1459.unet +++ b/doc/rfc1459.unet @@ -1632,7 +1632,8 @@ LINKS *.au ; list all servers which have a name a new connection to another server immediately. CONNECT is a privileged command and is to be available only to IRC Operators. If a remote server is given then the CONNECT attempt is made by that - server to and . + server to and . A port of 0 means use the default + port number. Most errors are reported in notice's. Numeric Replies: diff --git a/include/handlers.h b/include/handlers.h index 3889074..9b991d5 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -110,7 +110,7 @@ extern int m_notice(struct Client*, struct Client*, int, char*[]); extern int m_notice(struct Client*, struct Client*, int, char*[]); extern int m_oper(struct Client*, struct Client*, int, char*[]); extern int m_part(struct Client*, struct Client*, int, char*[]); -extern int m_pass(struct Client*, struct Client*, int, char*[]); +extern int mr_pass(struct Client*, struct Client*, int, char*[]); extern int m_ping(struct Client*, struct Client*, int, char*[]); extern int m_pong(struct Client*, struct Client*, int, char*[]); extern int m_private(struct Client*, struct Client*, int, char*[]); diff --git a/include/ircd_reply.h b/include/ircd_reply.h index 91d48fb..4ea9e5a 100644 --- a/include/ircd_reply.h +++ b/include/ircd_reply.h @@ -24,6 +24,7 @@ struct Client; +extern int protocol_violation(struct Client* cptr, const char* pattern, ...); extern int need_more_params(struct Client* cptr, const char* cmd); extern int send_error_to_client(struct Client* cptr, int error, ...); extern int send_reply(struct Client* to, int reply, ...); diff --git a/include/map.h b/include/map.h deleted file mode 100644 index 3b039f2..0000000 --- a/include/map.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * map.h - * - * $Id$ - */ -#ifndef INCLUDED_map_h -#define INCLUDED_map_h - -struct Client; - -/* - * Prototypes - */ - -void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length); - -#endif /* INCLUDED_map_h */ diff --git a/ircd/Makefile.in b/ircd/Makefile.in index 93c367e..1e95528 100644 --- a/ircd/Makefile.in +++ b/ircd/Makefile.in @@ -150,7 +150,6 @@ SRC = \ m_who.c \ m_whois.c \ m_whowas.c \ - map.c \ match.c \ numnicks.c \ opercmds.c \ @@ -375,7 +374,8 @@ ircd_reply.o: ircd_reply.c ../include/ircd_reply.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/ircd_handler.h \ ../include/ircd.h ../config/config.h ../config/setup.h \ ../include/struct.h ../include/ircd_snprintf.h ../include/numeric.h \ - ../include/s_conf.h ../include/s_debug.h ../include/send.h + ../include/msg.h ../include/s_conf.h ../include/s_debug.h \ + ../include/send.h ircd_signal.o: ircd_signal.c ../include/ircd_signal.h \ ../include/ircd.h ../config/config.h ../config/setup.h \ ../include/struct.h ../include/ircd_defs.h @@ -591,8 +591,7 @@ m_map.o: m_map.c ../include/client.h ../include/ircd_defs.h \ ../include/dbuf.h ../include/ircd_handler.h ../include/ircd.h \ ../config/config.h ../config/setup.h ../include/struct.h \ ../include/ircd_reply.h ../include/ircd_string.h \ - ../include/ircd_chattr.h ../include/map.h ../include/numeric.h \ - ../include/send.h + ../include/ircd_chattr.h ../include/numeric.h ../include/send.h m_mode.o: m_mode.c ../include/handlers.h ../include/channel.h \ ../config/config.h ../config/setup.h ../include/ircd_defs.h \ ../include/client.h ../include/dbuf.h ../include/ircd_handler.h \ @@ -838,12 +837,6 @@ m_whowas.o: m_whowas.c ../include/client.h ../include/ircd_defs.h \ ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \ ../include/numnicks.h ../include/s_user.h ../include/s_misc.h \ ../include/send.h ../include/whowas.h -map.o: map.c ../include/map.h ../include/client.h \ - ../include/ircd_defs.h ../include/dbuf.h ../include/ircd_handler.h \ - ../include/ircd.h ../config/config.h ../config/setup.h \ - ../include/struct.h ../include/ircd_reply.h ../include/list.h \ - ../include/match.h ../include/numeric.h ../include/numnicks.h \ - ../include/querycmds.h ../include/send.h match.o: match.c ../include/match.h ../include/ircd_chattr.h numnicks.o: numnicks.c ../include/numnicks.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/ircd_handler.h \ @@ -864,18 +857,6 @@ packet.o: packet.c ../include/packet.h ../include/client.h \ ../include/ircd.h ../config/config.h ../config/setup.h \ ../include/struct.h ../include/ircd_chattr.h ../include/parse.h \ ../include/s_bsd.h ../include/s_misc.h ../include/send.h -parse.o: parse.c ../include/parse.h ../include/client.h \ - ../include/ircd_defs.h ../include/dbuf.h ../include/ircd_handler.h \ - ../include/channel.h ../config/config.h ../config/setup.h \ - ../include/handlers.h ../include/hash.h ../include/ircd.h \ - ../include/struct.h ../include/ircd_alloc.h ../include/fda.h \ - ../include/ircd_chattr.h ../include/ircd_reply.h \ - ../include/ircd_string.h ../include/map.h ../include/msg.h \ - ../include/numeric.h ../include/numnicks.h ../include/opercmds.h \ - ../include/querycmds.h ../include/res.h ../include/s_bsd.h \ - ../include/s_conf.h ../include/s_debug.h ../include/s_misc.h \ - ../include/s_numeric.h ../include/s_user.h ../include/send.h \ - ../include/sys.h ../include/whocmds.h ../include/whowas.h querycmds.o: querycmds.c ../include/querycmds.h random.o: random.c ../include/random.h ../config/config.h \ ../config/setup.h diff --git a/ircd/ircd_reply.c b/ircd/ircd_reply.c index 742923d..5e33b1b 100644 --- a/ircd/ircd_reply.c +++ b/ircd/ircd_reply.c @@ -27,6 +27,7 @@ #include "ircd.h" #include "ircd_snprintf.h" #include "numeric.h" +#include "msg.h" #include "s_conf.h" #include "s_debug.h" #include "send.h" @@ -34,8 +35,29 @@ #include #include +/* Report a protocol violation warning to anyone listening. This can be + * easily used to cleanup the last couple of parts of the code up. + */ + +int protocol_violation(struct Client* cptr, const char* pattern, ...) +{ + va_list vl; + char buffer[512]; + assert(pattern); + assert(cptr); + va_start(vl,pattern); + ircd_snprintf(0,buffer,sizeof(buffer)-2, + "Protocol Violation from %C: %v",vl); + sendcmdto_flag_butone(&me, CMD_DESYNCH, NULL, FLAGS_DEBUG, + ":%s", cptr, buffer); + va_end(vl); + return 0; +} + int need_more_params(struct Client* cptr, const char* cmd) { + if (!MyUser(cptr)) + protocol_violation(cptr,"Not enough parameters for %s",cmd); send_reply(cptr, ERR_NEEDMOREPARAMS, cmd); return 0; } diff --git a/ircd/m_away.c b/ircd/m_away.c index db726ff..9595084 100644 --- a/ircd/m_away.c +++ b/ircd/m_away.c @@ -141,7 +141,7 @@ int ms_away(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * servers can't set away */ if (IsServer(sptr)) - return 0; + return protocol_violation(sptr,"Server trying to set itself away"); if (user_set_away(sptr->user, away_message)) sendcmdto_serv_butone(sptr, CMD_AWAY, cptr, ":%s", away_message); diff --git a/ircd/m_burst.c b/ircd/m_burst.c index f966ca8..ceb8c9b 100644 --- a/ircd/m_burst.c +++ b/ircd/m_burst.c @@ -151,7 +151,7 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) char modestr[IRC_BUFSIZE], nickstr[IRC_BUFSIZE], banstr[IRC_BUFSIZE]; if (parc < 4) - return 0; + return protocol_violation(sptr,"Too few parameters for BURST"); if (!IsBurst(sptr)) /* don't allow BURST outside of burst */ return exit_client_msg(cptr, cptr, &me, "HACK: BURST message outside " diff --git a/ircd/m_clearmode.c b/ircd/m_clearmode.c index a2946e0..ef2e10b 100644 --- a/ircd/m_clearmode.c +++ b/ircd/m_clearmode.c @@ -265,8 +265,10 @@ ms_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc < 3) return need_more_params(sptr, "CLEARMODE"); - if (!IsPrivileged(sptr)) + 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]))) diff --git a/ircd/m_connect.c b/ircd/m_connect.c index d30151d..3f7d6f9 100644 --- a/ircd/m_connect.c +++ b/ircd/m_connect.c @@ -180,6 +180,12 @@ int ms_connect(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) sptr, JupeServer(ajupe), JupeReason(ajupe)); return 0; } + + /* + * Allow opers to /connect foo.* 0 bah.* to connect foo and bah + * using the conf's configured port + */ +#if 0 /* * Get port number from params, port must be non-zero if it comes from a * server. @@ -189,11 +195,18 @@ int ms_connect(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) sptr); return 0; } +#endif + port = atoi(parv[2]); /* * save the old port */ tmpport = aconf->port; - aconf->port = port; + if (port) { + aconf->port = port; + } + else { + port = aconf->port; + } /* * Notify all operators about remote connect requests */ diff --git a/ircd/m_create.c b/ircd/m_create.c index 6333645..e89afa3 100644 --- a/ircd/m_create.c +++ b/ircd/m_create.c @@ -97,6 +97,7 @@ #include "numeric.h" #include "numnicks.h" #include "s_debug.h" +#include "s_user.h" #include "send.h" #include @@ -117,14 +118,12 @@ int ms_create(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) struct ModeBuf mbuf; /* a mode buffer */ int badop; /* a flag */ - if (IsServer(sptr)) { - Debug((DEBUG_ERROR, "%s tried to CREATE a channel", sptr->name)); - return 0; - } + if (IsServer(sptr)) + return protocol_violation(sptr,"%s tried to CREATE a channel", sptr->name); /* sanity checks: Only accept CREATE messages from servers */ if (parc < 3 || *parv[2] == '\0') - return 0; + return need_more_params(sptr,"CREATE"); chanTS = atoi(parv[2]); @@ -138,11 +137,12 @@ int ms_create(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) MAGIC_REMOTE_JOIN_TS != chanTS) sptr->user->server->serv->lag = TStime() - chanTS; -#if 0 +#if 1 /* If this server is >5 minutes fast, squit it */ if (TStime() - chanTS<-5*60*60) return exit_client(sptr,sptr,"Timestamp Drift/Bogus TS"); - +#endif +#if 0 /* If we recieve a CREATE for a channel from a server before that server * was linked, then it's a HACK */ diff --git a/ircd/m_destruct.c b/ircd/m_destruct.c index c26aeaf..c05e41e 100644 --- a/ircd/m_destruct.c +++ b/ircd/m_destruct.c @@ -120,11 +120,7 @@ int ms_destruct(struct Client* cptr, struct Client* sptr, int parc, char* parv[] assert(IsServer(cptr)); if (parc < 3 || EmptyString(parv[2])) - return 0; - - /* sanity checks: Only accept DESTRUCT messages from servers */ - if (!IsServer(sptr)) - return 0; + return need_more_params(sptr,"DESTRUCT"); /* Don't pass on DESTRUCT messages for channels that exist */ if (FindChannel(parv[1])) diff --git a/ircd/m_desynch.c b/ircd/m_desynch.c index d2b2cd0..eee568f 100644 --- a/ircd/m_desynch.c +++ b/ircd/m_desynch.c @@ -111,9 +111,11 @@ */ int ms_desynch(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - if (IsServer(sptr) && parc >= 2) + if (parc >= 2) sendcmdto_flag_butone(sptr, CMD_DESYNCH, cptr, FLAGS_DEBUG, ":%s", parv[parc - 1]); + else + need_more_params(sptr,"DESYNCH"); return 0; } diff --git a/ircd/m_endburst.c b/ircd/m_endburst.c index ec42f72..c987428 100644 --- a/ircd/m_endburst.c +++ b/ircd/m_endburst.c @@ -119,10 +119,9 @@ int ms_end_of_burst(struct Client* cptr, struct Client* sptr, int parc, char* pa assert(0 != cptr); assert(0 != sptr); - if (!IsServer(sptr)) - return 0; - sendto_opmask_butone(0, SNO_NETWORK, "Completed net.burst from %C.", sptr); + sendto_opmask_butone(0, SNO_NETWORK, "Completed net.burst from %C.", + sptr); sendcmdto_serv_butone(sptr, CMD_END_OF_BURST, cptr, ""); ClearBurst(sptr); SetBurstAck(sptr); diff --git a/ircd/m_error.c b/ircd/m_error.c index 7af17f4..f7ad566 100644 --- a/ircd/m_error.c +++ b/ircd/m_error.c @@ -115,55 +115,6 @@ int ms_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) para = (parc > 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>"; Debug((DEBUG_ERROR, "Received ERROR message from %s: %s", sptr->name, para)); - /* - * Ignore error messages generated by normal user clients - * (because ill-behaving user clients would flood opers - * screen otherwise). Pass ERROR's from other sources to - * the local operator... - */ - if (IsUser(cptr)) - return 0; - if (IsUnknown(cptr)) - return exit_client_msg(cptr, cptr, &me, "Register first"); - - if (cptr == sptr) - sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C -- %s", cptr, para); - else - sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C via %C -- %s", sptr, - cptr, para); - - if (sptr->serv) - { - MyFree(sptr->serv->last_error_msg); - DupString(sptr->serv->last_error_msg, para); - } - - return 0; -} - -/* - * mr_error - registration message handler - * - * parv[0] = sender prefix - * parv[parc-1] = text - */ -int mr_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) -{ - const char *para; - - para = (parc > 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>"; - - Debug((DEBUG_ERROR, "Received ERROR message from %s: %s", sptr->name, para)); - /* - * Ignore error messages generated by normal user clients - * (because ill-behaving user clients would flood opers - * screen otherwise). Pass ERROR's from other sources to - * the local operator... - */ - if (IsUser(cptr)) - return 0; - if (IsUnknown(cptr)) - return exit_client_msg(cptr, cptr, &me, "Register first"); if (cptr == sptr) sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C -- %s", cptr, para); diff --git a/ircd/m_invite.c b/ircd/m_invite.c index 47beba3..af90a34 100644 --- a/ircd/m_invite.c +++ b/ircd/m_invite.c @@ -134,7 +134,7 @@ int m_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(cptr, RPL_ENDOFINVITELIST); return 0; } - + if (parc < 3 || EmptyString(parv[2])) return need_more_params(sptr, "INVITE"); @@ -232,22 +232,19 @@ int ms_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * this will blow up if we get an invite from a server * we look for channel membership in sptr below. */ - /* PROTOCOL WARNING */ - return 0; + return protocol_violation(sptr,"Server attempting to invite"); } if (parc < 3 || EmptyString(parv[2])) { /* * should have been handled upstream, ignore it. */ - /* PROTOCOL WARNING */ - return 0; + return need_more_params(sptr,"INVITE"); } if ('#' != *parv[2]) { /* * should not be sent */ - /* PROTOCOL WARNING */ - return 0; + return protocol_violation(sptr, "Invite to a non-standard channel %s",parv[2]); } if (!(acptr = FindUser(parv[1]))) { send_reply(sptr, ERR_NOSUCHNICK, parv[1]); diff --git a/ircd/m_join.c b/ircd/m_join.c index 657bc4e..e6fea02 100644 --- a/ircd/m_join.c +++ b/ircd/m_join.c @@ -316,8 +316,7 @@ int ms_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) char *name; if (IsServer(sptr)) { - Debug((DEBUG_ERROR, "%s tried to JOIN a channel", sptr->name)); - return 0; + return protocol_violation(sptr,"%s tried to JOIN a channel, duh!", sptr->name); } if (parc < 2 || *parv[1] == '\0') diff --git a/ircd/m_kill.c b/ircd/m_kill.c index b8dd100..4ed73db 100644 --- a/ircd/m_kill.c +++ b/ircd/m_kill.c @@ -176,8 +176,8 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) inpath = cptr->name; sendto_opmask_butone(0, IsServer(sptr) ? SNO_SERVKILL : SNO_OPERKILL, - "Received KILL message for %C. From %s Path: %C!%s", - victim, parv[0], cptr, path); + "Received KILL message for %s. From %s Path: %C!%s", + get_client_name(victim,SHOW_IP), parv[0], cptr, path); #if defined(SYSLOG_KILL) ircd_log_kill(victim, sptr, cptr->name, path); @@ -222,7 +222,7 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * anyway (as this user don't exist there any more either) */ if (MyConnect(victim)) - sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s!%s", victim, cptr->name, + sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s!%s", victim, NumServ(cptr), path); /* * the first space in path will be at the end of the @@ -337,7 +337,7 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ sendto_opmask_butone(0, SNO_OPERKILL, "Received KILL message for %s. From %s Path: %s!%s", - victim->name, parv[0], inpath, path); + get_client_name(victim,SHOW_IP), parv[0], inpath, path); #if defined(SYSLOG_KILL) ircd_log_kill(victim, sptr, inpath, path); diff --git a/ircd/m_map.c b/ircd/m_map.c index e420ea1..77192e9 100644 --- a/ircd/m_map.c +++ b/ircd/m_map.c @@ -90,12 +90,71 @@ #include "client.h" #include "ircd.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" -#include "map.h" +#include "list.h" +#include "match.h" #include "numeric.h" +#include "s_user.h" +#include "s_serv.h" #include "send.h" +#include "querycmds.h" #include +#include + +static void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length) +{ + static char prompt[64]; + struct DLink *lp; + char *p = &prompt[prompt_length]; + int cnt = 0; + + *p = '\0'; + if (prompt_length > 60) + send_reply(cptr, RPL_MAPMORE, prompt, server->name); + else { + char lag[512]; + if (server->serv->lag>10000) + lag[0]=0; + else if (server->serv->lag<0) + strcpy(lag,"(0s)"); + else + sprintf(lag,"(%is)",server->serv->lag); + send_reply(cptr, RPL_MAP, prompt, ( + (IsBurst(server)) ? "*" : (IsBurstAck(server) ? "!" : "")), + server->name, lag, (server == &me) ? UserStats.local_clients : + server->serv->clients); + } + if (prompt_length > 0) + { + p[-1] = ' '; + if (p[-2] == '`') + p[-2] = ' '; + } + if (prompt_length > 60) + return; + strcpy(p, "|-"); + for (lp = server->serv->down; lp; lp = lp->next) + if (match(mask, lp->value.cptr->name)) + lp->value.cptr->flags &= ~FLAGS_MAP; + else + { + lp->value.cptr->flags |= FLAGS_MAP; + cnt++; + } + for (lp = server->serv->down; lp; lp = lp->next) + { + if ((lp->value.cptr->flags & FLAGS_MAP) == 0) + continue; + if (--cnt == 0) + *p = '`'; + dump_map(cptr, lp->value.cptr, mask, prompt_length + 2); + } + if (prompt_length > 0) + p[-1] = '-'; +} + /* * m_map - generic message handler diff --git a/ircd/m_motd.c b/ircd/m_motd.c index 3b03a51..966a8b6 100644 --- a/ircd/m_motd.c +++ b/ircd/m_motd.c @@ -96,9 +96,11 @@ #include "numeric.h" #include "numnicks.h" #include "s_conf.h" +#include "class.h" #include "s_user.h" #include "send.h" +#include #include /* @@ -123,6 +125,7 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) struct TRecord *ptr; int count; struct MotdItem *temp; + int class = get_client_class(sptr); #ifdef NODEFAULTMOTD int no_motd; @@ -142,30 +145,25 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) no_motd = 1; } #endif - - /* - * Find out if this is a remote query or if we have a T line for our hostname + /* 2.10.11: Allow per Class T:'s + * -- Isomer 2000-11-19 */ - if (IsServer(cptr)) + for (ptr = tdata; ptr; ptr = ptr->next) { - tm = 0; /* Remote MOTD */ - temp = rmotd; - } - else - { - for (ptr = tdata; ptr; ptr = ptr->next) - { - if (!match(ptr->hostmask, cptr->sockhost)) + if (IsDigit(*ptr->hostmask)) { + if (atoi(ptr->hostmask)==class) break; } - if (ptr) - { - temp = ptr->tmotd; - tm = &ptr->tmotd_tm; - } - else - temp = motd; + else if (!match(ptr->hostmask, cptr->sockhost)) + break; } + if (ptr) + { + temp = ptr->tmotd; + tm = &ptr->tmotd_tm; + } + else + temp = motd; if (temp == 0) { send_reply(sptr, ERR_NOMOTD); diff --git a/ircd/m_notice.c b/ircd/m_notice.c index 2022972..1ecc885 100644 --- a/ircd/m_notice.c +++ b/ircd/m_notice.c @@ -167,7 +167,7 @@ int ms_notice(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) /* * we can't deliver it, sending an error back is pointless */ - return 0; + return protocol_violation(sptr,"Not enough params for NOTICE"); } name = parv[1]; /* diff --git a/ircd/m_pass.c b/ircd/m_pass.c index 2087118..c436ec8 100644 --- a/ircd/m_pass.c +++ b/ircd/m_pass.c @@ -97,7 +97,7 @@ /* * mr_pass - registration message handler */ -int m_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { const char* password = parc > 1 ? parv[1] : 0; @@ -108,6 +108,12 @@ int m_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (EmptyString(password)) return need_more_params(cptr, "PASS"); + /* TODO: For protocol negotiation */ +#if 0 + if (ircd_strcmp(password,"PROT")==0) { + /* Do something here */ + } +#endif ircd_strncpy(cptr->passwd, password, PASSWDLEN); return 0; } diff --git a/ircd/m_pong.c b/ircd/m_pong.c index bed2412..64a4e81 100644 --- a/ircd/m_pong.c +++ b/ircd/m_pong.c @@ -124,7 +124,7 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); /* XXX DEAD */ #endif - return 0; + return protocol_violation(sptr,"No Origin on PONG"); } origin = parv[1]; destination = parv[2]; diff --git a/ircd/m_quit.c b/ircd/m_quit.c index bc49038..3c45f88 100644 --- a/ircd/m_quit.c +++ b/ircd/m_quit.c @@ -92,6 +92,7 @@ #include "ircd_string.h" #include "struct.h" #include "s_misc.h" +#include "ircd_reply.h" #include #include @@ -140,10 +141,14 @@ int ms_quit(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { assert(0 != sptr); assert(parc > 0); + if (IsServer(sptr)) { + protocol_violation(sptr,"Server QUIT, not SQUIT?"); + return 0; + } /* * ignore quit from servers */ - return IsServer(sptr) ? 0 : exit_client(cptr, sptr, sptr, parv[parc - 1]); + return exit_client(cptr, sptr, sptr, parv[parc - 1]); } #if 0 diff --git a/ircd/m_rehash.c b/ircd/m_rehash.c index 0d2358a..de38a9c 100644 --- a/ircd/m_rehash.c +++ b/ircd/m_rehash.c @@ -100,6 +100,8 @@ /* * mo_rehash - oper message handler + * + * parv[1] = 'q' to not rehash the resolver (optional) */ int mo_rehash(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { diff --git a/ircd/m_rping.c b/ircd/m_rping.c index 905dbf5..4fdabd6 100644 --- a/ircd/m_rping.c +++ b/ircd/m_rping.c @@ -160,9 +160,6 @@ int ms_rping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } else { if (parc < 3) { - /* - * PROTOCOL ERROR - */ return need_more_params(sptr, "RPING"); } /* diff --git a/ircd/m_server.c b/ircd/m_server.c index b0af144..9c072dc 100644 --- a/ircd/m_server.c +++ b/ircd/m_server.c @@ -157,7 +157,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc < 7) { - return need_more_params(sptr, "SERVER"); + need_more_params(sptr, "SERVER"); return exit_client(cptr, cptr, &me, "Need more parameters"); } host = parv[1]; diff --git a/ircd/m_silence.c b/ircd/m_silence.c index 25867e9..6451d98 100644 --- a/ircd/m_silence.c +++ b/ircd/m_silence.c @@ -170,12 +170,9 @@ int ms_silence(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) struct Client* acptr; if (IsServer(sptr)) { - /* PROTOCOL WARNING */ - /* bail, don't core */ - return 0; + return protocol_violation(sptr,"Server trying to silence a user"); } if (parc < 3 || EmptyString(parv[2])) { - /* PROTOCOL WARNING */ return need_more_params(sptr, "SILENCE"); } diff --git a/ircd/m_topic.c b/ircd/m_topic.c index 2b7756e..300536e 100644 --- a/ircd/m_topic.c +++ b/ircd/m_topic.c @@ -220,13 +220,13 @@ int ms_topic(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) /* Modeless Channels don't have topics */ if (IsModelessChannel(name)) { - /* Protocol Violation? */ + protocol_violation(sptr,"Attempted to topic modeless channel"); send_reply(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname); continue; } /* Ignore requests for topics from remote servers */ if (IsLocalChannel(name) && !MyUser(sptr)) - /* Protocol Violation warning here? */ + protocol_violation(sptr,"Topic request"); continue; do_settopic(sptr,cptr,chptr,topic); diff --git a/ircd/m_version.c b/ircd/m_version.c index b782791..b1b3f24 100644 --- a/ircd/m_version.c +++ b/ircd/m_version.c @@ -160,12 +160,7 @@ int ms_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (hunt_server_cmd(sptr, CMD_VERSION, cptr, 0, ":%C", 1, parc, parv) == HUNTED_ISME) { - char featurebuf[512]; - - sprintf_irc(featurebuf,FEATURES,FEATURESVALUES); - send_reply(sptr, RPL_VERSION, version, debugmode, me.name, serveropts); - send_reply(sptr, RPL_ISUPPORT, featurebuf); } return 0; diff --git a/ircd/m_wallops.c b/ircd/m_wallops.c index 2e5ad2f..865fed8 100644 --- a/ircd/m_wallops.c +++ b/ircd/m_wallops.c @@ -148,7 +148,7 @@ int m_wallops(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) if (BadPtr(message)) return need_more_params(sptr, "WALLOPS"); - if (!IsServer(sptr) && MyConnect(sptr) && !IsAnOper(sptr)) + if (!IsAnOper(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); /* XXX DEAD */ return 0; diff --git a/ircd/map.c b/ircd/map.c deleted file mode 100644 index 07b7c68..0000000 --- a/ircd/map.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * IRC - Internet Relay Chat, ircd/map.c - * Copyright (C) 1994 Carlo Wood ( Run @ undernet.org ) - * - * 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$ - */ -#include "map.h" -#include "client.h" -#include "ircd.h" -#include "ircd_reply.h" -#include "list.h" -#include "match.h" -#include "numeric.h" -#include "numnicks.h" -#include "querycmds.h" -#include "send.h" -#include "struct.h" - -#include /* sprintf */ -#include - -void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length) -{ - static char prompt[64]; - struct DLink *lp; - char *p = &prompt[prompt_length]; - int cnt = 0; - - *p = '\0'; - if (prompt_length > 60) - send_reply(cptr, RPL_MAPMORE, prompt, server->name); - else { - char lag[512]; - if (server->serv->lag>10000) - lag[0]=0; - else if (server->serv->lag<0) - strcpy(lag,"(0s)"); - else - sprintf(lag,"(%is)",server->serv->lag); - send_reply(cptr, RPL_MAP, prompt, ((IsBurstOrBurstAck(server)) ? "*" : ""), - server->name, lag, (server == &me) ? UserStats.local_clients : - server->serv->clients); - } - if (prompt_length > 0) - { - p[-1] = ' '; - if (p[-2] == '`') - p[-2] = ' '; - } - if (prompt_length > 60) - return; - strcpy(p, "|-"); - for (lp = server->serv->down; lp; lp = lp->next) - if (match(mask, lp->value.cptr->name)) - lp->value.cptr->flags &= ~FLAGS_MAP; - else - { - lp->value.cptr->flags |= FLAGS_MAP; - cnt++; - } - for (lp = server->serv->down; lp; lp = lp->next) - { - if ((lp->value.cptr->flags & FLAGS_MAP) == 0) - continue; - if (--cnt == 0) - *p = '`'; - dump_map(cptr, lp->value.cptr, mask, prompt_length + 2); - } - if (prompt_length > 0) - p[-1] = '-'; -} - -#if 0 -/* - * m_map -- by Run - * - * parv[0] = sender prefix - * parv[1] = server mask - */ -int m_map(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - if (parc < 2) - parv[1] = "*"; - - dump_map(sptr, &me, parv[1], 0); - sendto_one(sptr, rpl_str(RPL_MAPEND), me.name, parv[0]); /* XXX DEAD */ - - return 0; -} -#endif /* 0 */ - diff --git a/ircd/parse.c b/ircd/parse.c index b2c7657..7fb9571 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -29,7 +29,6 @@ #include "ircd_chattr.h" #include "ircd_reply.h" #include "ircd_string.h" -#include "map.h" #include "msg.h" #include "numeric.h" #include "numnicks.h" @@ -207,7 +206,7 @@ struct Message msgtab[] = { TOK_ERROR, 0, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, /* UNREG, CLIENT, SERVER, OPER, SERVICE */ - { mr_error, m_ignore, ms_error, m_ignore, m_ignore } + { m_ignore, m_ignore, ms_error, m_ignore, m_ignore } }, { MSG_KILL, @@ -312,7 +311,7 @@ struct Message msgtab[] = { TOK_PASS, 0, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, /* UNREG, CLIENT, SERVER, OPER, SERVICE */ - { m_pass, m_registered, m_ignore, m_registered, m_ignore } + { mr_pass, m_registered, m_ignore, m_registered, m_ignore } }, { MSG_LUSERS, @@ -707,7 +706,7 @@ void initmsgtree(void) int ii; struct Message **msgtab_tok; struct Message **msgtok; - + for (i = 0; msg->cmd; ++i, ++msg) continue; qsort(msgtab, i, sizeof(struct Message), diff --git a/ircd/s_stats.c b/ircd/s_stats.c index 87591d9..f233392 100644 --- a/ircd/s_stats.c +++ b/ircd/s_stats.c @@ -170,6 +170,10 @@ void report_deny_list(struct Client* to) * hunt_server() possiblites were becoming very messy. It now uses a * switch() so as to be easier to read and update as params change. * -Ghostwolf + * + * 2.10.11: Don't check for the oper limitation if it's not our local server. + * thusly once all the hubs have upgraded local opers will be able + * to remote stats anywhere on the network. */ int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[], char stat) { @@ -201,16 +205,16 @@ int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[], case 'M': { if (parc == 4) - return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s %C :%s", 2, parc, parv); + return hunt_server_cmd(sptr, CMD_STATS, cptr, MyUser(sptr) ? 1 : 0, "%s %C :%s", 2, parc, parv); else if (parc > 4) - return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s %C %s :%s", 2, parc, parv); + return hunt_server_cmd(sptr, CMD_STATS, cptr, MyUser(sptr) ? 1 : 0, "%s %C %s :%s", 2, parc, parv); else - return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s :%C", 2, parc, parv); + return hunt_server_cmd(sptr, CMD_STATS, cptr, MyUser(sptr) ? 1 : 0, "%s :%C", 2, parc, parv); } /* oper only, standard # of params */ default: - return hunt_server_cmd(sptr, CMD_STATS, cptr, 1, "%s :%C", 2, parc, parv); + return hunt_server_cmd(sptr, CMD_STATS, cptr, MyUser(sptr) ? 1 : 0, "%s :%C", 2, parc, parv); } } -- 2.20.1