]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Use functions provided by op.c "module"
authorAlexander Barton <alex@barton.de>
Wed, 22 Apr 2009 21:24:15 +0000 (23:24 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 30 Sep 2009 14:00:06 +0000 (16:00 +0200)
Local functions Check_Oper() and No_Privileges() have been replaced by
global functions in op.c "module": Op_Check() and Op_NoPrivileges().

src/ngircd/irc-oper.c

index f67e947ce17be37a6f8e81a5254dd3352e0219f6..68b5eb6fb5f559fe47252a9e34949f01f125ff91 100644 (file)
@@ -31,6 +31,7 @@
 #include "match.h"
 #include "messages.h"
 #include "parse.h"
+#include "op.h"
 
 #include <exp.h>
 #include "irc-oper.h"
@@ -51,58 +52,6 @@ Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg)
 } /* Bad_OperPass */
 
 
-/**
- * Check that the client is an IRC operator allowed to administer this server.
- */
-static bool
-Check_Oper(CLIENT * Client, REQUEST * Req)
-{
-       CLIENT *c;
-
-       assert(Client != NULL);
-       assert(Req != NULL);
-
-       if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
-               c = Client_Search(Req->prefix);
-       else
-               c = Client;
-       if (!c)
-               return false;
-       if (!Client_HasMode(c, 'o'))
-               return false;
-       if (!Client_OperByMe(c) && !Conf_AllowRemoteOper)
-               return false;
-       /* The client is an local IRC operator, or this server is configured
-        * to trust remote operators. */
-       return true;
-} /* CheckOper */
-
-
-/**
- * Return and log a "no privileges" message.
- */
-static bool
-No_Privileges(CLIENT * Client, REQUEST * Req)
-{
-       CLIENT *from = NULL;
-
-       if (Req->prefix) 
-               from = Client_Search(Req->prefix);
-
-       if (from) {
-               Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"",
-                   Req->prefix, Client_Mask(Client), Req->command);
-               return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
-                                         Client_ID(from));
-       } else {
-               Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"",
-                   Client_Mask(Client), Req->command);
-               return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
-                                         Client_ID(Client));
-       }
-} /* PermissionDenied */
-
-
 GLOBAL bool
 IRC_OPER( CLIENT *Client, REQUEST *Req )
 {
@@ -151,8 +100,8 @@ IRC_DIE(CLIENT * Client, REQUEST * Req)
        assert(Client != NULL);
        assert(Req != NULL);
 
-       if (!Check_Oper(Client, Req))
-               return No_Privileges(Client, Req);
+       if (!Op_Check(Client, Req))
+               return Op_NoPrivileges(Client, Req);
 
        /* Bad number of parameters? */
 #ifdef STRICT_RFC
@@ -191,8 +140,8 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req )
        assert( Client != NULL );
        assert( Req != NULL );
 
-       if (!Check_Oper(Client, Req))
-               return No_Privileges(Client, Req);
+       if (!Op_Check(Client, Req))
+               return Op_NoPrivileges(Client, Req);
 
        /* Bad number of parameters? */
        if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -212,8 +161,8 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
        assert( Client != NULL );
        assert( Req != NULL );
 
-       if (!Check_Oper(Client, Req))
-               return No_Privileges(Client, Req);
+       if (!Op_Check(Client, Req))
+               return Op_NoPrivileges(Client, Req);
 
        /* Bad number of parameters? */
        if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -235,8 +184,8 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
        assert(Client != NULL);
        assert(Req != NULL);
 
-       if (!Check_Oper(Client, Req))
-               return No_Privileges(Client, Req);
+       if (!Op_Check(Client, Req))
+               return Op_NoPrivileges(Client, Req);
 
        /* Bad number of parameters? */
        if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
@@ -329,8 +278,8 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
        assert(Client != NULL);
        assert(Req != NULL);
 
-       if (!Check_Oper(Client, Req))
-               return No_Privileges(Client, Req);
+       if (!Op_Check(Client, Req))
+               return Op_NoPrivileges(Client, Req);
 
        /* Bad number of parameters? */
        if (Req->argc != 1)