/[svn]/ircd-hybrid/branches/8.2.x/modules/m_svsmode.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.2.x/modules/m_svsmode.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7329 - (show annotations)
Thu Feb 18 21:07:50 2016 UTC (6 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 5458 byte(s)
- Now that we got time_t to work nicely on openbsd with snprintf's conversion specifiers,
  we ran into a similiar issue on Raspbian/ARMv7's time_t which is of signed 32 bit and
  doesn't cope at all with %j. Instead of doing tricks, get rid of time_t everywhere and
  forever and use uintmax_t instead which has at least a 'standardized' conversion specifier
  associated with it.

1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1999 Bahamut development team.
5 * Copyright (c) 2011-2016 ircd-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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 * USA
21 */
22
23 /*! \file m_svsmode.c
24 * \brief Includes required functions for processing the SVSMODE command.
25 * \version $Id$
26 */
27
28 #include "stdinc.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "send.h"
32 #include "channel_mode.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "irc_string.h"
36 #include "user.h"
37 #include "conf.h"
38
39
40 /*! \brief SVSMODE command handler
41 *
42 * \param source_p Pointer to allocated Client struct from which the message
43 * originally comes from. This can be a local or remote client.
44 * \param parc Integer holding the number of supplied arguments.
45 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
46 * pointers.
47 * \note Valid arguments for this command are:
48 * - parv[0] = command
49 * - parv[1] = nickname
50 * - parv[2] = TS
51 * - parv[3] = mode
52 * - parv[4] = optional argument (services account, vhost)
53 */
54 static int
55 ms_svsmode(struct Client *source_p, int parc, char *parv[])
56 {
57 const struct user_modes *tab = NULL;
58 struct Client *target_p = NULL;
59 int what = MODE_ADD;
60 unsigned int setmodes = 0;
61 const char *modes = NULL, *extarg = NULL;
62
63 if (!HasFlag(source_p, FLAGS_SERVICE))
64 return 0;
65
66 modes = parv[3];
67 extarg = (parc > 4) ? parv[4] : NULL;
68
69 if ((target_p = find_person(source_p, parv[1])) == NULL)
70 return 0;
71
72 uintmax_t ts = strtoumax(parv[2], NULL, 10);
73 if (ts && (ts != target_p->tsinfo))
74 return 0;
75
76 setmodes = target_p->umodes;
77
78 for (const char *m = modes; *m; ++m)
79 {
80 switch (*m)
81 {
82 case '+':
83 what = MODE_ADD;
84 break;
85 case '-':
86 what = MODE_DEL;
87 break;
88
89 case 'd':
90 if (!EmptyString(extarg))
91 {
92 strlcpy(target_p->account, extarg, sizeof(target_p->account));
93 sendto_common_channels_local(target_p, 1, CAP_ACCOUNT_NOTIFY, 0, ":%s!%s@%s ACCOUNT %s",
94 target_p->name, target_p->username,
95 target_p->host, target_p->account);
96 }
97
98 break;
99
100 case 'x':
101 if (!EmptyString(extarg) && valid_hostname(extarg))
102 user_set_hostmask(target_p, extarg, what);
103 break;
104
105 case 'o':
106 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
107 {
108 ClearOper(target_p);
109 --Count.oper;
110
111 if (MyConnect(target_p))
112 {
113 dlink_node *node = NULL;
114
115 detach_conf(target_p, CONF_OPER);
116 ClrOFlag(target_p);
117 DelUMode(target_p, ConfigGeneral.oper_only_umodes);
118
119 if ((node = dlinkFindDelete(&oper_list, target_p)))
120 free_dlink_node(node);
121 }
122 }
123
124 break;
125
126 case 'i':
127 if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
128 {
129 AddUMode(target_p, UMODE_INVISIBLE);
130 ++Count.invisi;
131 }
132 else 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 case 'S': /* Only servers may set +S in a burst */
141 case 'W': /* Only servers may set +W in a burst */
142 break;
143
144 default:
145 if ((tab = umode_map[(unsigned char)*m]))
146 {
147 if (what == MODE_ADD)
148 AddUMode(target_p, tab->flag);
149 else
150 DelUMode(target_p, tab->flag);
151 }
152
153 break;
154 }
155 }
156
157 if (extarg)
158 sendto_server(source_p, 0, 0, ":%s SVSMODE %s %ju %s %s",
159 source_p->id,
160 target_p->id, target_p->tsinfo, modes, extarg);
161 else
162 sendto_server(source_p, 0, 0, ":%s SVSMODE %s %ju %s",
163 source_p->id,
164 target_p->id, target_p->tsinfo, modes);
165
166 if (MyConnect(target_p) && (setmodes != target_p->umodes))
167 {
168 char modebuf[IRCD_BUFSIZE] = "";
169
170 send_umode(target_p, target_p, setmodes, modebuf);
171 }
172
173 return 0;
174 }
175
176 static struct Message svsmode_msgtab =
177 {
178 .cmd = "SVSMODE",
179 .args_min = 4,
180 .args_max = MAXPARA,
181 .handlers[UNREGISTERED_HANDLER] = m_ignore,
182 .handlers[CLIENT_HANDLER] = m_ignore,
183 .handlers[SERVER_HANDLER] = ms_svsmode,
184 .handlers[ENCAP_HANDLER] = m_ignore,
185 .handlers[OPER_HANDLER] = m_ignore
186 };
187
188 static void
189 module_init(void)
190 {
191 mod_add_cmd(&svsmode_msgtab);
192 }
193
194 static void
195 module_exit(void)
196 {
197 mod_del_cmd(&svsmode_msgtab);
198 }
199
200 struct module module_entry =
201 {
202 .version = "$Revision$",
203 .modinit = module_init,
204 .modexit = module_exit,
205 };

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28