ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_oper.c
Revision: 3110
Committed: Thu Mar 6 20:33:17 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4736 byte(s)
Log Message:
- Added sendto_one_notice()

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 michael 3096 ** parv[0] = command
69 adx 30 ** 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 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "OPER");
83 michael 2820 return 0;
84 adx 30 }
85    
86     /* end the grace period */
87     if (!IsFloodDone(source_p))
88     flood_endgrace(source_p);
89    
90 michael 1632 if ((conf = find_exact_name_conf(CONF_OPER, source_p, name, NULL, NULL)) == NULL)
91 adx 30 {
92 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
93 michael 1632 conf = find_exact_name_conf(CONF_OPER, NULL, name, NULL, NULL);
94 adx 30 failed_oper_notice(source_p, name, (conf != NULL) ?
95     "host mismatch" : "no oper {} block");
96 michael 2820 return 0;
97 adx 30 }
98    
99 michael 2248 if (IsConfSSL(conf) && !HasUMode(source_p, UMODE_SSL))
100     {
101 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
102 michael 2248 failed_oper_notice(source_p, name, "requires SSL/TLS");
103 michael 2820 return 0;
104 michael 2248 }
105    
106 michael 2228 if (!EmptyString(conf->certfp))
107     {
108 michael 2229 if (EmptyString(source_p->certfp) || strcasecmp(source_p->certfp, conf->certfp))
109 michael 2228 {
110 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
111 michael 2228 failed_oper_notice(source_p, name, "client certificate fingerprint mismatch");
112 michael 2820 return 0;
113 michael 2228 }
114     }
115    
116 michael 1632 if (match_conf_password(password, conf))
117 adx 30 {
118     if (attach_conf(source_p, conf) != 0)
119     {
120 michael 3110 sendto_one_notice(source_p, &me, ":Can't attach conf!");
121 adx 30 failed_oper_notice(source_p, name, "can't attach conf!");
122 michael 2820 return 0;
123 adx 30 }
124    
125     oper_up(source_p);
126    
127 michael 1247 ilog(LOG_TYPE_OPER, "OPER %s by %s!%s@%s",
128 adx 30 name, source_p->name, source_p->username, source_p->host);
129     }
130     else
131     {
132 michael 3109 sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
133 adx 30 failed_oper_notice(source_p, name, "password mismatch");
134     }
135 michael 2820
136     return 0;
137 adx 30 }
138    
139     /*
140     ** mo_oper
141 michael 3096 ** parv[0] = command
142 adx 30 ** parv[1] = oper name
143     ** parv[2] = oper password
144     */
145 michael 2820 static int
146 adx 30 mo_oper(struct Client *client_p, struct Client *source_p,
147     int parc, char *parv[])
148     {
149 michael 3109 sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
150 michael 2820 return 0;
151 adx 30 }
152    
153 michael 2820 static struct Message oper_msgtab =
154     {
155 michael 1230 "OPER", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
156     { m_unregistered, m_oper, m_ignore, m_ignore, mo_oper, m_ignore }
157     };
158    
159     static void
160     module_init(void)
161 adx 30 {
162 michael 1230 mod_add_cmd(&oper_msgtab);
163 adx 30 }
164    
165     static void
166 michael 1230 module_exit(void)
167 adx 30 {
168 michael 1230 mod_del_cmd(&oper_msgtab);
169 adx 30 }
170 michael 1230
171 michael 2820 struct module module_entry =
172     {
173 michael 1230 .node = { NULL, NULL, NULL },
174     .name = NULL,
175     .version = "$Revision$",
176     .handle = NULL,
177     .modinit = module_init,
178     .modexit = module_exit,
179     .flags = 0
180     };

Properties

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