]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/irc-mode.c
Backported all changes up to now from HEAD.
[ngircd.git] / src / ngircd / irc-mode.c
index 40dfb7329994d9b6428648f6bf65e82b22f2cff3..fcc1eca552648d5926e4146cc9a83d62b5d02bf4 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.29 2003/01/08 23:00:12 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.31.2.1 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -230,7 +230,8 @@ client_exit:
                }
                Log( LOG_DEBUG, "User \"%s\": Mode change, now \"%s\".", Client_Mask( Target ), Client_Modes( Target ));
        }
-               
+       
+       IRC_SetPenalty( Client, 1 );    
        return ok;
 } /* Client_Mode */
 
@@ -279,6 +280,10 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
        /* Is the user allowed to change modes? */
        if( Client_Type( Client ) == CLIENT_USER )
        {
+               /* Is the originating user on that channel? */
+               if( ! Channel_IsMemberOf( Channel, Origin )) return IRC_WriteStrClient( Origin, ERR_NOTONCHANNEL_MSG, Client_ID( Origin ), Channel_Name( Channel ));
+
+               /* Is he channel operator? */
                if( strchr( Channel_UserModes( Channel, Origin ), 'o' )) modeok = TRUE;
                else modeok = FALSE;
                if( Conf_OperCanMode )
@@ -505,6 +510,13 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
                /* Is there a valid mode change? */
                if( ! x[0] ) continue;
 
+               /* Validate target client */
+               if( client && ( ! Channel_IsMemberOf( Channel, client )))
+               {
+                       if( ! IRC_WriteStrClient( Origin, ERR_USERNOTINCHANNEL_MSG, Client_ID( Origin ), Client_ID( client ), Channel_Name( Channel ))) break;
+                       continue;
+               }
+
                if( set )
                {
                        /* Set mode */
@@ -587,6 +599,7 @@ chan_exit:
                }
        }
 
+       IRC_SetPenalty( Client, 1 );
        return CONNECTED;
 } /* Channel_Mode */