[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2005-03-31 12:58:23
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2005-03-31 12:58:15 UTC Modified files: ChangeLog ChangeLog.es include/client.h include/ddb.h include/handlers.h include/ircd_features.h include/msg.h include/numeric.h include/patchlevel.h include/s_user.h include/send.h ircd/Makefile.in ircd/ircd_features.c ircd/m_nick.c ircd/m_whois.c ircd/parse.c ircd/s_err.c ircd/s_user.c ircd/send.c ircd/whocmds.c Added files: ircd/m_ghost.c ircd/m_svsnick.c Log message: Author: zoltan <zo...@ir...> Log message: 2005-03-30 Toni García <zo...@ir...> 1.0.alpha23 * Soporte de tabla n (NICKDB) * Modo de usuario +r * Modo de usuario +S * Modificaciones en comando NICK * Comando GHOST * Comando SVSNICK ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.24 ircd-ircdev/ChangeLog:1.25 --- ircd-ircdev/ChangeLog:1.24 Wed Mar 23 10:34:15 2005 +++ ircd-ircdev/ChangeLog Thu Mar 31 04:58:01 2005 @@ -1,10 +1,18 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.24 2005/03/23 18:34:15 zolty Exp $ +# $Id: ChangeLog,v 1.25 2005/03/31 12:58:01 zolty Exp $ # # Insert new changes at beginning of the change list. # +2005-03-30 Toni García <zo...@ir...> 1.0.alpha23 + * Table n (NICKDB) support + * Usermode +r + * Usermode +S + * NICK command modifies + * GHOST command + * SVSNICK command + 2005-03-23 Toni García <zo...@ir...> 1.0.alpha22 * Distributed DataBase support in memory * DB command Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.24 ircd-ircdev/ChangeLog.es:1.25 --- ircd-ircdev/ChangeLog.es:1.24 Wed Mar 23 10:34:15 2005 +++ ircd-ircdev/ChangeLog.es Thu Mar 31 04:58:01 2005 @@ -1,10 +1,18 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.24 2005/03/23 18:34:15 zolty Exp $ +# $Id: ChangeLog.es,v 1.25 2005/03/31 12:58:01 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2005-03-30 Toni García <zo...@ir...> 1.0.alpha23 + * Soporte de tabla n (NICKDB) + * Modo de usuario +r + * Modo de usuario +S + * Modificaciones en comando NICK + * Comando GHOST + * Comando SVSNICK + 2005-03-23 Toni García <zo...@ir...> 1.0.alpha22 * Soporte de Bases de Datos Distribuidas en memoria * Comando DB Index: ircd-ircdev/include/client.h diff -u ircd-ircdev/include/client.h:1.12 ircd-ircdev/include/client.h:1.13 --- ircd-ircdev/include/client.h:1.12 Wed Mar 23 10:34:24 2005 +++ ircd-ircdev/include/client.h Thu Mar 31 04:58:02 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Structures and functions for handling local clients. - * @version $Id: client.h,v 1.12 2005/03/23 18:34:24 zolty Exp $ + * @version $Id: client.h,v 1.13 2005/03/31 12:58:02 zolty Exp $ */ #ifndef INCLUDED_client_h #define INCLUDED_client_h @@ -93,7 +93,11 @@ #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag)) /** String containing valid user modes, in no particular order. */ +#if defined(DDB) || defined(SERVICES) +#define infousermodes "dioswkgxrS" +#else #define infousermodes "dioswkgx" +#endif /** Operator privileges. */ enum Priv @@ -173,6 +177,9 @@ FLAG_DEBUG, /**< send global debug/anti-hack info */ #if defined(UNDERNET) FLAG_ACCOUNT, /**< account name has been set */ +#elif defined(DDB) || defined(SERVICES) + FLAG_NICKREG, /**< nick registered */ + FLAG_NICKSUSPEND, /**< nick suspended */ #endif FLAG_HIDDENHOST, /**< user's host is hidden */ FLAG_LAST_FLAG, /**< number of flags */ @@ -614,12 +621,20 @@ #define IsIPv6(x) HasFlag(x, FLAG_IPV6) /** Return non-zero if the client claims to be a services server. */ #define IsService(x) HasFlag(x, FLAG_SERVICE) +#if defined(UNDERNET) /** Return non-zero if the client has an account stamp. */ #define IsAccount(x) HasFlag(x, FLAG_ACCOUNT) +#endif /** Return non-zero if the client has set mode +x (hidden host). */ #define IsHiddenHost(x) HasFlag(x, FLAG_HIDDENHOST) /** Return non-zero if the client has an active PING request. */ #define IsPingSent(x) HasFlag(x, FLAG_PINGSENT) +#if defined(DDB) || defined(SERVICES) +/** Return non-zero if the client has set mode +r (nick registered) */ +#define IsNickRegistered(x) HasFlag(x, FLAG_NICKREG) +/** Return non-zero if the client has set mode +S (nick suspended) */ +#define IsNickSuspended(x) HasFlag(x, FLAG_NICKSUSPEND) +#endif /** Return non-zero if the client has operator or server privileges. */ #define IsPrivileged(x) (IsAnOper(x) || IsServer(x)) @@ -666,12 +681,20 @@ #define SetIPv6(x) SetFlag(x, FLAG_IPV6) /** Mark a client as being a services server. */ #define SetService(x) SetFlag(x, FLAG_SERVICE) +#if defined(UNDERNET) /** Mark a client as having an account stamp. */ #define SetAccount(x) SetFlag(x, FLAG_ACCOUNT) +#endif /** Mark a client as having mode +x (hidden host). */ #define SetHiddenHost(x) SetFlag(x, FLAG_HIDDENHOST) /** Mark a client as having a pending PING. */ #define SetPingSent(x) SetFlag(x, FLAG_PINGSENT) +#if defined(DDB) || defined(SERVICES) +/** Mark a client as having mode +r (nick registered) */ +#define SetNickRegistered(x) SetFlag(x, FLAG_NICKREG) +/** Mark a client as having mode +S (nick suspended) */ +#define SetNickSuspended(x) SetFlag(x, FLAG_NICKSUSPEND) +#endif /** Return non-zero if \a sptr sees \a acptr as an operator. */ #define SeeOper(sptr,acptr) (IsAnOper(acptr) && (HasPriv(acptr, PRIV_DISPLAY) \ @@ -705,6 +728,12 @@ #define ClearHiddenHost(x) ClrFlag(x, FLAG_HIDDENHOST) /** Clear the client's pending PING flag. */ #define ClearPingSent(x) ClrFlag(x, FLAG_PINGSENT) +#if defined(DDB) || defined(SERVICES) +/** Remove mode +r (nick registered) from the client */ +#define ClearNickRegistered(x) ClrFlag(x, FLAG_NICKREG) +/** Remode mode +S (nick suspended) from the client */ +#define ClearNickSuspended(x) ClrFlag(x, FLAG_NICKSUSPEND) +#endif /* free flags */ #define FREEFLAG_SOCKET 0x0001 /**< socket needs to be freed */ Index: ircd-ircdev/include/ddb.h diff -u ircd-ircdev/include/ddb.h:1.3 ircd-ircdev/include/ddb.h:1.4 --- ircd-ircdev/include/ddb.h:1.3 Wed Mar 23 10:34:25 2005 +++ ircd-ircdev/include/ddb.h Thu Mar 31 04:58:02 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ddb.h,v 1.3 2005/03/23 18:34:25 zolty Exp $ + * $Id: ddb.h,v 1.4 2005/03/31 12:58:02 zolty Exp $ * */ #ifndef INCLUDED_ddb_h @@ -51,6 +51,12 @@ /* + * PseudoBots + */ +#define DDB_NICKSERV "NickServ" + + +/* * Structures */ struct Ddb { @@ -136,7 +142,7 @@ extern struct Ddb *ddb_iterator_first(unsigned char table); extern struct Ddb *ddb_iterator_next(void); extern struct Ddb *ddb_find_key(unsigned char table, char *key); -extern char *ddb_get_botname(char *bot); +extern char *ddb_get_botname(char *botname); extern void ddb_splithubs_butone(struct Client *cptr, char *exitmsg); extern void ddb_reload(void); Index: ircd-ircdev/include/handlers.h diff -u ircd-ircdev/include/handlers.h:1.10 ircd-ircdev/include/handlers.h:1.11 --- ircd-ircdev/include/handlers.h:1.10 Mon Jan 10 04:21:59 2005 +++ ircd-ircdev/include/handlers.h Thu Mar 31 04:58:02 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Declarations for all protocol message handler functions. - * @version $Id: handlers.h,v 1.10 2005/01/10 12:21:59 zolty Exp $ + * @version $Id: handlers.h,v 1.11 2005/03/31 12:58:02 zolty Exp $ */ #ifndef INCLUDED_handlers_h #define INCLUDED_handlers_h @@ -96,6 +96,7 @@ extern int m_cap(struct Client*, struct Client*, int, char*[]); extern int m_cnotice(struct Client*, struct Client*, int, char*[]); extern int m_cprivmsg(struct Client*, struct Client*, int, char*[]); +extern int m_ghost(struct Client*, struct Client*, int, char*[]); extern int m_gline(struct Client*, struct Client*, int, char*[]); extern int m_help(struct Client*, struct Client*, int, char*[]); extern int m_ignore(struct Client*, struct Client*, int, char*[]); @@ -236,6 +237,7 @@ extern int ms_silence(struct Client*, struct Client*, int, char*[]); extern int ms_squit(struct Client*, struct Client*, int, char*[]); extern int ms_stats(struct Client*, struct Client*, int, char*[]); +extern int ms_svsnick(struct Client*, struct Client*, int, char*[]); extern int ms_topic(struct Client*, struct Client*, int, char*[]); extern int ms_trace(struct Client*, struct Client*, int, char*[]); extern int ms_uping(struct Client*, struct Client*, int, char*[]); Index: ircd-ircdev/include/ircd_features.h diff -u ircd-ircdev/include/ircd_features.h:1.10 ircd-ircdev/include/ircd_features.h:1.11 --- ircd-ircdev/include/ircd_features.h:1.10 Wed Mar 23 10:34:25 2005 +++ ircd-ircdev/include/ircd_features.h Thu Mar 31 04:58:02 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Public interfaces and declarations for dealing with configurable features. - * @version $Id: ircd_features.h,v 1.10 2005/03/23 18:34:25 zolty Exp $ + * @version $Id: ircd_features.h,v 1.11 2005/03/31 12:58:02 zolty Exp $ */ #ifndef INCLUDED_features_h #define INCLUDED_features_h @@ -88,6 +88,9 @@ FEAT_MPATH, FEAT_RPATH, FEAT_PPATH, +#if defined(DDB) + FEAT_DDBPATH, +#endif /* Networking features */ FEAT_TOS_SERVER, Index: ircd-ircdev/include/msg.h diff -u ircd-ircdev/include/msg.h:1.10 ircd-ircdev/include/msg.h:1.11 --- ircd-ircdev/include/msg.h:1.10 Wed Mar 23 10:34:26 2005 +++ ircd-ircdev/include/msg.h Thu Mar 31 04:58:02 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Command and token declarations and structures. - * @version $Id: msg.h,v 1.10 2005/03/23 18:34:26 zolty Exp $ + * @version $Id: msg.h,v 1.11 2005/03/31 12:58:02 zolty Exp $ */ #ifndef INCLUDED_msg_h #define INCLUDED_msg_h @@ -377,6 +377,15 @@ #define TOK_DBQ "DBQ" #define CMD_DBQ MSG_DBQ, TOK_DBQ +#define MSG_GHOST "GHOST" /* GHOST */ +#define TOK_GHOST "GHOST" +#define CMD_GHOST MSG_GHOST, TOK_GHOST + +#define MSG_SVSNICK "SVSNICK" /* SVSN */ +#define TOK_SVSNICK "SN" +#define CMD_SVSNICK MSG_SVSNICK, TOK_SVSNICK + + /* * Constants Index: ircd-ircdev/include/numeric.h diff -u ircd-ircdev/include/numeric.h:1.9 ircd-ircdev/include/numeric.h:1.10 --- ircd-ircdev/include/numeric.h:1.9 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/numeric.h Thu Mar 31 04:58:02 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Declarations of numeric replies and supporting functions. - * @version $Id: numeric.h,v 1.9 2005/01/10 12:22:00 zolty Exp $ + * @version $Id: numeric.h,v 1.10 2005/03/31 12:58:02 zolty Exp $ */ #ifndef INCLUDED_numeric_h #define INCLUDED_numeric_h @@ -213,7 +213,7 @@ #define RPL_UNAWAY 305 #define RPL_NOWAWAY 306 /* NotAway, aircd */ -/* RPL_WHOISREGNICK 307 Numeric List: Dalnet */ +#define RPL_WHOISREGNICK 307 /* IRC-Dev, Dalnet, Unreal extension */ /* RPL_SUSERHOST 307 austnet */ /* RPL_NOTIFYACTION 308 aircd */ /* RPL_WHOISADMIN 308 Numeric List: Dalnet */ @@ -296,6 +296,7 @@ /* RPL_SPAM 377 austnet */ /* RPL_BANEXPIRED 378 aircd */ /* RPL_KICKLINKED 379 aircd */ +#define RPL_WHOISMODES 379 /* IRC-Dev, Unreal extension */ /* RPL_BANLINKED 380 aircd */ #define RPL_YOUREOPER 381 @@ -307,7 +308,8 @@ /* RPL_ENDOFQLIST 387 unreal */ /* RPL_ALIST 388 unreal */ /* RPL_ENDOFALIST 389 unreal */ - + +#define RPL_WHOISSUSPEND 390 /* IRC-Dev extension */ #define RPL_TIME 391 /* RPL_START_USERS 392 Dalnet/EFnet/IRCnet */ /* RPL_USERS 393 Dalnet/EFnet/IRCnet */ Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.24 ircd-ircdev/include/patchlevel.h:1.25 --- ircd-ircdev/include/patchlevel.h:1.24 Wed Mar 23 10:34:26 2005 +++ ircd-ircdev/include/patchlevel.h Thu Mar 31 04:58:03 2005 @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: patchlevel.h,v 1.24 2005/03/23 18:34:26 zolty Exp $ + * $Id: patchlevel.h,v 1.25 2005/03/31 12:58:03 zolty Exp $ * */ -#define PATCHLEVEL ".alpha22" +#define PATCHLEVEL ".alpha23" #define RELEASE "1.0" Index: ircd-ircdev/include/s_user.h diff -u ircd-ircdev/include/s_user.h:1.6 ircd-ircdev/include/s_user.h:1.7 --- ircd-ircdev/include/s_user.h:1.6 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/s_user.h Thu Mar 31 04:58:03 2005 @@ -21,7 +21,7 @@ */ /** @file s_user.h * @brief Miscellaneous user-related helper functions. - * @version $Id: s_user.h,v 1.6 2005/01/10 12:22:00 zolty Exp $ + * @version $Id: s_user.h,v 1.7 2005/03/31 12:58:03 zolty Exp $ */ #ifndef INCLUDED_s_user_h #define INCLUDED_s_user_h @@ -74,6 +74,25 @@ #define COOKIE_VERIFIED 0xffffffff /**< value for cli_cookie() to show completion */ +/* used in set_nick_name */ +#define NICK_EQUIVALENT 0x01 /** < Equivalent */ +#define NICK_RENAMED 0x02 /** < Rename */ +#if defined(DDB) +#define NICK_GHOST 0x04 /** < Ghost */ +#define NICK_IDENTIFY 0x08 /** < Identify */ +#endif /* defined(DDB) */ + +#define SetNickEquivalent(x) ((x) |= NICK_EQUIVALENT) +#define IsNickEquivalent(x) ((x) & NICK_EQUIVALENT) +#define SetRenamed(x) ((x) |= NICK_RENAMED) +#define IsRenamed(x) ((x) & NICK_RENAMED) +#if defined(DDB) +#define SetGhost(x) ((x) |= NICK_GHOST) +#define IsGhost(x) ((x) & NICK_GHOST) +#define SetIdentify(x) ((x) |= NICK_IDENTIFY) +#define IsIdentify(x) ((x) & NICK_IDENTIFY) +#endif /* defined(DDB) */ + /** Formatter function for send_user_info(). * @param who Client being displayed. * @param sptr Client requesting information. @@ -91,8 +110,12 @@ extern void user_count_memory(size_t* count_out, size_t* bytes_out); +#if defined(DDB) +extern int verify_pass_nick(char *nick, char *cryptpass, char *pass); +#endif +extern int do_nick_name(char* nick); extern int set_nick_name(struct Client* cptr, struct Client* sptr, - const char* nick, int parc, char* parv[]); + const char* nick, int parc, char* parv[], int flags); extern void send_umode_out(struct Client* cptr, struct Client* sptr, struct Flags* old, int prop); extern int whisper(struct Client* source, const char* nick, Index: ircd-ircdev/include/send.h diff -u ircd-ircdev/include/send.h:1.6 ircd-ircdev/include/send.h:1.7 --- ircd-ircdev/include/send.h:1.6 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/send.h Thu Mar 31 04:58:03 2005 @@ -21,7 +21,7 @@ */ /** @file send.h * @brief Send messages to certain targets. - * @version $Id: send.h,v 1.6 2005/01/10 12:22:00 zolty Exp $ + * @version $Id: send.h,v 1.7 2005/03/31 12:58:03 zolty Exp $ */ #ifndef INCLUDED_send_h #define INCLUDED_send_h @@ -56,6 +56,11 @@ */ extern void sendrawto_one(struct Client *to, const char *pattern, ...); +/* Send a bot command to one client */ +extern void sendcmdbotto_one(char *botname, const char *cmd, + const char *tok, struct Client *to, + const char *pattern, ...); + /* Send a command to one client */ extern void sendcmdto_one(struct Client *from, const char *cmd, const char *tok, struct Client *to, Index: ircd-ircdev/ircd/Makefile.in diff -u ircd-ircdev/ircd/Makefile.in:1.20 ircd-ircdev/ircd/Makefile.in:1.21 --- ircd-ircdev/ircd/Makefile.in:1.20 Wed Mar 23 10:34:27 2005 +++ ircd-ircdev/ircd/Makefile.in Thu Mar 31 04:58:03 2005 @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA -# $Id: Makefile.in,v 1.20 2005/03/23 18:34:27 zolty Exp $ +# $Id: Makefile.in,v 1.21 2005/03/31 12:58:03 zolty Exp $ #### Start of system configuration section. #### @@ -94,7 +94,12 @@ ddb.c \ ddb_db_template.c \ m_db.c \ - m_dbq.c + m_dbq.c \ + m_ghost.c \ + m_svsnick.c + +SERVICES_SRC = \ + m_svsnick.c IRCD_SRC = \ IPcheck.c \ @@ -229,15 +234,19 @@ whowas.c \ y.tab.c -#SRC = ${IRCD_SRC} ${ENGINE_C} ${CRYPTO_SRC} +#TODO Arreglar esto +#Para undernet #SRC = ${IRCD_SRC} ${UNDERNET_SRC} ${ENGINE_C} ${CRYPTO_SRC} +#Para DDb SRC = ${IRCD_SRC} ${DDB_SRC} ${ENGINE_C} ${CRYPTO_SRC} +#Para Services +#SRC = ${IRCD_SRC} ${SERVICES_SRC} ${ENGINE_C} ${CRYPTO_SRC} OBJS = ${SRC:%.c=%.o} UMKPASSWD_OBJS = ${UMKPASSWD_SRC:%.c=%.o} -DEP_SRC = ${IRCD_SRC} ${UNDERNET_SRC} ${DDB} ${ENGINE_SRC} ${CRYPTO_SRC} +DEP_SRC = ${IRCD_SRC} ${UNDERNET_SRC} ${DDB_SRC} ${SERVICES_SRC} ${ENGINE_SRC} ${CRYPTO_SRC} all: ( cd ..; make -f Makefile ) Index: ircd-ircdev/ircd/ircd_features.c diff -u ircd-ircdev/ircd/ircd_features.c:1.12 ircd-ircdev/ircd/ircd_features.c:1.13 --- ircd-ircdev/ircd/ircd_features.c:1.12 Wed Mar 23 10:34:48 2005 +++ ircd-ircdev/ircd/ircd_features.c Thu Mar 31 04:58:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of configurable feature support. - * @version $Id: ircd_features.c,v 1.12 2005/03/23 18:34:48 zolty Exp $ + * @version $Id: ircd_features.c,v 1.13 2005/03/31 12:58:04 zolty Exp $ */ #include "config.h" @@ -328,6 +328,9 @@ F_S(MPATH, FEAT_CASE | FEAT_MYOPER, "ircd.motd", motd_init), F_S(RPATH, FEAT_CASE | FEAT_MYOPER, "remote.motd", motd_init), F_S(PPATH, FEAT_CASE | FEAT_MYOPER | FEAT_READ, "ircd.pid", 0), +#if defined(DDB) + F_S(DDBPATH, FEAT_CASE | FEAT_MYOPER, "database", 0), +#endif /* Networking features */ F_I(TOS_SERVER, 0, 0x08, 0), Index: ircd-ircdev/ircd/m_ghost.c diff -u /dev/null ircd-ircdev/ircd/m_ghost.c:1.1 --- /dev/null Thu Mar 31 04:58:15 2005 +++ ircd-ircdev/ircd/m_ghost.c Thu Mar 31 04:58:04 2005 @@ -0,0 +1,125 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/m_ghost.c + * + * Copyright (C) 2002-2005 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2004 Toni Garcia (zoltan) <zo...@ir...> + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/** @file + * @brief Handlers for GHOST command. + * @version $Id: m_ghost.c,v 1.1 2005/03/31 12:58:04 zolty Exp $ + */ +#include "config.h" + +#include "client.h" +#include "ddb.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_log.h" +#include "ircd_reply.h" +#include "msg.h" +#include "numnicks.h" +#include "s_misc.h" +#include "s_user.h" +#include "send.h" + +/* #include <assert.h> -- Now using assert in ircd_log.h */ +#include <string.h> + + +/** Handle a GHOST command from a client. + * See @ref m_functions for general discussion of parameters. + * + * \a parv[1] is a nick + * \a parv[2] is a password (optional) + * + * @param[in] cptr Client that sent us the message. + * @param[in] sptr Original source of message. + * @param[in] parc Number of arguments. + * @param[in] parv Argument vector. + */ +int m_ghost(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + struct Client *acptr; + struct Ddb *ddb; + char *botname; + char *passwd; + + assert(0 != cptr); + assert(sptr == cptr); + + botname = ddb_get_botname(DDB_NICKSERV); + + if (parc < 2) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Sintaxis: /GHOST <nick> [password]", cptr); + return need_more_params(cptr, "GHOST"); + } + + if (parc < 3) + { + passwd = strchr(parv[1], ':'); + if (passwd) + *passwd++ = '\0'; + else + passwd = cli_passwd(cptr); + } + else + passwd = parv[2]; + + if (!(acptr = FindUser(parv[1]))) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** The nick %s is not in use.", cptr, parv[1]); + return 0; + } + + if (!(ddb = ddb_find_key(DDB_NICKDB, parv[1]))) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** The nick %s is not registered", cptr, parv[1]); + return 0; + } + + if (!(verify_pass_nick(ddb->key, ddb->content, passwd))) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Password incorrect", cptr); + return 0; + } + + sendto_opmask_butone(0, SNO_SERVKILL, + "Received KILL message for %C. From %C, Reason: GHOST kill", acptr, cptr); + + sendcmdto_serv_butone(&me, CMD_KILL, acptr, "%C :GHOST session released by %C", + acptr, cptr); + + if (MyConnect(acptr)) + { + sendcmdto_one(acptr, CMD_QUIT, cptr, ":Killed (GHOST session " + "released by %C)", cptr); + sendcmdto_one(&me, CMD_KILL, acptr, "%C :GHOST session released by %C", + acptr, cptr); + } + sendcmdbotto_one(botname, CMD_NOTICE, cptr, "%C :*** %C GHOST session has been " + "released", acptr, cptr); + exit_client_msg(cptr, acptr, &me, "Killed (GHOST session released by %C)", + cptr); + return 0; + +} Index: ircd-ircdev/ircd/m_nick.c diff -u ircd-ircdev/ircd/m_nick.c:1.8 ircd-ircdev/ircd/m_nick.c:1.9 --- ircd-ircdev/ircd/m_nick.c:1.8 Mon Mar 21 10:39:08 2005 +++ ircd-ircdev/ircd/m_nick.c Thu Mar 31 04:58:04 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_nick.c,v 1.8 2005/03/21 18:39:08 zolty Exp $ + * $Id: m_nick.c,v 1.9 2005/03/31 12:58:04 zolty Exp $ * */ @@ -82,6 +82,7 @@ #include "IPcheck.h" #include "client.h" +#include "ddb.h" #include "hash.h" #include "ircd.h" #include "ircd_chattr.h" @@ -116,7 +117,7 @@ * The '~'-character should be allowed, but a change should be global, * some confusion would result if only few servers allowed it... */ -static int do_nick_name(char* nick) +int do_nick_name(char* nick) { char* ch = nick; char* end = ch + NICKLEN; @@ -148,6 +149,11 @@ char* arg; char* s; const char* client_name; + int flags = 0; +#if defined(DDB) + struct Ddb *ddb; + char *p; +#endif assert(0 != cptr); assert(cptr == sptr); @@ -157,10 +163,48 @@ */ client_name = (*(cli_name(sptr))) ? cli_name(sptr) : "*"; +#if 0 + /* + * Not change nick several times BEFORE to have completed your entrance + * in the network. + */ + if (MyConnect(sptr) && (!IsRegistered(sptr)) && (sptr->cookie != 0) && + (sptr->cookie != COOKIE_VERIFIED)) + return 0; +#endif + if (parc < 2) { send_reply(sptr, ERR_NONICKNAMEGIVEN); return 0; } + +#if defined(DDB) + p = strchr(parv[1], ':'); + if (p) + { + *p++ = '\0'; + parc = 3; + parv[2] = p; + } + else if ((p = strchr(parv[1], '!'))) + { + /* GHOST nick !password Support */ + SetGhost(flags); + if (strlen(p) > 1) + { + *p++ = '\0'; + parc = 3; + parv[2] = p; + } + } + else if (parc > 2 && (*parv[2] == '!')) + { + /* GHOST nick !password Support */ + SetGhost(flags); + *parv[2]++ = '\0'; + } +#endif /* defined(DDB) */ + /* * Don't let them send make us send back a really long string of * garbage @@ -169,8 +213,11 @@ if (strlen(arg) > IRCD_MIN(NICKLEN, feature_int(FEAT_NICKLEN))) arg[IRCD_MIN(NICKLEN, feature_int(FEAT_NICKLEN))] = '\0'; +#if 1 + /* Soporte de nicks ~ */ if ((s = strchr(arg, '~'))) *s = '\0'; +#endif strcpy(nick, arg); @@ -182,6 +229,20 @@ return 0; } +#if defined(DDB) + if (strlen(nick) == 11) + { + if ((strcmp(nick, "Guest000000") >= 0) && (strcmp(nick, "Guest999999") <= 0)) + { + if (FindClient(nick)) + send_reply(sptr, ERR_NICKNAMEINUSE, nick); + else + send_reply(sptr, ERR_ERRONEUSNICKNAME, nick); + return 0; /* NICK message ignored */ + } + } +#endif /* defined(DDB) */ + /* * Check if this is a LOCAL user trying to use a reserved (Juped) * nick, if so tell him that it's a nick in use... @@ -195,7 +256,7 @@ /* * No collisions, all clear... */ - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, flags); } if (IsServer(acptr)) { @@ -216,11 +277,16 @@ * is concerned (user is changing the case of his/her * nickname or somesuch) */ +#if defined(DDB) + if (IsNickRegistered(sptr) || IsNickSuspended(sptr)) +#endif + SetNickEquivalent(flags); + if (0 != strcmp(cli_name(acptr), nick)) { /* * Allows change of case in his/her nick */ - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, flags); } /* * This is just ':old NICK old' type thing. @@ -253,8 +319,69 @@ ServerStats->is_ref++; IPcheck_connect_fail(acptr); exit_client(cptr, acptr, &me, "Overridden by other sign on"); - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, flags); + } + +#if defined(DDB) + /* + * GHOST through NICK nick!password Support + * Verify if nick is registered, if a local user, do not flooding + * and put a ! + * + * If puts the correct password, kill to the user with ghost session and + * propagates the KILL by the network, and put the nick; in opposite case, + * follows and leave the nick not available message. + * --zoltan + */ + ddb = ddb_find_key(DDB_NICKDB, parv[1]); + if (IsGhost(flags) && (ddb) && (CurrentTime >= cli_nextnick(cptr))) + { + if (verify_pass_nick(ddb->key, ddb->content, + (parc >= 3 ? parv[2] : cli_passwd(cptr)))) + { + char *botname = ddb_get_botname(DDB_NICKSERV); + char nickwho[NICKLEN + 2]; + + SetIdentify(flags); + + if (cli_name(cptr)[0] == '\0') + { + /* Ghost during the establishment of the connection + * do not have old nick information, it is added ! to the nick + */ + strncpy(nickwho, nick, sizeof(nickwho)); + nickwho[strlen(nickwho)] = '!'; + } + else + { + /* Ponemos su antiguo nick */ + strncpy(nickwho, cli_name(cptr), sizeof(nickwho)); + } + + /* Matamos al usuario con un kill */ + sendto_opmask_butone(0, SNO_SERVKILL, + "Received KILL message for %C. From %s, Reason: GHOST kill", acptr, nickwho); + + sendcmdto_serv_butone(&me, CMD_KILL, acptr, "%C :GHOST session released by %s", + acptr, nickwho); + + if (MyConnect(acptr)) + { + sendcmdto_one(acptr, CMD_QUIT, cptr, ":Killed (GHOST session " + "released by %s)", nickwho); + sendcmdto_one(&me, CMD_KILL, acptr, "%C :GHOST session released by %s", + acptr, nickwho); + } + sendcmdbotto_one(botname, CMD_NOTICE, cptr, "%C :*** %C GHOST session has been " + "released", acptr, cptr); + exit_client_msg(cptr, acptr, &me, "Killed (GHOST session released by %s)", + nickwho); + + return set_nick_name(cptr, sptr, nick, parc, parv, flags); + } } +#endif /* defined(DDB) */ + /* * NICK is coming from local client connection. Just * send error reply and ignore the command. @@ -349,7 +476,7 @@ /* Check against nick name collisions. */ if ((acptr = FindClient(nick)) == NULL) /* No collisions, all clear... */ - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, 0); /* * If acptr == sptr, then we have a client doing a nick @@ -361,7 +488,7 @@ { if (strcmp(cli_name(acptr), nick) != 0) /* Allows change of case in his/her nick */ - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, 0); else /* Setting their nick to what it already is? Ignore it. */ return 0; @@ -383,7 +510,7 @@ ServerStats->is_ref++; IPcheck_connect_fail(acptr); exit_client(cptr, acptr, &me, "Overridden by other sign on"); - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, 0); } /* * Decide, we really have a nick collision and deal with it @@ -504,5 +631,5 @@ return 0; if (sptr == NULL) return 0; - return set_nick_name(cptr, sptr, nick, parc, parv); + return set_nick_name(cptr, sptr, nick, parc, parv, 0); } Index: ircd-ircdev/ircd/m_svsnick.c diff -u /dev/null ircd-ircdev/ircd/m_svsnick.c:1.1 --- /dev/null Thu Mar 31 04:58:15 2005 +++ ircd-ircdev/ircd/m_svsnick.c Thu Mar 31 04:58:04 2005 @@ -0,0 +1,150 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/m_svsnick.c + * + * Copyright (C) 2002-2005 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2004 Toni Garcia (zoltan) <zo...@ir...> + * + * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/** @file + * @brief Handlers for SVSNICK command. + * @version $Id: m_svsnick.c,v 1.1 2005/03/31 12:58:04 zolty Exp $ + */ +#include "config.h" + +#include "client.h" +#include "ddb.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_features.h" +#include "ircd_log.h" +#include "ircd_string.h" +#include "ircd_tea.h" +#include "msg.h" +#include "numnicks.h" +#include "s_conf.h" +#include "s_user.h" +#include "send.h" +#include "sys.h" + +/* #include <assert.h> -- Now using assert in ircd_log.h */ +#include <stdio.h> +#include <string.h> + + +/** Handle a SVSNICK command from a server. + * See @ref m_functions for general discussion of parameters. + * + * \a parv[1] is a nick + * \a parv[2] is a new nick (* random nick) + * + * @param[in] cptr Client that sent us the message. + * @param[in] sptr Original source of message. + * @param[in] parc Number of arguments. + * @param[in] parv Argument vector. + */ +int ms_svsnick(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + struct Client *acptr; + struct Client *bcptr; + char newnick[NICKLEN + 2]; + char *arg; + int flags = 0; + + assert(0 != IsServer(cptr)); + + if (parc < 2) + return 0; + + if (!find_conf_byhost(cli_confs(cptr), cli_name(sptr), CONF_UWORLD)) + { + sendcmdto_serv_butone(&me, CMD_DESYNCH, 0, + ":HACK(2): Fail SVSNICK for %s. From %C", parv[1], sptr); + sendto_opmask_butone(0, SNO_HACK2, + "Fail SVSNICK for %s. From %C", parv[1], sptr); + return 0; + } + + sendcmdto_serv_butone(sptr, CMD_SVSNICK, cptr, "%s :%s", parv[1], parv[2]); + + acptr = findNUser(parv[1]); + + if (!acptr || !MyUser(acptr)) + return 0; + + if (ircd_strcmp(parv[2], "*")) + { + /* + * Don't let them send make us send back a really long string of + * garbage + */ + arg = parv[2]; + if (strlen(arg) > IRCD_MIN(NICKLEN, feature_int(FEAT_NICKLEN))) + arg[IRCD_MIN(NICKLEN, feature_int(FEAT_NICKLEN))] = '\0'; + + strcpy(newnick, arg); + + if (0 == do_nick_name(newnick)) + return 0; + + if (FindUser(newnick)) + return 0; + } + else + { + unsigned int v[2], k[2], x[2]; + + k[0] = k[1] = x[0] = x[1] = 0; + + v[0] = base64toint(cli_yxx(acptr)); + v[1] = base64toint(cli_yxx(&me)); + + bcptr = acptr; + + do + { + ircd_tea(v, k, x); + v[1] += 4096; + + if (x[0] >= 4294000000ul) + continue; + + sprintf(newnick, "Guest%.6d", (int)(x[0] % 1000000)); + bcptr = FindUser(newnick); + } + while (bcptr); + } + + sendto_opmask_butone(0, SNO_HACK4, + "SVSNICK for %C, new nick %s. From %C", acptr, newnick, sptr); + + SetRenamed(flags); +#if defined(DDB) + if (ddb_find_key(DDB_NICKDB, newnick)) + SetIdentify(flags); +#endif + + parv[0] = cli_name(acptr); + parv[1] = newnick; + { + char tmp[100]; + sprintf(tmp, "%lu", TStime()); + parv[2] = tmp; + } + + return set_nick_name(acptr, acptr, newnick, parc , parv, flags); + +} Index: ircd-ircdev/ircd/m_whois.c diff -u ircd-ircdev/ircd/m_whois.c:1.12 ircd-ircdev/ircd/m_whois.c:1.13 --- ircd-ircdev/ircd/m_whois.c:1.12 Mon Mar 21 10:39:10 2005 +++ ircd-ircdev/ircd/m_whois.c Thu Mar 31 04:58:04 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_whois.c,v 1.12 2005/03/21 18:39:10 zolty Exp $ + * $Id: m_whois.c,v 1.13 2005/03/31 12:58:04 zolty Exp $ */ /* @@ -210,6 +210,13 @@ if (user->away) send_reply(sptr, RPL_AWAY, name, user->away); +#if defined(DDB) || defined(SERVICES) + if (IsNickRegistered(acptr)) + send_reply(sptr, RPL_WHOISREGNICK, name); + else if (IsNickSuspended(acptr)) + send_reply(sptr, RPL_WHOISSUSPEND, name); +#endif /* defined(DDB) || defined(SERVICES) */ + if (SeeOper(sptr,acptr)) send_reply(sptr, RPL_WHOISOPERATOR, name); @@ -218,9 +225,15 @@ send_reply(sptr, RPL_WHOISACCOUNT, name, user->account); #endif - if (HasHiddenHost(acptr) && (IsAnOper(sptr) || acptr == sptr)) - send_reply(sptr, RPL_WHOISACTUALLY, name, user->username, - user->realhost, ircd_ntoa(&cli_ip(acptr))); + if (IsAnOper(sptr) || (acptr == sptr)) + { + char *modes = umode_str(acptr); + + if (HasHiddenHost(acptr)) + send_reply(sptr, RPL_WHOISACTUALLY, name, user->username, + user->realhost, ircd_ntoa(&cli_ip(acptr))); + send_reply(sptr, RPL_WHOISMODES, name, *modes ? modes : ""); + } /* Hint: if your looking to add more flags to a user, eg +h, here's * probably a good place to add them :) Index: ircd-ircdev/ircd/parse.c diff -u ircd-ircdev/ircd/parse.c:1.13 ircd-ircdev/ircd/parse.c:1.14 --- ircd-ircdev/ircd/parse.c:1.13 Wed Mar 23 10:34:51 2005 +++ ircd-ircdev/ircd/parse.c Thu Mar 31 04:58:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Parse input from IRC clients and other servers. - * @version $Id: parse.c,v 1.13 2005/03/23 18:34:51 zolty Exp $ + * @version $Id: parse.c,v 1.14 2005/03/31 12:58:04 zolty Exp $ */ #include "config.h" @@ -656,6 +656,22 @@ /* UNREG, CLIENT, SERVER, OPER, SERVICE */ { m_unregistered, m_not_oper, ms_dbq, mo_dbq, m_ignore } }, + { + MSG_GHOST, + TOK_GHOST, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_unregistered, m_ghost, m_ignore, m_ignore, m_ignore } + }, +#endif +#if defined(DDB) || defined(SERVICES) + { + MSG_SVSNICK, + TOK_SVSNICK, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_ignore, m_ignore, ms_svsnick, m_ignore, m_ignore } + }, #endif /* This command is an alias for QUIT during the unregistered part of Index: ircd-ircdev/ircd/s_err.c diff -u ircd-ircdev/ircd/s_err.c:1.13 ircd-ircdev/ircd/s_err.c:1.14 --- ircd-ircdev/ircd/s_err.c:1.13 Mon Mar 21 10:39:12 2005 +++ ircd-ircdev/ircd/s_err.c Thu Mar 31 04:58:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Error handling support. - * @version $Id: s_err.c,v 1.13 2005/03/21 18:39:12 zolty Exp $ + * @version $Id: s_err.c,v 1.14 2005/03/31 12:58:04 zolty Exp $ */ #include "config.h" @@ -653,7 +653,7 @@ /* 306 */ { RPL_NOWAWAY, ":You have been marked as being away", "306" }, /* 307 */ - { 0 }, + { RPL_WHOISREGNICK, "%s :is a registered and protected nick", "307" }, /* 308 */ { 0 }, /* 309 */ @@ -801,7 +801,7 @@ /* 378 */ { 0 }, /* 379 */ - { 0 }, + { RPL_WHOISMODES, "%s :is using modes %s", "379" }, /* 380 */ { 0 }, /* 381 */ @@ -823,7 +823,7 @@ /* 389 */ { 0 }, /* 390 */ - { 0 }, + { RPL_WHOISSUSPEND, "%s :is a suspended nick", "390" }, /* 391 */ { RPL_TIME, "%s %Tu %ld :%s", "391" }, /* 392 */ Index: ircd-ircdev/ircd/s_user.c diff -u ircd-ircdev/ircd/s_user.c:1.12 ircd-ircdev/ircd/s_user.c:1.13 --- ircd-ircdev/ircd/s_user.c:1.12 Mon Mar 21 10:39:12 2005 +++ ircd-ircdev/ircd/s_user.c Thu Mar 31 04:58:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Miscellaneous user-related helper functions. - * @version $Id: s_user.c,v 1.12 2005/03/21 18:39:12 zolty Exp $ + * @version $Id: s_user.c,v 1.13 2005/03/31 12:58:04 zolty Exp $ */ #include "config.h" @@ -30,6 +30,7 @@ #include "channel.h" #include "class.h" #include "client.h" +#include "ddb.h" #include "hash.h" #include "ircd.h" #include "ircd_alloc.h" @@ -40,6 +41,7 @@ #include "ircd_reply.h" #include "ircd_snprintf.h" #include "ircd_string.h" +#include "ircd_tea.h" #include "list.h" #include "match.h" #include "motd.h" @@ -702,6 +704,9 @@ { FLAG_DEBUG, 'g' }, #if defined(UNDERNET) { FLAG_ACCOUNT, 'r' }, +#elif defined(DDB) || defined(SERVICES) + { FLAG_NICKREG, 'r' }, + { FLAG_NICKSUSPEND, 'S' }, #endif { FLAG_HIDDENHOST, 'x' } }; @@ -715,6 +720,59 @@ /** Nasty global buffer used for communications with umode_str() and others. */ static char umodeBuf[BUFSIZE]; +#if defined(DDB) +/** Verify the passwords + * @param[in] nick Nickname + * @param[in] cryptpass Crypt password + * @param[in] password Password + * @return 1 if a correct password, else 0. + */ +int verify_pass_nick(char *nick, char *cryptpass, char *pass) +{ + unsigned int v[2], k[2], x[2]; + int cont = (NICKLEN + 8) / 8; + char tmpnick[8 * ((NICKLEN + 8) / 8) + 1]; + char tmppass[12 + 1]; + unsigned int *p = (unsigned int *)tmpnick; /* int == 32bits */ + unsigned int numpass[2]; + + memset(tmpnick, 0, sizeof(tmpnick)); + strncpy(tmpnick, nick, sizeof(tmpnick) - 1); + + memset(tmppass, 0, sizeof(tmppass)); + strncpy(tmppass, cryptpass, sizeof(tmppass) - 1); + + numpass[1] = base64toint(tmppass + 6); + tmppass[6] = '\0'; + numpass[0] = base64toint(tmppass); + + memset(tmppass, 0, sizeof(tmppass)); + + strncpy(tmppass, pass, sizeof(tmppass) - 1); + + /* relleno -> 123456789012 */ + strncat(tmppass, "AAAAAAAAAAAA", sizeof(tmppass) - strlen(tmppass) - 1); + + x[0] = x[1] = 0; + + k[1] = base64toint(tmppass + 6); + tmppass[6] = '\0'; + k[0] = base64toint(tmppass); + + while (cont--) + { + v[0] = ntohl(*p++); /* 32 bits */ + v[1] = ntohl(*p++); /* 32 bits */ + ircd_tea(v, k, x); + } + + if ((x[0] == numpass[0]) && (x[1] == numpass[1])) + return 1; + + return 0; +} +#endif /* defined(DDB) */ + /** Try to set a user's nickname. * If \a sptr is a server, the client is being introduced for the first time. * @param[in] cptr Client to set nickname. @@ -722,11 +780,116 @@ * @param[in] nick New nickname. * @param[in] parc Number of arguments to NICK. * @param[in] parv Argument list to NICK. + * @param[in] flags * @return CPTR_KILLED if \a cptr was killed, else 0. */ int set_nick_name(struct Client* cptr, struct Client* sptr, - const char* nick, int parc, char* parv[]) + const char* nick, int parc, char* parv[], int flags) { +#if defined(DDB) + struct Ddb *ddb; + int nick_suspend = 0; + char *botname = 0; + + /* + * Comprueba si el nick esta registrado, y + * si lo esta que se ponga la clave correcta + * + * Esta comprobacion solo se va a hacer si + * el usuario es local y no esta haciendo nick flood. + */ + if (MyConnect(sptr) && !IsIdentify(flags) && (ddb = ddb_find_key(DDB_NICKDB, (char *)nick)) + && (CurrentTime >= cli_nextnick(cptr))) + { + const char *name; + int nick_forbid = 0; + char c; + + botname = ddb_get_botname(DDB_NICKSERV); + /* + * Si el ultimo caracter de la clave (bdd->content) contiene: + * '+' El nick esta suspendido. + * '*' El nick esta prohibido (forbid). + * Cualquier otro caracter, el nick esta activo. + */ + c = ddb->content[strlen(ddb->content) - 1]; + if (c == '+') + nick_suspend = 1; + else if (c == '*') + nick_forbid = 1; + + /* + * Si el usuario ha hecho ghost, no se necesita + * verificar la clave de nuevo ya que se ha hecho + * antes al hacer el ghost. En un nick prohibido + * tampoco. + */ + if (!(IsGhost(flags) && !IsIdentify(flags) && !nick_forbid)) + { + if ((IsNickRegistered(sptr) || IsNickSuspended(sptr)) + && (0 == ircd_strcmp(parv[0], nick))) + { + SetNickEquivalent(flags); + SetIdentify(flags); + } + else if (verify_pass_nick(ddb->key, ddb->content, + (parc >= 3 ? parv[2] : cli_passwd(cptr)))) + SetIdentify(flags); + } + + if (*parv[0]) + name = parv[0]; + else + name = nick; + + if (IsIdentify(flags)) + { + /* + * Si no tiene nick anterior (acaba de conectarse) + * mandar este notice. + * El notice de autentificacion de cuando cambia nick + * esta mas abajo. + */ + if (!cli_name(cptr)[0] && !IsNickEquivalent(flags)) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%s :*** Password accepted. Welcome to %s", + nick, feature_str(FEAT_NETWORK)); + if (nick_suspend) + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%s :*** Your nick %s is suspended", + nick, nick); + } + } + else if (nick_forbid) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%s :*** The nick %s is forbided, cannot be used", + name, nick); + send_reply(cptr, ERR_NICKNAMEINUSE, nick); + return 0; + } + else + { + if (parc < 3) + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%s :*** The nick %s is Registered, you need password", + name, nick); + else + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%s :*** Incorrect password for nick %s", + name, nick); + + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%s :*** It uses \002/NICK %s%spassword\002 for identify", + name, nick, IsGhost(flags) ? "!" : ":"); + + send_reply(cptr, ERR_NICKNAMEINUSE, nick); + return 0; + } + } +#endif /* defined(DDB) */ + if (IsServer(sptr)) { int i; #if defined(UNDERNET) @@ -811,7 +974,8 @@ * if client is on any channels where it is currently * banned. If so, do not allow the nick change to occur. */ - if (MyUser(sptr)) { + if (MyUser(sptr) && !IsRenamed(flags)) + { const char* channel_name; struct Membership *member; if ((channel_name = find_no_nickchange_channel(sptr))) { @@ -847,6 +1011,20 @@ member = member->next_channel) ClearBanValid(member); } + +#if defined(DDB) + if (IsIdentify(flags) && !IsNickEquivalent(flags)) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Password accepted. Welcome to %s", + cptr, feature_str(FEAT_NETWORK)); + + if (nick_suspend) + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Your nick %s is suspended", cptr, nick); + } +#endif + /* * Also set 'lastnick' to current time, if changed. */ @@ -859,6 +1037,23 @@ * on that channel. Propagate notice to other servers. */ if (IsUser(sptr)) { + if (!IsNickEquivalent(flags)) + { +#if defined(DDB) + struct Flags oldflags; +#endif + + /* Notify exit user */ + check_status_watch(sptr, RPL_LOGOFF); + +#if defined(DDB) + oldflags = cli_flags(sptr); + ClearNickRegistered(sptr); + ClearNickSuspended(sptr); + + send_umode_out(cptr, sptr, &oldflags, IsRegistered(sptr)); +#endif + } sendcmdto_common_channels_butone(sptr, CMD_NICK, NULL, ":%s", nick); add_history(sptr, 1); sendcmdto_serv_butone(sptr, CMD_NICK, cptr, "%s %Tu", nick, @@ -871,6 +1066,7 @@ hRemClient(sptr); strcpy(cli_name(sptr), nick); hAddClient(sptr); + } else { /* Local client setting NICK the first time */ @@ -906,8 +1102,30 @@ } } - /* Notify change nick local/remote user */ - check_status_watch(sptr, RPL_LOGON); + if (!IsNickEquivalent(flags)) + { +#if defined(DDB) + if (MyConnect(sptr)) + { + struct Flags oldflags; + + if (IsIdentify(flags)) + { + oldflags = cli_flags(sptr); + + if (nick_suspend) + SetNickSuspended(sptr); + else + SetNickRegistered(sptr); + + send_umode_out(cptr, sptr, &oldflags, IsRegistered(sptr)); + } + } +#endif /* defined(DDB) */ + + /* Notify change nick local/remote user */ + check_status_watch(sptr, RPL_LOGON); + } return 0; } @@ -1146,9 +1364,7 @@ int hide_hostmask(struct Client *cptr, unsigned int flag) { -#if defined(UNDERNET) struct Membership *chan; -#endif switch (flag) { case FLAG_HIDDENHOST: @@ -1168,14 +1384,21 @@ return 0; } -#if defined(UNDERNET) SetFlag(cptr, flag); +#if defined(UNDERNET) if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_ACCOUNT)) +#else + if (!HasFlag(cptr, FLAG_HIDDENHOST)) +#endif return 0; sendcmdto_common_channels_butone(cptr, CMD_QUIT, cptr, ":Registered"); ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, "%s.%s", +#if defined(UNDERNET) cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST)); +#else + cli_yxx(cptr), feature_str(FEAT_HIDDEN_HOST)); +#endif /* ok, the client is now fully hidden, so let them know -- hikari */ if (MyConnect(cptr)) @@ -1201,7 +1424,6 @@ sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr, 0, "%H +%c %C", chan->channel, IsChanOp(chan) ? 'o' : 'v', cptr); } -#endif return 0; } @@ -1371,6 +1593,20 @@ if (what == MODE_ADD) do_host_hiding = 1; break; +#if defined(DDB) || defined(SERVICES) + case 'r': + if (what == MODE_ADD) + SetNickRegistered(sptr); + else + ClearNickRegistered(sptr); + break; + case 'S': + if (what == MODE_ADD) + SetNickSuspended(sptr); + else + ClearNickSuspended(sptr); + break; +#endif /* defined(DDB) || defined(SERVICES) */ /* if none of the given case is valid then compain by * sending raw 501 ( ERR_UMODEUNKNOWNFLAG ) */ @@ -1413,6 +1649,12 @@ if (feature_bool(FEAT_HIS_DEBUG_OPER_ONLY) && !IsAnOper(sptr) && !FlagHas(&setflags, FLAG_DEBUG)) ClearDebug(sptr); +#if defined(DDB) || defined(SERVICES) + if (!FlagHas(&setflags, FLAG_NICKREG) && IsNickRegistered(sptr)) + ClearNickRegistered(sptr); + if (!FlagHas(&setflags, FLAG_NICKSUSPEND) && IsNickSuspended(sptr)) + ClearNickSuspended(sptr); +#endif /* defined(DDB) || defined(SERVICES) */ } if (MyConnect(sptr)) Index: ircd-ircdev/ircd/send.c diff -u ircd-ircdev/ircd/send.c:1.6 ircd-ircdev/ircd/send.c:1.7 --- ircd-ircdev/ircd/send.c:1.6 Mon Jan 10 04:23:04 2005 +++ ircd-ircdev/ircd/send.c Thu Mar 31 04:58:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Send messages to certain targets. - * @version $Id: send.c,v 1.6 2005/01/10 12:23:04 zolty Exp $ + * @version $Id: send.c,v 1.7 2005/03/31 12:58:04 zolty Exp $ */ #include "config.h" @@ -308,6 +308,34 @@ msgq_clean(mb); } +/** Send a bot command to a single client. + * @param[in] botname Bot sending the command. + * @param[in] cmd Long name of command (used if \a to is a user). + * @param[in] tok Short name of command (used if \a to is a server). + * @param[in] to Destination of command. + * @param[in] pattern Format string for command arguments. + */ +void sendcmdbotto_one(char *botname, const char *cmd, const char *tok, + struct Client *to, const char *pattern, ...) +{ + struct VarData vd; + struct MsgBuf *mb; + + to = cli_from(to); + + vd.vd_format = pattern; /* set up the struct VarData for %v */ + va_start(vd.vd_args, pattern); + + mb = msgq_make(to, ":%s %s %v", botname, cmd, &vd); + + va_end(vd.vd_args); + + send_buffer(to, mb, 0); + + msgq_clean(mb); + +} + /** Send a (prefixed) command to a single client. * @param[in] from Client sending the command. * @param[in] cmd Long name of command (used if \a to is a user). Index: ircd-ircdev/ircd/whocmds.c diff -u ircd-ircdev/ircd/whocmds.c:1.7 ircd-ircdev/ircd/whocmds.c:1.8 --- ircd-ircdev/ircd/whocmds.c:1.7 Mon Jan 10 04:23:04 2005 +++ ircd-ircdev/ircd/whocmds.c Thu Mar 31 04:58:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Support functions for /WHO-like commands. - * @version $Id: whocmds.c,v 1.7 2005/01/10 12:23:04 zolty Exp $ + * @version $Id: whocmds.c,v 1.8 2005/03/31 12:58:04 zolty Exp $ */ #include "config.h" @@ -198,6 +198,12 @@ if (SendDebug(acptr)) *(p1++) = 'g'; } +#if defined(DDB) || defined(SERVICES) + if (IsNickRegistered(acptr)) + *(p1++) = 'r'; + if (IsNickSuspended(acptr)) + *(p1++) = 'S'; +#endif if (HasHiddenHost(acptr)) *(p1++) = 'x'; } ----------------------- End of diff ----------------------- |