]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Remove CLIENT.oper_by_my, Client_SetOperByMe() and Client_OperByMe() RemoveOperByMe
authorAlexander Barton <alex@barton.de>
Tue, 24 Sep 2013 23:29:23 +0000 (01:29 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 24 Sep 2013 23:29:23 +0000 (01:29 +0200)
All places where Client_OperByMe() is used can either be converted to
Client_HasMode(Client, 'o') or Op_Check().

And Op_Check() itself can use the connection handle for deciding whether
the IRC Operator is a local user or not.

src/ngircd/client.c
src/ngircd/client.h
src/ngircd/irc-channel.c
src/ngircd/irc-mode.c
src/ngircd/irc-oper.c
src/ngircd/irc.c
src/ngircd/op.c

index 37b97d689e5ed900fac5bc86eb303a7190063e2a..b1a371fc4e156e683141ab207607bd458fcfe799 100644 (file)
@@ -545,14 +545,6 @@ Client_SetIntroducer( CLIENT *Client, CLIENT *Introducer )
 } /* Client_SetIntroducer */
 
 
-GLOBAL void
-Client_SetOperByMe( CLIENT *Client, bool OperByMe )
-{
-       assert( Client != NULL );
-       Client->oper_by_me = OperByMe;
-} /* Client_SetOperByMe */
-
-
 GLOBAL bool
 Client_ModeAdd( CLIENT *Client, char Mode )
 {
@@ -889,14 +881,6 @@ Client_Flags( CLIENT *Client )
 } /* Client_Flags */
 
 
-GLOBAL bool
-Client_OperByMe( CLIENT *Client )
-{
-       assert( Client != NULL );
-       return Client->oper_by_me;
-} /* Client_OperByMe */
-
-
 GLOBAL int
 Client_Hops( CLIENT *Client )
 {
@@ -1426,7 +1410,6 @@ New_Client_Struct( void )
 
        c->type = CLIENT_UNKNOWN;
        c->conn_id = NONE;
-       c->oper_by_me = false;
        c->hops = -1;
        c->token = -1;
        c->mytoken = -1;
index e5c48b750349158f382850a497a5bc8e40e33411..c6fcec0717c880909872f5ee12854e951b12c30e 100644 (file)
@@ -58,7 +58,6 @@ typedef struct _CLIENT
        char info[CLIENT_INFO_LEN];     /* long user name (user) / info text (server) */
        char modes[CLIENT_MODE_LEN];    /* client modes */
        int hops, token, mytoken;       /* "hops" and "Token" (see SERVER command) */
-       bool oper_by_me;                /* client is local IRC operator on this server? */
        char *away;                     /* AWAY text (valid if mode 'a' is set) */
        char flags[CLIENT_FLAGS_LEN];   /* flags of the client */
        char *account_name;             /* login account (for services) */
@@ -120,7 +119,6 @@ GLOBAL const char *Client_IPAText PARAMS(( CLIENT *Client ));
 GLOBAL char *Client_Modes PARAMS(( CLIENT *Client ));
 GLOBAL char *Client_Flags PARAMS(( CLIENT *Client ));
 GLOBAL CLIENT *Client_Introducer PARAMS(( CLIENT *Client ));
-GLOBAL bool Client_OperByMe PARAMS(( CLIENT *Client ));
 GLOBAL int Client_Hops PARAMS(( CLIENT *Client ));
 GLOBAL int Client_Token PARAMS(( CLIENT *Client ));
 GLOBAL int Client_MyToken PARAMS(( CLIENT *Client ));
@@ -142,7 +140,6 @@ GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
 GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
 GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops ));
 GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token ));
-GLOBAL void Client_SetOperByMe PARAMS(( CLIENT *Client, bool OperByMe ));
 GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, const char *Modes ));
 GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, const char *Flags ));
 GLOBAL void Client_SetIntroducer PARAMS(( CLIENT *Client, CLIENT *Introducer ));
index d5e7bdd1b474a1882c0cca04048a624c17032ac3..b286b5ac3df4cf705b18dc63b695209268083d5d 100644 (file)
@@ -129,7 +129,7 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
                return false;
        }
 
-       if (Channel_HasMode(chan, 'O') && !Client_OperByMe(Client)) {
+       if (Channel_HasMode(chan, 'O') && !Client_HasMode(Client, 'o')) {
                /* Only IRC operators are allowed! */
                IRC_WriteErrClient(Client, ERR_OPONLYCHANNEL_MSG,
                                   Client_ID(Client), channame);
@@ -619,7 +619,10 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
                                /* Gotcha! */
                                if (!Channel_HasMode(chan, 's')
                                    || Channel_IsMemberOf(chan, from)
-                                   || (!Conf_MorePrivacy && Client_OperByMe(Client))) {
+                                   || (!Conf_MorePrivacy
+                                       && Client_HasMode(Client, 'o')
+                                       && Client_Conn(Client) > NONE))
+                               {
                                        if ((Conf_MaxListSize > 0)
                                            && IRC_CheckListTooBig(from, count,
                                                                   Conf_MaxListSize,
index e2fa59a2df67aa5f306629e0b3db9030a26d7c1d..af59683a744740baae7cae3ebec1dd3b22ef91c9 100644 (file)
@@ -223,11 +223,12 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                        else
                                x[0] = 'B';
                        break;
-               case 'c': /* Receive connect notices
-                          * (only settable by IRC operators!) */
+               case 'c': /* Receive connect notices */
+               case 'q': /* KICK-protected user */
+                         /* (only settable by IRC operators!) */
                        if (!set || Client_Type(Client) == CLIENT_SERVER
-                           || Client_OperByMe(Origin))
-                               x[0] = 'c';
+                           || Client_HasMode(Origin, 'o'))
+                               x[0] = *mode_ptr;
                        else
                                ok = IRC_WriteErrClient(Origin,
                                                        ERR_NOPRIVILEGES_MSG,
@@ -235,22 +236,12 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                        break;
                case 'o': /* IRC operator (only unsettable!) */
                        if (!set || Client_Type(Client) == CLIENT_SERVER) {
-                               Client_SetOperByMe(Target, false);
                                x[0] = 'o';
                        } else
                                ok = IRC_WriteErrClient(Origin,
                                                        ERR_NOPRIVILEGES_MSG,
                                                        Client_ID(Origin));
                        break;
-               case 'q': /* KICK-protected user */
-                       if (!set || Client_Type(Client) == CLIENT_SERVER
-                           || Client_OperByMe(Origin))
-                               x[0] = 'q';
-                       else
-                               ok = IRC_WriteErrClient(Origin,
-                                                       ERR_NOPRIVILEGES_MSG,
-                                                       Client_ID(Origin));
-                       break;
                case 'r': /* Restricted (only settable) */
                        if (set || Client_Type(Client) == CLIENT_SERVER)
                                x[0] = 'r';
@@ -274,7 +265,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                                        Client_ID(Origin));
                        else if (!set || Conf_CloakHostModeX[0]
                                 || Client_Type(Client) == CLIENT_SERVER
-                                || Client_OperByMe(Client)) {
+                                || Client_HasMode(Origin, 'o')) {
                                x[0] = 'x';
                                send_RPL_HOSTHIDDEN_MSG = true;
                        } else
@@ -455,7 +446,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
 
        /* Check if origin is oper and opers can use mode */
        use_servermode = Conf_OperServerMode;
-       if(Client_OperByMe(Client) && Conf_OperCanMode) {
+       if(Client_HasMode(Client, 'o') && Conf_OperCanMode) {
                is_oper = true;
        }
 
index 4d17085f4ac3ce7a264bfa900e940d17512f5c5c..74f17cc0dec9343483ec7844e9b9570a83ba57c0 100644 (file)
@@ -90,12 +90,10 @@ IRC_OPER( CLIENT *Client, REQUEST *Req )
                                          Client_ID(Client));
        }
 
-       if (!Client_OperByMe(Client))
-               Log(LOG_NOTICE|LOG_snotice,
-                   "Got valid OPER for \"%s\" from \"%s\", user is an IRC operator now.",
-                   Req->argv[0], Client_Mask(Client));
+       Log(LOG_NOTICE|LOG_snotice,
+           "Got valid OPER for \"%s\" from \"%s\", user is an IRC operator now.",
+           Req->argv[0], Client_Mask(Client));
 
-       Client_SetOperByMe(Client, true);
        return IRC_WriteStrClient(Client, RPL_YOUREOPER_MSG, Client_ID(Client));
 } /* IRC_OPER */
 
@@ -357,9 +355,8 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
 
        switch (Client_Type(Client)) {
        case CLIENT_USER:
-               if (!Client_OperByMe(Client))
-                       return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
-                                                 Client_ID(Client));
+               if (!Op_Check(Client, Req))
+                       return Op_NoPrivileges(Client, Req);
                from = Client;
                break;
        case CLIENT_SERVER:
index 8c08cdc1a744fc939d183d2fa16a5c657b788ed8..34180aa7d48eb04130da17ffdd712909859204bf 100644 (file)
@@ -33,6 +33,7 @@
 #include "match.h"
 #include "messages.h"
 #include "parse.h"
+#include "op.h"
 #include "tool.h"
 
 #include "exp.h"
@@ -134,9 +135,8 @@ IRC_KILL(CLIENT *Client, REQUEST *Req)
        assert (Client != NULL);
        assert (Req != NULL);
 
-       if (Client_Type(Client) != CLIENT_SERVER && !Client_OperByMe(Client))
-               return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
-                                         Client_ID(Client));
+       if (Client_Type(Client) != CLIENT_SERVER && !Op_Check(Client, Req))
+               return Op_NoPrivileges(Client, Req);
 
        /* Get prefix (origin); use the client if no prefix is given. */
        if (Req->prefix)
index 2d36cd559196c3e7639367370bf6960896f6e451..71e7cbcec778ae3e65a266846dfa655e04f73cd9 100644 (file)
@@ -86,7 +86,7 @@ Op_Check(CLIENT * Client, REQUEST * Req)
                return c;
        if (!Client_HasMode(c, 'o'))
                return NULL;
-       if (!Client_OperByMe(c) && !Conf_AllowRemoteOper)
+       if (Client_Conn(c) <= NONE && !Conf_AllowRemoteOper)
                return NULL;
 
        /* The client is an local IRC operator, or this server is configured