ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsmode.c
Revision: 1819
Committed: Fri Apr 12 11:57:26 2013 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 5585 byte(s)
Log Message:
- Removed recently added m_svshost.c. Services may now change the host of a
  specific user via "SVSMODE <timestamp> <target> +x <hostname>"

File Contents

# User Rev Content
1 michael 1159 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     *
4     * Copyright (C) 1999 by the Bahamut Development Team.
5     * Copyright (C) 2011 by the Hybrid Development Team.
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    
23     /*! \file m_svsmode.c
24     * \brief Includes required functions for processing the SVSMODE command.
25 michael 1160 * \version $Id$
26 michael 1159 */
27    
28     #include "stdinc.h"
29     #include "client.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "s_serv.h"
33     #include "send.h"
34     #include "channel_mode.h"
35     #include "parse.h"
36     #include "modules.h"
37     #include "irc_string.h"
38     #include "s_user.h"
39 michael 1309 #include "conf.h"
40 michael 1243 #include "hook.h"
41 michael 1159
42    
43 michael 1221 /*! \brief SVSMODE command handler (called by services)
44 michael 1159 *
45     * \param client_p Pointer to allocated Client struct with physical connection
46     * to this server, i.e. with an open socket connected.
47     * \param source_p Pointer to allocated Client struct from which the message
48     * originally comes from. This can be a local or remote client.
49     * \param parc Integer holding the number of supplied arguments.
50     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
51     * pointers.
52     * \note Valid arguments for this command are:
53     * - parv[0] = sender prefix
54     * - parv[1] = nickname
55 michael 1809 * - parv[2] = TS
56     * - parv[3] = mode
57 michael 1819 * - parv[4] = optional argument (services id, hostname)
58 michael 1159 */
59     static void
60     ms_svsmode(struct Client *client_p, struct Client *source_p,
61     int parc, char *parv[])
62     {
63     struct Client *target_p = NULL;
64 michael 1809 const char *m = NULL, *extarg = NULL;
65 michael 1159 int what = MODE_ADD;
66 michael 1819 unsigned int flag = 0, setflags = 0;
67 michael 1159 time_t ts = 0;
68    
69 michael 1221 if (!HasFlag(source_p, FLAGS_SERVICE))
70 michael 1159 return;
71    
72     if ((target_p = find_person(client_p, parv[1])) == NULL)
73     return;
74    
75 michael 1809 if ((ts = atol(parv[2])) && (ts != target_p->tsinfo))
76 michael 1159 return;
77    
78 michael 1809 if (parc > 4 && !EmptyString(parv[4]))
79     extarg = parv[4];
80 michael 1159
81 michael 1819 setflags = target_p->umodes;
82 michael 1809
83     for (m = parv[3]; *m; ++m)
84 michael 1159 {
85     switch (*m)
86     {
87     case '+':
88     what = MODE_ADD;
89     break;
90     case '-':
91     what = MODE_DEL;
92     break;
93 michael 1163
94     case 'd':
95 michael 1809 if (extarg)
96 michael 1559 strlcpy(target_p->svid, extarg, sizeof(target_p->svid));
97 michael 1163 break;
98    
99 michael 1819 case 'x':
100     if (what == MODE_ADD && extarg)
101     user_set_hostmask(target_p, extarg);
102     break;
103    
104 michael 1159 case 'o':
105 michael 1219 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
106 michael 1159 {
107     ClearOper(target_p);
108     Count.oper--;
109    
110     if (MyConnect(target_p))
111     {
112     dlink_node *dm = NULL;
113    
114 michael 1632 detach_conf(target_p, CONF_OPER);
115 michael 1219 ClrOFlag(target_p);
116 michael 1159 DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
117    
118     if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
119     free_dlink_node(dm);
120     }
121     }
122    
123     break;
124    
125 michael 1163 case 'i':
126     if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
127     {
128     AddUMode(target_p, UMODE_INVISIBLE);
129     ++Count.invisi;
130     }
131    
132     if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
133     {
134     DelUMode(target_p, UMODE_INVISIBLE);
135     --Count.invisi;
136     }
137    
138     break;
139    
140 michael 1159 case ' ':
141     case '\n':
142     case '\r':
143     case '\t':
144     break;
145     default:
146     if ((flag = user_modes[(unsigned char)*m]))
147     execute_callback(umode_cb, client_p, target_p, what, flag);
148     break;
149     }
150     }
151    
152     if (extarg)
153     {
154 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
155 michael 1159 ":%s SVSMODE %s %lu %s %s", ID(source_p),
156 michael 1809 ID(target_p), (unsigned long)target_p->tsinfo, parv[3], extarg);
157 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
158 michael 1159 ":%s SVSMODE %s %lu %s %s", source_p->name,
159 michael 1809 target_p->name, (unsigned long)target_p->tsinfo, parv[3], extarg);
160 michael 1159 }
161     else
162     {
163 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
164 michael 1159 ":%s SVSMODE %s %lu %s", ID(source_p),
165 michael 1809 ID(target_p), (unsigned long)target_p->tsinfo, parv[3]);
166 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
167 michael 1159 ":%s SVSMODE %s %lu %s", source_p->name,
168 michael 1809 target_p->name, (unsigned long)target_p->tsinfo, parv[3]);
169 michael 1159 }
170    
171 michael 1819 if (MyConnect(target_p) && (setflags != target_p->umodes))
172 michael 1159 {
173     char modebuf[IRCD_BUFSIZE];
174    
175 michael 1819 send_umode(target_p, target_p, setflags, 0xffffffff, modebuf);
176 michael 1159 }
177     }
178 michael 1230
179     static struct Message svsmode_msgtab = {
180 michael 1809 "SVSMODE", 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
181 michael 1230 {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
182     };
183    
184     static void
185     module_init(void)
186     {
187     mod_add_cmd(&svsmode_msgtab);
188     }
189    
190     static void
191     module_exit(void)
192     {
193     mod_del_cmd(&svsmode_msgtab);
194     }
195    
196     struct module module_entry = {
197     .node = { NULL, NULL, NULL },
198     .name = NULL,
199     .version = "$Revision$",
200     .handle = NULL,
201     .modinit = module_init,
202     .modexit = module_exit,
203     .flags = 0
204     };

Properties

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