summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-login.c15
-rw-r--r--src/ngircd/irc-mode.c1
-rw-r--r--src/ngircd/messages.h1
3 files changed, 17 insertions, 0 deletions
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 98ac0e7f..f3226011 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -172,6 +172,7 @@ GLOBAL bool
 IRC_NICK( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *intr_c, *target, *c;
+	CHANNEL *chan;
 	char *nick, *user, *hostname, *modes, *info;
 	int token, hops;
 
@@ -259,6 +260,20 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 				Client_SetType( Client, CLIENT_GOTNICK );
 		} else {
 			/* Nickname change */
+
+			/* Check that the user isn't on any channels set +N */
+			chan = Channel_First();
+			while (chan) {
+				if(Channel_IsMemberOf(chan, Client) &&
+				   Channel_HasMode(chan, 'N') &&
+				   !Client_HasMode(Client, 'o'))
+					return IRC_WriteErrClient(Client,
+								  ERR_UNAVAILRESOURCE_MSG,
+								  Client_ID(Client),
+								  Channel_Name(chan));
+				chan = Channel_Next(chan);
+			}
+
 			Change_Nick(Client, target, Req->argv[0],
 				    Client_Type(Client) == CLIENT_USER ? true : false);
 			IRC_SetPenalty(target, 2);
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index 2f922506..99255df1 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -580,6 +580,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
 		case 'M': /* Only identified nicks can write */
 		case 'm': /* Moderated */
 		case 'n': /* Only members can write */
+		case 'N': /* Can't change nick while on this channel */
 		case 'Q': /* No kicks */
 		case 't': /* Topic locked */
 			if(is_oper || is_machine || is_owner ||
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index 8a7215b4..15dbe8cf 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -122,6 +122,7 @@
 #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_UNAVAILRESOURCE_MSG		"437 %s :Cannot change nickname while on %s(+N)"
 #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"
 #define ERR_USERONCHANNEL_MSG		"443 %s %s %s :is already on channel"