]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Add channel mode N (normal user can't change nick while on channel)
authorIan Chard <ian@chard.org>
Wed, 24 Jun 2015 14:37:56 +0000 (15:37 +0100)
committerIan Chard <ian@chard.org>
Wed, 24 Jun 2015 14:37:56 +0000 (15:37 +0100)
src/ngircd/irc-login.c
src/ngircd/irc-mode.c
src/ngircd/messages.h

index 98ac0e7f5e07ead740eed5297eb8b45802b59b8d..f3226011890655711a4781b8e716e531d7244016 100644 (file)
@@ -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);
index 2f9225067a4aa503146c142c811ac224243052ed..99255df14a5433f60b3ad56e35f7e8f802175916 100644 (file)
@@ -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 ||
index 8a7215b42172464a3f77204225292760fb47af5c..15dbe8cf81f350db4dd00edc66e27f9e480d9edf 100644 (file)
 #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"