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 * $Id: irc-oper.c,v 1.12 2002/12/12 12:24:18 alex Exp $
13 * IRC operator commands
19 static char UNUSED id[] = "$Id: irc-oper.c,v 1.12 2002/12/12 12:24:18 alex Exp $";
31 #include "irc-write.h"
41 IRC_OPER( CLIENT *Client, REQUEST *Req )
45 assert( Client != NULL );
46 assert( Req != NULL );
48 /* Falsche Anzahl Parameter? */
49 if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
52 for( i = 0; i < Conf_Oper_Count; i++)
54 if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
56 if( i >= Conf_Oper_Count )
58 Log( LOG_WARNING, "Got invalid OPER from \"%s\": Name \"%s\" not configured!", Client_Mask( Client ), Req->argv[0] );
59 return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
62 /* Stimmt das Passwort? */
63 if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
65 Log( LOG_WARNING, "Got invalid OPER from \"%s\": Bad password for \"%s\"!", Client_Mask( Client ), Conf_Oper[i].name );
66 return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
69 if( ! Client_HasMode( Client, 'o' ))
71 /* noch kein o-Mode gesetzt */
72 Client_ModeAdd( Client, 'o' );
73 if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
74 IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));
77 if( ! Client_OperByMe( Client )) Log( LOG_NOTICE|LOG_snotice, "Got valid OPER from \"%s\", user is an IRC operator now.", Client_Mask( Client ));
79 Client_SetOperByMe( Client, TRUE );
80 return IRC_WriteStrClient( Client, RPL_YOUREOPER_MSG, Client_ID( Client ));
85 IRC_DIE( CLIENT *Client, REQUEST *Req )
87 assert( Client != NULL );
88 assert( Req != NULL );
90 /* Falsche Anzahl Parameter? */
91 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
93 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
95 Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\", going down!", Client_Mask( Client ));
102 IRC_REHASH( CLIENT *Client, REQUEST *Req )
104 assert( Client != NULL );
105 assert( Req != NULL );
107 /* Falsche Anzahl Parameter? */
108 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
110 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
112 Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\", re-reading configuration ...", Client_Mask( Client ));
120 IRC_RESTART( CLIENT *Client, REQUEST *Req )
122 assert( Client != NULL );
123 assert( Req != NULL );
125 /* Falsche Anzahl Parameter? */
126 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
128 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
130 Log( LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\", going down!", Client_Mask( Client ));
131 NGIRCd_Restart = TRUE;
137 IRC_CONNECT(CLIENT *Client, REQUEST *Req )
139 /* Vorlaeufige Version zu Debug-Zwecken: es wird einfach
140 * der "passive mode" aufgehoben, mehr passiert nicht ... */
142 assert( Client != NULL );
143 assert( Req != NULL );
145 /* Falsche Anzahl Parameter? */
146 if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
147 if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
149 Log( LOG_NOTICE|LOG_snotice, "Got CONNECT command from \"%s\".", Client_Mask( Client ));
150 NGIRCd_Passive = FALSE;