about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/Modes.txt1
-rw-r--r--src/ngircd/irc-login.c17
-rw-r--r--src/ngircd/irc-mode.c1
-rw-r--r--src/ngircd/messages.h1
4 files changed, 20 insertions, 0 deletions
diff --git a/doc/Modes.txt b/doc/Modes.txt
index 07f16eb0..2230f36e 100644
--- a/doc/Modes.txt
+++ b/doc/Modes.txt
@@ -56,6 +56,7 @@ users to lists (e.g. "invite list", "ban list"), others have parameters
   m	0.3.0	Channel is moderated, only "voiced" users can send messages.
   M	20	Only registered users (and IRC Ops) can send messages.
   n	0.3.0	Channel doesn't allow messages of users not being members.
+  N     ??      Users can't change their nickname while on this channel.
   O	18	Only IRC operators are allowed to join this channel.
   P	0.5.0	Channel is "persistent".
   Q	20	Nobody can be kicked from the channel.
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 98ac0e7f..35026e55 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,22 @@ 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 */
+			if(Client_Type(Client) == CLIENT_USER &&
+			   !Client_HasMode(Client, 'o')) {
+				chan = Channel_First();
+				while (chan) {
+					if(Channel_IsMemberOf(chan, Client) &&
+					   Channel_HasMode(chan, 'N'))
+						return IRC_WriteErrClient(Client,
+									  ERR_NONICKCHANGE_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..4f1632b0 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -127,6 +127,7 @@
 #define ERR_USERONCHANNEL_MSG		"443 %s %s %s :is already on channel"
 #define ERR_SUMMONDISABLED_MSG		"445 %s :SUMMON has been disabled"
 #define ERR_USERSDISABLED_MSG		"446 %s :USERS has been disabled"
+#define ERR_NONICKCHANGE_MSG		"447 %s :Cannot change nickname while on %s(+N)"
 #define ERR_NOTREGISTERED_MSG		"451 %s :Connection not registered"
 #define ERR_NOTREGISTEREDSERVER_MSG	"451 %s :Connection not registered as server link"
 #define ERR_NEEDMOREPARAMS_MSG		"461 %s %s :Syntax error"