diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 2466c717..f163f72c 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -905,6 +905,16 @@ Client_CheckNick(CLIENT *Client, char *Nick) return false; } + if (Client_Type(Client) != CLIENT_SERVER + && Client_Type(Client) != CLIENT_SERVICE) { + /* Make sure that this isn't a restricted/forbidden nick name */ + if (Conf_NickIsBlocked(Nick)) { + IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG, + Client_ID(Client), Nick); + return false; + } + } + /* Nickname already registered? */ if (Client_Search(Nick)) { IRC_WriteStrClient(Client, ERR_NICKNAMEINUSE_MSG, diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 16ad98c2..41b5469a 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -651,6 +651,27 @@ Conf_NickIsService(int ConfServer, const char *Nick) return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick); } +/** + * Check if the given nick name is blocked for "normal client" use. + * + * @param ConfServer The server index or NONE to check all configured servers. + * @param Nick The nick name to check. + * @returns true if the given nick name belongs to an "IRC service". + */ +GLOBAL bool +Conf_NickIsBlocked(const char *Nick) +{ + int i; + + for(i = 0; i < MAX_SERVERS; i++) { + if (!Conf_Server[i].name[0]) + continue; + if (Conf_NickIsService(i, Nick)) + return true; + } + return false; +} + /** * Initialize configuration settings with their default values. */ diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index 72c80390..8e66c07c 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors. + * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. * * 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 @@ -245,6 +245,7 @@ GLOBAL bool Conf_DisableServer PARAMS(( const char *Name )); GLOBAL bool Conf_AddServer PARAMS(( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd )); GLOBAL bool Conf_NickIsService PARAMS((int ConfServer, const char *Nick)); +GLOBAL bool Conf_NickIsBlocked PARAMS((const char *Nick)); /* Password required by WEBIRC command */ GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN]; diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index 96ff2dea..9ad6be17 100644 --- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -112,6 +112,7 @@ #define ERR_NONICKNAMEGIVEN_MSG "431 %s :No nickname given" #define ERR_ERRONEUSNICKNAME_MSG "432 %s %s :Erroneous nickname" #define ERR_NICKNAMETOOLONG_MSG "432 %s %s :Nickname too long, max. %u characters" +#define ERR_FORBIDDENNICKNAME_MSG "432 %s %s :Nickname is forbidden/blocked" #define ERR_NICKNAMEINUSE_MSG "433 %s %s :Nickname already in use" #define ERR_USERNOTINCHANNEL_MSG "441 %s %s %s :They aren't on that channel" #define ERR_NOTONCHANNEL_MSG "442 %s %s :You are not on that channel"