X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-mode.c;h=cf6354171df7a454dbd704163b0a146e90673729;hp=aac8769512ac87eaf252feecb305ea8303aedf44;hb=7deacbaa11e237c987ba7d379a3162846cda8f2d;hpb=8c1df9ef8d90aa249950fe9043d659361568b85a diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index aac87695..cf635417 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-mode.c,v 1.28 2003/01/02 17:57:09 alex Exp $"; +static char UNUSED id[] = "$Id: irc-mode.c,v 1.31 2003/01/21 21:04:16 alex Exp $"; #include "imp.h" #include @@ -247,11 +247,42 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ) LONG l; /* Mode request: let's answer it :-) */ - if( Req->argc == 1 ) return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), Channel_Modes( Channel )); + if( Req->argc == 1 ) + { + /* Member or not? -- That's the question! */ + if( ! Channel_IsMemberOf( Channel, Origin )) return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), Channel_Modes( Channel )); + + /* The sender is a member: generate extended reply */ + strlcpy( the_modes, Channel_Modes( Channel ), sizeof( the_modes )); + mode_ptr = the_modes; + strcpy( the_args, "" ); + while( *mode_ptr ) + { + switch( *mode_ptr ) + { + case 'l': + snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel )); + strlcat( the_args, argadd, sizeof( the_args )); + break; + case 'k': + strlcat( the_args, " ", sizeof( the_args )); + strlcat( the_args, Channel_Key( Channel ), sizeof( the_args )); + break; + } + mode_ptr++; + } + if( the_args[0] ) strlcat( the_modes, the_args, sizeof( the_modes )); + + return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), the_modes ); + } /* 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 ) @@ -478,6 +509,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 */