[IRC-Dev CVS] [CVS] Module ircdh: Change committed
Brought to you by:
zolty
From: Zolty <zo...@us...> - 2002-10-24 09:59:52
|
CVSROOT : /cvsroot/irc-dev Module : ircdh Commit time: 2002-10-24 09:59:51 UTC Added files: ircd/m_admin.c ircd/m_rename.c Log message: 2002-10-24 Toni Garcia <zo...@ir...> 1.0.alpha10 Faltaban 2 archivos :) ---------------------- diff included ---------------------- Index: ircdh/ircd/m_admin.c diff -u /dev/null ircdh/ircd/m_admin.c:1.1 --- /dev/null Thu Oct 24 02:59:51 2002 +++ ircdh/ircd/m_admin.c Thu Oct 24 02:59:41 2002 @@ -0,0 +1,170 @@ +/* + * IRC - Internet Relay Chat, ircd/m_admin.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_admin.c,v 1.1 2002/10/24 09:59:41 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 "client.h" +#include "ircd.h" +#include "ircd_reply.h" +#include "msg.h" +#include "numeric.h" +#include "numnicks.h" +#include "s_conf.h" +#include "s_user.h" +#include "send.h" + +#include <assert.h> + +/* + * m_admin - generic message handler + * + * parv[0] = sender prefix + * parv[1] = servername + */ +int m_admin(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + assert(0 != cptr); + assert(cptr == sptr); + + if (parc > 1) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, sptr->name); + return 0; + } + + return send_admin_info(sptr, find_admin()); +} + +#define HEAD_IN_SAND_REMOTE 0 /* Provisional */ +/* + * mo_admin - oper message handler + * + * parv[0] = sender prefix + * parv[1] = servername + */ +int mo_admin(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + assert(0 != cptr); + assert(cptr == sptr); + + if (parc > 1) + { + struct Client *acptr; + if (!(acptr = find_match_server(parv[1]))) + return send_error_to_client(sptr, ERR_NOSUCHSERVER, parv[1]); + + parv[1] = acptr->name; +#ifdef P09_SUPPORT + if (hunt_server(HEAD_IN_SAND_REMOTE, cptr, sptr, ":%s " MSG_ADMIN " :%s", + 1, parc, parv) != HUNTED_ISME) +#else + if (hunt_server(HEAD_IN_SAND_REMOTE, cptr, sptr, "%s%s " TOK_ADMIN " :%s", + 1, parc, parv) != HUNTED_ISME) +#endif + return 0; + } + return send_admin_info(sptr, find_admin()); +} + + +/* + * ms_admin - server message handler + * + * parv[0] = sender prefix + * parv[1] = servername + */ +int ms_admin(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + assert(0 != cptr); + assert(0 != sptr); + + if (parc < 2) + return 0; + +#ifdef P09_SUPPORT + if (hunt_server(0, cptr, sptr, ":%s " MSG_ADMIN " :%s", 1, parc, + parv) != HUNTED_ISME) +#else + if (hunt_server(0, cptr, sptr, "%s%s " TOK_ADMIN " :%s", 1, parc, + parv) != HUNTED_ISME) +#endif + return 0; + + return send_admin_info(sptr, find_admin()); +} Index: ircdh/ircd/m_rename.c diff -u /dev/null ircdh/ircd/m_rename.c:1.1 --- /dev/null Thu Oct 24 02:59:51 2002 +++ ircdh/ircd/m_rename.c Thu Oct 24 02:59:41 2002 @@ -0,0 +1,237 @@ +/* + * IRC - Internet Relay Chat, ircd/m_rename.c + * Copyright (C) 2000 IRC-Hispano.org - ESNET - jcea + * + * 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_rename.c,v 1.1 2002/10/24 09:59:41 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 "client.h" + +#include <assert.h> + +#ifdef BDD +int m_rename(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + char buf[NICKLEN + 2]; + char buf2[NICKLEN + 1024]; + aClient *acptr; + aClient *bcptr; + char nick[NICKLEN + 2]; + + if (!IsServer(cptr) || !IsServer(sptr) || parc != 2) + return 0; + + if (!find_conf_host(cptr->confs, sptr->name, CONF_UWORLD) + || (sptr->from != cptr)) + { + sendto_serv_butone(cptr, + ":%s DESYNC :HACK(4): El nodo '%s' dice que '%s' solicita " + "cambio de nick para '%s'", me.name, cptr->name, sptr->name, parv[1]); + sendto_op_mask(SNO_HACK4 | SNO_SERVKILL | SNO_RENAME | SNO_RENAME2, + "HACK(4): El nodo '%s' dice que '%s' solicita " + "cambio de nick para '%s'", cptr->name, sptr->name, parv[1]); + return 0; + } + +#ifdef P09_SUPPORT + sendto_serv_butone(cptr, ":%s RENAME :%s", sptr->name, parv[1]); + sendto_serv_butone(cptr, ":%s RENAME :%s", sptr->name, parv[1]); +#else + sendto_serv_butone(cptr, ":%s RENAME :%s", sptr -, parv[1]); +#endif + + sendto_op_mask(SNO_RENAME, + "El nodo '%s' solicita un cambio de nick para '%s'", sptr->name, parv[1]); + + strncpy(buf, parv[1], sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + + if (!do_nick_name(buf)) + return 0; + + if (FindServer(buf)) + return 0; + + acptr = FindClient(buf); + + if (!acptr || !MyConnect(acptr)) + return 0; + + { + unsigned int v[2], k[2], x[2]; + + k[0] = k[1] = x[0] = x[1] = 0; + + v[0] = base64toint(acptr->yxx); + v[1] = base64toint(me.yxx); + + bcptr = acptr; + + do + { + tea(v, k, x); + v[1] += 4096; +/* +** El 'if' que sigue lo necesitamos +** para que todos los valores tengan +** la misma probabilidad. +*/ + if (x[0] >= 4294000000ul) + continue; + sprintf_irc(nick, "inv%.6d", (int)(x[0] % 1000000)); + bcptr = FindClient(nick); + } + while (bcptr); + } + + sendto_op_mask(SNO_RENAME | SNO_RENAME2, + "Cambiamos el nick '%s' a '%s', a peticion del nodo '%s'", parv[1], nick, + sptr->name); + + { + static void send_umode_out(struct Client *a, struct Client *b, int c, int d, + int e); + int of, oh; + + of = acptr->flags; + oh = acptr->hmodes; + + if (IsNickRegistered(acptr) || IsNickSuspended(acptr)) + { /* Parche DB69 */ + ClearNickRegistered(acptr); + ClearNickSuspended(acptr); + ClearHelpOp(acptr); +#if defined(BDD) && defined(BDD_VIP) +#if !defined(BDD_VIP2) + if (MyConnect(acptr)) + { + if (!db_buscar_registro(BDD_IPVIRTUAL2DB, acptr->name) + && !db_buscar_registro(BDD_IPVIRTUALDB, acptr->name)) + { + ClearHidden(acptr); + } + } +#endif +#endif + if (!IsAnOper(acptr)) + ClearHiddenViewer(acptr); + send_umode_out(cptr, acptr, of, oh, IsRegistered(acptr)); + } + } + + acptr->lastnick = now; + + /* Esto manda una copia al propio usuario */ + sendto_common_channels(acptr, ":%s " MSG_NICK " :%s", acptr->name, nick); + add_history(acptr, 1); + +#ifdef P09_SUPPORT + sendto_lowprot_butone(cptr, 9, + ":%s " MSG_NICK " %s " TIME_T_FMT, acptr->name, nick, acptr->lastnick); + sendto_highprot_butone(cptr, 10, + "%s%s " MSG_NICK " %s " TIME_T_FMT, NumNick(acptr), nick, + acptr->lastnick); +#else + sendto_serv_butone(cptr, + "%s%s " TOK_NICK " %s " TIME_T_FMT, NumNick(acptr), nick, + acptr->lastnick); +#endif + + if (acptr->name[0]) + { + hRemClient(acptr); + /* + * Avisamos a sus contactos que el nick + * ha salido (ha cambiado de nick). + */ + chequea_estado_watch(acptr, RPL_LOGOFF, NULL, NULL); + + } + strcpy(acptr->name, nick); + hAddClient(acptr); + +#ifdef BDD_VIP + acptr->user->virtualhost[0] = '\0'; +#endif + /* + * Avisamos a sus contactos que el nick + * ha entrado (ha cambiado de nick). + */ + chequea_estado_watch(acptr, RPL_LOGON, NULL, NULL); + + return 0; +} +#endif ----------------------- End of diff ----------------------- |