ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_oper.c
Revision: 2947
Committed: Sun Jan 26 19:41:03 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 4952 byte(s)
Log Message:
- Revert -r1925. We no longer show how many times an oline has been hit.

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     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * 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 adx 30 #include "s_user.h"
36     #include "send.h"
37     #include "parse.h"
38     #include "modules.h"
39     #include "packet.h"
40    
41    
42    
43 michael 1230 /* 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 adx 30 {
55 michael 1230 if (ConfigFileEntry.failed_oper_notice)
56 michael 1618 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 michael 1247
61 michael 1618 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 adx 30 }
65    
66     /*
67     ** m_oper
68     ** parv[0] = sender prefix
69     ** parv[1] = oper name
70     ** parv[2] = oper password
71     */
72 michael 2820 static int
73 adx 30 m_oper(struct Client *client_p, struct Client *source_p,
74     int parc, char *parv[])
75     {
76 michael 1632 struct MaskItem *conf = NULL;
77 adx 30 const char *name = parv[1];
78     const char *password = parv[2];
79    
80     if (EmptyString(password))
81     {
82 michael 1834 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
83 michael 1446 me.name, source_p->name, "OPER");
84 michael 2820 return 0;
85 adx 30 }
86    
87     /* end the grace period */
88     if (!IsFloodDone(source_p))
89     flood_endgrace(source_p);
90    
91 michael 1632 if ((conf = find_exact_name_conf(CONF_OPER, source_p, name, NULL, NULL)) == NULL)
92 adx 30 {
93 michael 1834 sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
94 michael 1632 conf = find_exact_name_conf(CONF_OPER, NULL, name, NULL, NULL);
95 adx 30 failed_oper_notice(source_p, name, (conf != NULL) ?
96     "host mismatch" : "no oper {} block");
97 michael 2820 return 0;
98 adx 30 }
99    
100 michael 2248 if (IsConfSSL(conf) && !HasUMode(source_p, UMODE_SSL))
101     {
102     sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
103     failed_oper_notice(source_p, name, "requires SSL/TLS");
104 michael 2820 return 0;
105 michael 2248 }
106    
107 michael 2228 if (!EmptyString(conf->certfp))
108     {
109 michael 2229 if (EmptyString(source_p->certfp) || strcasecmp(source_p->certfp, conf->certfp))
110 michael 2228 {
111     sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
112     failed_oper_notice(source_p, name, "client certificate fingerprint mismatch");
113 michael 2820 return 0;
114 michael 2228 }
115     }
116    
117 michael 1632 if (match_conf_password(password, conf))
118 adx 30 {
119     if (attach_conf(source_p, conf) != 0)
120     {
121     sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
122     me.name, source_p->name);
123     failed_oper_notice(source_p, name, "can't attach conf!");
124 michael 2820 return 0;
125 adx 30 }
126    
127     oper_up(source_p);
128    
129 michael 1247 ilog(LOG_TYPE_OPER, "OPER %s by %s!%s@%s",
130 adx 30 name, source_p->name, source_p->username, source_p->host);
131     }
132     else
133     {
134 michael 1834 sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
135 adx 30 failed_oper_notice(source_p, name, "password mismatch");
136     }
137 michael 2820
138     return 0;
139 adx 30 }
140    
141     /*
142     ** mo_oper
143     ** parv[0] = sender prefix
144     ** parv[1] = oper name
145     ** parv[2] = oper password
146     */
147 michael 2820 static int
148 adx 30 mo_oper(struct Client *client_p, struct Client *source_p,
149     int parc, char *parv[])
150     {
151 michael 1834 sendto_one(source_p, form_str(RPL_YOUREOPER),
152 michael 1446 me.name, source_p->name);
153 michael 2820 return 0;
154 adx 30 }
155    
156 michael 2820 static struct Message oper_msgtab =
157     {
158 michael 1230 "OPER", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
159     { m_unregistered, m_oper, m_ignore, m_ignore, mo_oper, m_ignore }
160     };
161    
162     static void
163     module_init(void)
164 adx 30 {
165 michael 1230 mod_add_cmd(&oper_msgtab);
166 adx 30 }
167    
168     static void
169 michael 1230 module_exit(void)
170 adx 30 {
171 michael 1230 mod_del_cmd(&oper_msgtab);
172 adx 30 }
173 michael 1230
174 michael 2820 struct module module_entry =
175     {
176 michael 1230 .node = { NULL, NULL, NULL },
177     .name = NULL,
178     .version = "$Revision$",
179     .handle = NULL,
180     .modinit = module_init,
181     .modexit = module_exit,
182     .flags = 0
183     };

Properties

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