ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_oper.c
Revision: 1618
Committed: Tue Oct 30 21:04:38 2012 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4389 byte(s)
Log Message:
- Made m_globops() and ms_globops() use sendto_realops_flags()
- Added message-type parameter to sendto_realops_flags() which can be one of
  SEND_NOTICE, SEND_GLOBAL, SEND_LOCOPS
- Forward-port -r1617

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_oper.c: Makes a user an IRC Operator.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "client.h"
28 #include "irc_string.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "conf.h"
32 #include "log.h"
33 #include "s_user.h"
34 #include "send.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "packet.h"
38
39
40
41 /* failed_oper_notice()
42 *
43 * inputs - pointer to client doing /oper ...
44 * - pointer to nick they tried to oper as
45 * - pointer to reason they have failed
46 * output - nothing
47 * side effects - notices all opers of the failed oper attempt if enabled
48 */
49 static void
50 failed_oper_notice(struct Client *source_p, const char *name,
51 const char *reason)
52 {
53 if (ConfigFileEntry.failed_oper_notice)
54 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
55 "Failed OPER attempt as %s by %s (%s@%s) - %s",
56 name, source_p->name, source_p->username,
57 source_p->host, reason);
58
59 ilog(LOG_TYPE_OPER, "Failed OPER attempt as %s by %s (%s@%s) - %s",
60 name, source_p->name, source_p->username,
61 source_p->host, reason);
62 }
63
64 /*
65 ** m_oper
66 ** parv[0] = sender prefix
67 ** parv[1] = oper name
68 ** parv[2] = oper password
69 */
70 static void
71 m_oper(struct Client *client_p, struct Client *source_p,
72 int parc, char *parv[])
73 {
74 struct ConfItem *conf;
75 struct AccessItem *aconf=NULL;
76 const char *name = parv[1];
77 const char *password = parv[2];
78
79 if (EmptyString(password))
80 {
81 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
82 me.name, source_p->name, "OPER");
83 return;
84 }
85
86 /* end the grace period */
87 if (!IsFloodDone(source_p))
88 flood_endgrace(source_p);
89
90 if ((conf = find_exact_name_conf(OPER_TYPE, source_p, name, NULL, NULL)) == NULL)
91 {
92 sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
93 conf = find_exact_name_conf(OPER_TYPE, NULL, name, NULL, NULL);
94 failed_oper_notice(source_p, name, (conf != NULL) ?
95 "host mismatch" : "no oper {} block");
96 return;
97 }
98
99 aconf = map_to_conf(conf);
100
101 if (match_conf_password(password, aconf))
102 {
103 if (attach_conf(source_p, conf) != 0)
104 {
105 sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
106 me.name, source_p->name);
107 failed_oper_notice(source_p, name, "can't attach conf!");
108 return;
109 }
110
111 oper_up(source_p);
112
113 ilog(LOG_TYPE_OPER, "OPER %s by %s!%s@%s",
114 name, source_p->name, source_p->username, source_p->host);
115 }
116 else
117 {
118 sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
119 failed_oper_notice(source_p, name, "password mismatch");
120 }
121 }
122
123 /*
124 ** mo_oper
125 ** parv[0] = sender prefix
126 ** parv[1] = oper name
127 ** parv[2] = oper password
128 */
129 static void
130 mo_oper(struct Client *client_p, struct Client *source_p,
131 int parc, char *parv[])
132 {
133 sendto_one(source_p, form_str(RPL_YOUREOPER),
134 me.name, source_p->name);
135 }
136
137 static struct Message oper_msgtab = {
138 "OPER", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
139 { m_unregistered, m_oper, m_ignore, m_ignore, mo_oper, m_ignore }
140 };
141
142 static void
143 module_init(void)
144 {
145 mod_add_cmd(&oper_msgtab);
146 }
147
148 static void
149 module_exit(void)
150 {
151 mod_del_cmd(&oper_msgtab);
152 }
153
154 struct module module_entry = {
155 .node = { NULL, NULL, NULL },
156 .name = NULL,
157 .version = "$Revision$",
158 .handle = NULL,
159 .modinit = module_init,
160 .modexit = module_exit,
161 .flags = 0
162 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision