]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/op.c
New configuration option "NoZeroConf" to disable ZeroConf registration
[ngircd-alex.git] / src / ngircd / op.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
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  * IRC operator functions
12  */
13
14
15 #include "portab.h"
16
17 #include "imp.h"
18 #include <assert.h>
19 #include <string.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 <exp.h>
30 #include "op.h"
31
32 /**
33  * Return and log a "no privileges" message.
34  */
35 GLOBAL bool
36 Op_NoPrivileges(CLIENT * Client, REQUEST * Req)
37 {
38         CLIENT *from = NULL;
39
40         if (Req->prefix)
41                 from = Client_Search(Req->prefix);
42
43         if (from) {
44                 Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"",
45                     Req->prefix, Client_Mask(Client), Req->command);
46                 return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
47                                           Client_ID(from));
48         } else {
49                 Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"",
50                     Client_Mask(Client), Req->command);
51                 return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
52                                           Client_ID(Client));
53         }
54 } /* Op_NoPrivileges */
55
56
57 /**
58  * Check that the client is an IRC operator allowed to administer this server.
59  */
60 GLOBAL bool
61 Op_Check(CLIENT * Client, REQUEST * Req)
62 {
63         CLIENT *c;
64
65         assert(Client != NULL);
66         assert(Req != NULL);
67
68         if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
69                 c = Client_Search(Req->prefix);
70         else
71                 c = Client;
72         if (!c)
73                 return false;
74         if (!Client_HasMode(c, 'o'))
75                 return false;
76         if (!Client_OperByMe(c) && !Conf_AllowRemoteOper)
77                 return false;
78         /* The client is an local IRC operator, or this server is configured
79          * to trust remote operators. */
80         return true;
81 } /* Op_Check */