about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2015-08-01 14:24:20 +0200
committerAlexander Barton <alex@barton.de>2015-08-01 14:24:20 +0200
commit90ea23ab4fe3032824e22eb59bee305f35c4aae7 (patch)
treec3266114e4ec9456cb9dddb36b10944380cd0c85 /src
parent6e7e744cc6c3d378ac9bace41586e4f32f456551 (diff)
parent599626d570f5bd5284a7a30fb8c3ca8dc3636371 (diff)
downloadngircd-90ea23ab4fe3032824e22eb59bee305f35c4aae7.tar.gz
ngircd-90ea23ab4fe3032824e22eb59bee305f35c4aae7.zip
Merge pull request #214 from Flupsy/channel-mode-N
Channel mode N (users on this channel can't change their nick)
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-login.c17
-rw-r--r--src/ngircd/irc-mode.c1
-rw-r--r--src/ngircd/messages.h1
3 files changed, 19 insertions, 0 deletions
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"