ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_oper.c
Revision: 4830
Committed: Sun Nov 2 11:14:54 2014 UTC (9 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5456 byte(s)
Log Message:
- m_oper.c:m_oper(): renamed variable

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_oper.c
23     * \brief Includes required functions for processing the OPER command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #include "client.h"
30     #include "irc_string.h"
31     #include "ircd.h"
32     #include "numeric.h"
33 michael 1309 #include "conf.h"
34     #include "log.h"
35 michael 3347 #include "user.h"
36 adx 30 #include "send.h"
37     #include "parse.h"
38     #include "modules.h"
39     #include "packet.h"
40    
41    
42    
43 michael 3336 /*! \brief Notices all opers of the failed oper attempt if enabled
44 michael 1230 *
45 michael 3336 * \param source_p Client doing /oper ...
46     * \param name The nick they tried to oper as
47     * \param reason The reason why they have failed
48 michael 1230 */
49     static void
50     failed_oper_notice(struct Client *source_p, const char *name,
51     const char *reason)
52 adx 30 {
53 michael 4341 if (ConfigGeneral.failed_oper_notice)
54 michael 1618 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 michael 1247
59 michael 1618 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 adx 30 }
63    
64 michael 3266 /*! \brief OPER command handler
65     *
66     * \param source_p Pointer to allocated Client struct from which the message
67     * originally comes from. This can be a local or remote client.
68     * \param parc Integer holding the number of supplied arguments.
69     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
70     * pointers.
71     * \note Valid arguments for this command are:
72     * - parv[0] = command
73     * - parv[1] = oper name
74     * - parv[2] = oper password
75     */
76 michael 2820 static int
77 michael 3156 m_oper(struct Client *source_p, int parc, char *parv[])
78 adx 30 {
79 michael 1632 struct MaskItem *conf = NULL;
80 michael 4830 const char *opername = parv[1];
81 adx 30 const char *password = parv[2];
82    
83     if (EmptyString(password))
84     {
85 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "OPER");
86 michael 2820 return 0;
87 adx 30 }
88    
89     /* end the grace period */
90     if (!IsFloodDone(source_p))
91     flood_endgrace(source_p);
92    
93 michael 4830 if ((conf = find_exact_name_conf(CONF_OPER, source_p, opername, NULL, NULL)) == NULL)
94 adx 30 {
95 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
96 michael 4830 conf = find_exact_name_conf(CONF_OPER, NULL, opername, NULL, NULL);
97     failed_oper_notice(source_p, opername, (conf != NULL) ?
98 michael 4285 "host mismatch" : "no operator {} block");
99 michael 2820 return 0;
100 adx 30 }
101    
102 michael 2248 if (IsConfSSL(conf) && !HasUMode(source_p, UMODE_SSL))
103     {
104 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
105 michael 4830 failed_oper_notice(source_p, opername, "requires SSL/TLS");
106 michael 2820 return 0;
107 michael 2248 }
108    
109 michael 2228 if (!EmptyString(conf->certfp))
110     {
111 michael 2229 if (EmptyString(source_p->certfp) || strcasecmp(source_p->certfp, conf->certfp))
112 michael 2228 {
113 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
114 michael 4830 failed_oper_notice(source_p, opername, "client certificate fingerprint mismatch");
115 michael 2820 return 0;
116 michael 2228 }
117     }
118    
119 michael 1632 if (match_conf_password(password, conf))
120 adx 30 {
121 michael 3914 if (attach_conf(source_p, conf))
122 adx 30 {
123 michael 3110 sendto_one_notice(source_p, &me, ":Can't attach conf!");
124 michael 4830 failed_oper_notice(source_p, opername, "can't attach conf!");
125 michael 2820 return 0;
126 adx 30 }
127    
128     oper_up(source_p);
129    
130 michael 4830 ilog(LOG_TYPE_OPER, "OPER %s by %s!%s@%s", opername, source_p->name,
131     source_p->username, source_p->host);
132 adx 30 }
133     else
134     {
135 michael 3109 sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
136 michael 4830 failed_oper_notice(source_p, opername, "password mismatch");
137 adx 30 }
138 michael 2820
139     return 0;
140 adx 30 }
141    
142 michael 3266 /*! \brief OPER command handler
143     *
144     * \param source_p Pointer to allocated Client struct from which the message
145     * originally comes from. This can be a local or remote client.
146     * \param parc Integer holding the number of supplied arguments.
147     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
148     * pointers.
149     * \note Valid arguments for this command are:
150     * - parv[0] = command
151     * - parv[1] = oper name
152     * - parv[2] = oper password
153     */
154 michael 2820 static int
155 michael 3156 mo_oper(struct Client *source_p, int parc, char *parv[])
156 adx 30 {
157 michael 3109 sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
158 michael 2820 return 0;
159 adx 30 }
160    
161 michael 2820 static struct Message oper_msgtab =
162     {
163 michael 4546 "OPER", NULL, 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
164 michael 1230 { m_unregistered, m_oper, m_ignore, m_ignore, mo_oper, m_ignore }
165     };
166    
167     static void
168     module_init(void)
169 adx 30 {
170 michael 1230 mod_add_cmd(&oper_msgtab);
171 adx 30 }
172    
173     static void
174 michael 1230 module_exit(void)
175 adx 30 {
176 michael 1230 mod_del_cmd(&oper_msgtab);
177 adx 30 }
178 michael 1230
179 michael 2820 struct module module_entry =
180     {
181 michael 1230 .node = { NULL, NULL, NULL },
182     .name = NULL,
183     .version = "$Revision$",
184     .handle = NULL,
185     .modinit = module_init,
186     .modexit = module_exit,
187     .flags = 0
188     };

Properties

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