X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-oper.c;h=c9286d7015e4598d1d0c09ef7694160cb39bc22d;hb=4c113d8850dfc423e3dae2d2f90e7e9a9d42f0b0;hp=8f94cb1f3de3b6480f45aef8812a716900f8b17e;hpb=fcf65beea459747b6bf9b4937cd45c71f6ee7b36;p=ngircd-alex.git diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c index 8f94cb1f..c9286d70 100644 --- a/src/ngircd/irc-oper.c +++ b/src/ngircd/irc-oper.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-oper.c,v 1.22 2005/06/12 18:02:09 fw Exp $"; +static char UNUSED id[] = "$Id: irc-oper.c,v 1.29 2007/08/02 10:14:26 fw Exp $"; #include "imp.h" #include @@ -23,7 +23,7 @@ static char UNUSED id[] = "$Id: irc-oper.c,v 1.22 2005/06/12 18:02:09 fw Exp $"; #include "ngircd.h" #include "resolve.h" -#include "conn.h" +#include "conn-func.h" #include "conf.h" #include "client.h" #include "channel.h" @@ -37,7 +37,7 @@ static char UNUSED id[] = "$Id: irc-oper.c,v 1.22 2005/06/12 18:02:09 fw Exp $"; #include "irc-oper.h" -LOCAL bool +static bool Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg) { Log( LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s", Client_Mask( Client ), @@ -50,7 +50,7 @@ Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg) GLOBAL bool IRC_OPER( CLIENT *Client, REQUEST *Req ) { - int i; + unsigned int i; assert( Client != NULL ); assert( Req != NULL ); @@ -90,21 +90,46 @@ IRC_OPER( CLIENT *Client, REQUEST *Req ) GLOBAL bool -IRC_DIE( CLIENT *Client, REQUEST *Req ) +IRC_DIE(CLIENT * Client, REQUEST * Req) { /* Shut down server */ - assert( Client != NULL ); - assert( Req != NULL ); + CONN_ID c; + CLIENT *cl; + + assert(Client != NULL); + assert(Req != NULL); /* Not a local IRC operator? */ - if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client )); - + if ((!Client_HasMode(Client, 'o')) || (!Client_OperByMe(Client))) + return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, + Client_ID(Client)); + /* Bad number of parameters? */ - if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); +#ifdef STRICT_RFC + if (Req->argc != 0) +#else + if (Req->argc > 1) +#endif + return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, + Client_ID(Client), Req->command); + + /* Is a message given? */ + if (Req->argc > 0) { + c = Conn_First(); + while (c != NONE) { + cl = Conn_GetClient(c); + if (Client_Type(cl) == CLIENT_USER) + IRC_WriteStrClient(cl, "NOTICE %s :%s", + Client_ID(cl), Req->argv[0]); + c = Conn_Next(c); + } + } - Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\" ...", Client_Mask( Client )); + Log(LOG_NOTICE | LOG_snotice, "Got DIE command from \"%s\" ...", + Client_Mask(Client)); NGIRCd_SignalQuit = true; + return CONNECTED; } /* IRC_DIE */ @@ -150,35 +175,60 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req ) } /* IRC_RESTART */ +/** + * Connect configured or new server. + */ GLOBAL bool -IRC_CONNECT(CLIENT *Client, REQUEST *Req ) +IRC_CONNECT(CLIENT * Client, REQUEST * Req) { - /* Connect configured or new server */ - assert( Client != NULL ); - assert( Req != NULL ); + assert(Client != NULL); + assert(Req != NULL); /* Not a local IRC operator? */ - if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client )); + if ((!Client_HasMode(Client, 'o')) || (!Client_OperByMe(Client))) + return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, + Client_ID(Client)); /* Bad number of parameters? */ - if(( Req->argc != 2 ) && ( Req->argc != 5 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + if ((Req->argc != 1) && (Req->argc != 2) && (Req->argc != 5)) + return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, + Client_ID(Client), Req->command); /* Invalid port number? */ - if( atoi( Req->argv[1] ) < 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); - - Log( LOG_NOTICE|LOG_snotice, "Got CONNECT command from \"%s\" for \"%s\".", Client_Mask( Client ), Req->argv[0]); - - if( Req->argc == 2 ) - { + if ((Req->argc > 1) && atoi(Req->argv[1]) < 1) + return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, + Client_ID(Client), Req->command); + + Log(LOG_NOTICE | LOG_snotice, + "Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(Client), + Req->argv[0]); + + switch (Req->argc) { + case 1: + if (!Conf_EnablePassiveServer(Req->argv[0])) + return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, + Client_ID(Client), + Req->argv[0]); + break; + case 2: /* Connect configured server */ - if( ! Conf_EnableServer( Req->argv[0], atoi( Req->argv[1] ))) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); - } - else - { + if (!Conf_EnableServer + (Req->argv[0], (UINT16) atoi(Req->argv[1]))) + return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, + Client_ID(Client), + Req->argv[0]); + break; + default: /* Add server */ - if( ! Conf_AddServer( Req->argv[0], atoi( Req->argv[1] ), Req->argv[2], Req->argv[3], Req->argv[4] )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + if (!Conf_AddServer + (Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2], + Req->argv[3], Req->argv[4])) + return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, + Client_ID(Client), + Req->argv[0]); } + return CONNECTED; } /* IRC_CONNECT */ @@ -208,9 +258,59 @@ IRC_DISCONNECT(CLIENT *Client, REQUEST *Req ) if( ! Conf_DisableServer( Req->argv[0] )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); /* Are we still connected or were we killed, too? */ - if( Client_GetFromConn( my_conn )) return CONNECTED; + if( Conn_GetClient( my_conn )) return CONNECTED; else return DISCONNECTED; } /* IRC_CONNECT */ +GLOBAL bool +IRC_WALLOPS( CLIENT *Client, REQUEST *Req ) +{ + CLIENT *to, *from; + int client_type; + + assert( Client != NULL ); + assert( Req != NULL ); + + if (Req->argc != 1) + return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + + client_type = Client_Type(Client); + switch (client_type) { + case CLIENT_USER: + if (!Client_OperByMe(Client)) + return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, Client_ID(Client)); + from = Client; + break; + case CLIENT_SERVER: + from = Client_Search(Req->prefix); + break; + default: + return CONNECTED; + } + + if (!from) + return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->prefix); + + for (to=Client_First(); to != NULL; to=Client_Next(to)) { + if (Client_Conn(to) < 0) /* no local connection or WALLOPS origin */ + continue; + + client_type = Client_Type(to); + switch (client_type) { + case CLIENT_USER: + if (Client_HasMode(to, 'w')) + IRC_WriteStrClientPrefix(to, from, "WALLOPS :%s", Req->argv[0]); + break; + case CLIENT_SERVER: + if (to != Client) + IRC_WriteStrClientPrefix(to, from, "WALLOPS :%s", Req->argv[0]); + break; + } + } + return CONNECTED; +} + + + /* -eof- */