ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_oper.c
Revision: 3156
Committed: Fri Mar 14 19:57:38 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4671 byte(s)
Log Message:
- Removed client_p pointers from everywhere

File Contents

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

Properties

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