2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
11 * IRC operator commands
17 static char UNUSED id[] = "$Id: irc-oper.c,v 1.16 2002/12/30 00:01:45 alex Exp $";
29 #include "irc-write.h"
39 IRC_OPER( CLIENT *Client, REQUEST *Req )
43 assert( Client != NULL );
44 assert( Req != NULL );
46 /* Falsche Anzahl Parameter? */
47 if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
50 for( i = 0; i < Conf_Oper_Count; i++)
52 if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
54 if( i >= Conf_Oper_Count )
56 Log( LOG_WARNING, "Got invalid OPER from \"%s\": Name \"%s\" not configured!", Client_Mask( Client ), Req->argv[0] );
57 return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
60 /* Stimmt das Passwort? */
61 if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
63 Log( LOG_WARNING, "Got invalid OPER from \"%s\": Bad password for \"%s\"!", Client_Mask( Client ), Conf_Oper[i].name );
64 return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
67 if( ! Client_HasMode( Client, 'o' ))
69 /* noch kein o-Mode gesetzt */
70 Client_ModeAdd( Client, 'o' );
71 if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
72 IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));
75 if( ! Client_OperByMe( Client )) Log( LOG_NOTICE|LOG_snotice, "Got valid OPER from \"%s\", user is an IRC operator now.", Client_Mask( Client ));
77 Client_SetOperByMe( Client, TRUE );
78 return IRC_WriteStrClient( Client, RPL_YOUREOPER_MSG, Client_ID( Client ));
83 IRC_DIE( CLIENT *Client, REQUEST *Req )
85 assert( Client != NULL );
86 assert( Req != NULL );
88 /* Falsche Anzahl Parameter? */
89 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
91 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
93 Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\" ...", Client_Mask( Client ));
94 NGIRCd_SignalQuit = TRUE;
100 IRC_REHASH( CLIENT *Client, REQUEST *Req )
102 assert( Client != NULL );
103 assert( Req != NULL );
105 /* Falsche Anzahl Parameter? */
106 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
108 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
110 Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\" ...", Client_Mask( Client ));
111 NGIRCd_SignalRehash = TRUE;
118 IRC_RESTART( CLIENT *Client, REQUEST *Req )
120 assert( Client != NULL );
121 assert( Req != NULL );
123 /* Falsche Anzahl Parameter? */
124 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
126 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
128 Log( LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\" ...", Client_Mask( Client ));
129 NGIRCd_SignalRestart = TRUE;
135 IRC_CONNECT(CLIENT *Client, REQUEST *Req )
137 /* Vorlaeufige Version zu Debug-Zwecken: es wird einfach
138 * der "passive mode" aufgehoben, mehr passiert nicht ... */
140 assert( Client != NULL );
141 assert( Req != NULL );
143 /* Falsche Anzahl Parameter? */
144 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
145 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
147 Log( LOG_NOTICE|LOG_snotice, "Got CONNECT command from \"%s\".", Client_Mask( Client ));
148 NGIRCd_Passive = FALSE;