[BACK]Return to op.c CVS log [TXT][DIR] Up to [local] / ircnowd / src / ngircd

Annotation of ircnowd/src/ngircd/op.c, Revision 1.1.1.1

1.1       tomglok     1: /*
                      2:  * ngIRCd -- The Next Generation IRC Daemon
                      3:  * Copyright (c)2001-2018 Alexander Barton (alex@barton.de) and Contributors.
                      4:  *
                      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.
                     10:  */
                     11:
                     12: #include "portab.h"
                     13:
                     14: /**
                     15:  * @file
                     16:  * IRC operator functions
                     17:  */
                     18:
                     19: #include <assert.h>
                     20:
                     21: #include "conn.h"
                     22: #include "channel.h"
                     23: #include "conf.h"
                     24: #include "log.h"
                     25: #include "parse.h"
                     26: #include "messages.h"
                     27: #include "irc-write.h"
                     28:
                     29: #include "op.h"
                     30:
                     31: /**
                     32:  * Return and log a "no privileges" message.
                     33:  */
                     34: GLOBAL bool
                     35: Op_NoPrivileges(CLIENT * Client, REQUEST * Req)
                     36: {
                     37:        CLIENT *from = NULL;
                     38:
                     39:        if (Req->prefix)
                     40:                from = Client_Search(Req->prefix);
                     41:
                     42:        if (from) {
                     43:                Log(LOG_ERR|LOG_snotice,
                     44:                    "No privileges: client \"%s\" (%s), command \"%s\"!",
                     45:                    Req->prefix, Client_Mask(Client), Req->command);
                     46:                return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
                     47:                                          Client_ID(from));
                     48:        } else {
                     49:                Log(LOG_ERR|LOG_snotice,
                     50:                    "No privileges: client \"%s\", command \"%s\"!",
                     51:                    Client_Mask(Client), Req->command);
                     52:                return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
                     53:                                          Client_ID(Client));
                     54:        }
                     55: } /* Op_NoPrivileges */
                     56:
                     57: /**
                     58:  * Check that the originator of a request is an IRC operator and allowed
                     59:  * to administer this server.
                     60:  *
                     61:  * @param Client Client from which the command has been received.
                     62:  * @param Req Request structure.
                     63:  * @return CLIENT structure of the client that initiated the command or
                     64:  *        NULL if client is not allowed to execute operator commands.
                     65:  */
                     66: GLOBAL CLIENT *
                     67: Op_Check(CLIENT * Client, REQUEST * Req)
                     68: {
                     69:        CLIENT *c;
                     70:
                     71:        assert(Client != NULL);
                     72:        assert(Req != NULL);
                     73:
                     74:        if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
                     75:                c = Client_Search(Req->prefix);
                     76:        else
                     77:                c = Client;
                     78:
                     79:        if (!c)
                     80:                return NULL;
                     81:        if (Client_Type(Client) == CLIENT_SERVER
                     82:            && Client_Type(c) == CLIENT_SERVER)
                     83:                return c;
                     84:        if (!Client_HasMode(c, 'o'))
                     85:                return NULL;
                     86:        if (Client_Conn(c) <= NONE && !Conf_AllowRemoteOper)
                     87:                return NULL;
                     88:
                     89:        /* The client is an local IRC operator, or this server is configured
                     90:         * to trust remote operators. */
                     91:        return c;
                     92: } /* Op_Check */
                     93:
                     94: /* -eof- */

CVSweb