Commit Diff


commit - 9d8974d5098e9426f9185f31b2b3853e55513f3e
commit + a6dd2e33c2c9e60bbd286bb07a7a6273566dec7d
blob - 2466c7175a3bd11eb52000a62e03baf355d56196
blob + f163f72c371e2a84121a84d178c3552530109b3d
--- src/ngircd/client.c
+++ src/ngircd/client.c
@@ -903,6 +903,16 @@ Client_CheckNick(CLIENT *Client, char *Nick)
 			IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
 					   Client_ID(Client), 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? */
blob - 16ad98c21a40c185cc5b371f387e0372a3ee2cbe
blob + 41b5469a8140f4c5a07d1874dd6d048fcbf6ae3b
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -652,6 +652,27 @@ Conf_NickIsService(int ConfServer, const char *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.
  */
 static void
blob - 72c80390642c905759f56ed27f378c6c4024d413
blob + 8e66c07c3c671f3ecf119fc50f6fc313cdaa5307
--- src/ngircd/conf.h
+++ 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 *Na
 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];
blob - 96ff2dea2cc8ab431eef03adb084e7f16d1e3f69
blob + 9ad6be1763d569f7af3b486e3620930f15127516
--- src/ngircd/messages.h
+++ 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"