ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_oper.c
Revision: 101
Committed: Mon Oct 10 03:52:14 2005 UTC (20 years, 10 months ago) by db
Content type: text/x-csrc
File size: 4878 byte(s)
Log Message:
- First pass at s_conf.c cleanup for attach clients
- attach_conf() is gone replaced with attach_iline()
  Clients/servers have one single I line "attached", i.e. the confs
  list is gone.
- Add attach_leaf_hub()
  Add a leaf or hub mask to the given server, ->serv must exist
  since there can be a list of hub masks and leaf masks, this continues
  to be a dlink list
- Removed redundant find_conf_exact()
  This function can be replaced in all cases with find_exact_name_conf()
  notably because all find_conf_exact did differently was count whether
  an oper conf would cause an already connected client to exceed class limits.
- oper_up() now takes an extra conf pointer pointing to the found
  oper conf, the oper flags are set in the client->iline as necessary
  in oper_up()
- Cleaned up more prototypes that should have been moved from s_conf.h
  to parse_aline.h notably. find_kill() and find_gkill()
- m_stats.c needs more cleanup since memory in attached "confs" is now
  not counted. This should be replaced with iline memory count and
  hub/leaf confs memory count.
  

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "client.h"
28     #include "common.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "s_conf.h"
32     #include "s_user.h"
33     #include "send.h"
34     #include "msg.h"
35     #include "parse.h"
36     #include "modules.h"
37     #include "packet.h"
38    
39     static struct ConfItem *find_password_conf(const char *, struct Client *);
40     static void failed_oper_notice(struct Client *, const char *, const char *);
41     static void m_oper(struct Client *, struct Client *, int, char *[]);
42     static void mo_oper(struct Client *, struct Client *, int, char *[]);
43    
44     struct Message oper_msgtab = {
45     "OPER", 0, 0, 3, 0, MFLG_SLOW, 0,
46     { m_unregistered, m_oper, m_ignore, m_ignore, mo_oper, m_ignore }
47     };
48    
49     #ifndef STATIC_MODULES
50     void
51     _modinit(void)
52     {
53     mod_add_cmd(&oper_msgtab);
54     }
55    
56     void
57     _moddeinit(void)
58     {
59     mod_del_cmd(&oper_msgtab);
60     }
61    
62 knight 31 const char *_version = "$Revision$";
63 adx 30 #endif
64    
65     /*
66     ** m_oper
67     ** parv[0] = sender prefix
68     ** parv[1] = oper name
69     ** parv[2] = oper password
70     */
71     static void
72     m_oper(struct Client *client_p, struct Client *source_p,
73     int parc, char *parv[])
74     {
75     struct ConfItem *conf;
76     struct AccessItem *aconf=NULL;
77     const char *name = parv[1];
78     const char *password = parv[2];
79    
80     if (EmptyString(password))
81     {
82     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
83     me.name, source_p->name, "OPER");
84     return;
85     }
86    
87     /* end the grace period */
88     if (!IsFloodDone(source_p))
89     flood_endgrace(source_p);
90    
91     if ((conf = find_password_conf(name, source_p)) == NULL)
92     {
93     sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
94     conf = find_exact_name_conf(OPER_TYPE, name, NULL, NULL);
95     failed_oper_notice(source_p, name, (conf != NULL) ?
96     "host mismatch" : "no oper {} block");
97     log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n", name);
98     return;
99     }
100    
101     aconf = (struct AccessItem *)map_to_conf(conf);
102    
103     if (match_conf_password(password, aconf))
104     {
105 db 101 oper_up(source_p, conf);
106 adx 30
107     ilog(L_TRACE, "OPER %s by %s!%s@%s",
108     name, source_p->name, source_p->username, source_p->host);
109     log_oper_action(LOG_OPER_TYPE, source_p, "%s\n", name);
110     }
111     else
112     {
113     sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, parv[0]);
114     failed_oper_notice(source_p, name, "password mismatch");
115     log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n", name);
116     }
117     }
118    
119     /*
120     ** mo_oper
121     ** parv[0] = sender prefix
122     ** parv[1] = oper name
123     ** parv[2] = oper password
124     */
125     static void
126     mo_oper(struct Client *client_p, struct Client *source_p,
127     int parc, char *parv[])
128     {
129     sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
130     send_message_file(source_p, &ConfigFileEntry.opermotd);
131     }
132    
133     /* find_password_conf()
134     *
135     * inputs - name
136     * - pointer to source_p
137     * output - pointer to oper conf or NULL
138     * side effects - NONE
139     */
140     static struct ConfItem *
141     find_password_conf(const char *name, struct Client *source_p)
142     {
143     struct ConfItem *conf = NULL;
144    
145     if ((conf = find_exact_name_conf(OPER_TYPE,
146     name, source_p->username, source_p->host
147     )) != NULL)
148     {
149     return(conf);
150     }
151    
152     if ((conf = find_exact_name_conf(OPER_TYPE,
153     name, source_p->username,
154     source_p->sockhost)) != NULL)
155     {
156     return(conf);
157     }
158    
159     return(NULL);
160     }
161    
162     /* failed_oper_notice()
163     *
164     * inputs - pointer to client doing /oper ...
165     * - pointer to nick they tried to oper as
166     * - pointer to reason they have failed
167     * output - nothing
168     * side effects - notices all opers of the failed oper attempt if enabled
169     */
170     static void
171     failed_oper_notice(struct Client *source_p, const char *name,
172     const char *reason)
173     {
174     if (ConfigFileEntry.failed_oper_notice)
175     sendto_realops_flags(UMODE_ALL, L_ALL, "Failed OPER attempt as %s "
176     "by %s (%s@%s) - %s", name, source_p->name,
177     source_p->username, source_p->host, reason);
178     }

Properties

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