| 2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
|
* Copyright (c) 1999 Bahamut development team. |
| 5 |
< |
* Copyright (c) 2011-2014 ircd-hybrid development team |
| 5 |
> |
* Copyright (c) 2011-2015 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 |
| 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 |
| 19 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 20 |
|
* USA |
| 21 |
|
*/ |
| 22 |
|
|
| 28 |
|
#include "stdinc.h" |
| 29 |
|
#include "client.h" |
| 30 |
|
#include "ircd.h" |
| 31 |
– |
#include "s_serv.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 "s_user.h" |
| 36 |
> |
#include "user.h" |
| 37 |
|
#include "conf.h" |
| 38 |
|
|
| 39 |
|
|
| 40 |
< |
/*! \brief SVSMODE command handler (called by services) |
| 40 |
> |
/*! \brief SVSMODE command handler |
| 41 |
|
* |
| 43 |
– |
* \param client_p Pointer to allocated Client struct with physical connection |
| 44 |
– |
* to this server, i.e. with an open socket connected. |
| 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] = sender prefix |
| 48 |
> |
* - parv[0] = command |
| 49 |
|
* - parv[1] = nickname |
| 50 |
< |
* - parv[2] = TS (or mode, depending on svs version) |
| 51 |
< |
* - parv[3] = mode (or services id if old svs version) |
| 52 |
< |
* - parv[4] = optional argument (services id) |
| 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 *client_p, struct Client *source_p, |
| 59 |
< |
int parc, char *parv[]) |
| 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 flag = 0, setmodes = 0; |
| 61 |
< |
const char *m = NULL, *modes = NULL, *extarg = NULL; |
| 60 |
> |
const unsigned int setmodes = target_p->umodes; |
| 61 |
> |
const char *modes = NULL, *extarg = NULL; |
| 62 |
|
time_t ts = 0; |
| 63 |
|
|
| 64 |
|
if (!HasFlag(source_p, FLAGS_SERVICE)) |
| 65 |
|
return 0; |
| 66 |
|
|
| 67 |
< |
if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-'))) |
| 68 |
< |
{ |
| 69 |
< |
ts = atol(parv[2]); |
| 73 |
< |
modes = parv[3]; |
| 74 |
< |
extarg = (parc > 4) ? parv[4] : NULL; |
| 75 |
< |
} |
| 76 |
< |
else |
| 77 |
< |
{ |
| 78 |
< |
modes = parv[2]; |
| 79 |
< |
extarg = (parc > 3) ? parv[3] : NULL; |
| 80 |
< |
} |
| 67 |
> |
ts = atol(parv[2]); |
| 68 |
> |
modes = parv[3]; |
| 69 |
> |
extarg = (parc > 4) ? parv[4] : NULL; |
| 70 |
|
|
| 71 |
< |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
| 71 |
> |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
| 72 |
|
return 0; |
| 73 |
|
|
| 74 |
|
if (ts && (ts != target_p->tsinfo)) |
| 75 |
|
return 0; |
| 76 |
|
|
| 77 |
< |
setmodes = target_p->umodes; |
| 89 |
< |
|
| 90 |
< |
for (m = modes; *m; ++m) |
| 77 |
> |
for (const char *m = modes; *m; ++m) |
| 78 |
|
{ |
| 79 |
|
switch (*m) |
| 80 |
|
{ |
| 87 |
|
|
| 88 |
|
case 'd': |
| 89 |
|
if (!EmptyString(extarg)) |
| 90 |
< |
strlcpy(target_p->svid, extarg, sizeof(target_p->svid)); |
| 90 |
> |
strlcpy(target_p->account, extarg, sizeof(target_p->account)); |
| 91 |
|
break; |
| 92 |
|
|
| 93 |
|
case 'x': |
| 99 |
|
if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER)) |
| 100 |
|
{ |
| 101 |
|
ClearOper(target_p); |
| 102 |
< |
Count.oper--; |
| 102 |
> |
--Count.oper; |
| 103 |
|
|
| 104 |
|
if (MyConnect(target_p)) |
| 105 |
|
{ |
| 106 |
< |
dlink_node *dm = NULL; |
| 106 |
> |
dlink_node *node = NULL; |
| 107 |
|
|
| 108 |
|
detach_conf(target_p, CONF_OPER); |
| 109 |
|
ClrOFlag(target_p); |
| 110 |
< |
DelUMode(target_p, ConfigFileEntry.oper_only_umodes); |
| 110 |
> |
DelUMode(target_p, ConfigGeneral.oper_only_umodes); |
| 111 |
|
|
| 112 |
< |
if ((dm = dlinkFindDelete(&oper_list, target_p))) |
| 113 |
< |
free_dlink_node(dm); |
| 112 |
> |
if ((node = dlinkFindDelete(&oper_list, target_p))) |
| 113 |
> |
free_dlink_node(node); |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
|
| 136 |
|
break; |
| 137 |
|
|
| 138 |
|
default: |
| 139 |
< |
if ((flag = user_modes[(unsigned char)*m])) |
| 139 |
> |
if ((tab = umode_map[(unsigned char)*m])) |
| 140 |
|
{ |
| 141 |
|
if (what == MODE_ADD) |
| 142 |
< |
AddUMode(target_p, flag); |
| 142 |
> |
AddUMode(target_p, tab->flag); |
| 143 |
|
else |
| 144 |
< |
DelUMode(target_p, flag); |
| 144 |
> |
DelUMode(target_p, tab->flag); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
break; |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
if (extarg) |
| 152 |
< |
{ |
| 153 |
< |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 154 |
< |
":%s SVSMODE %s %lu %s %s", ID(source_p), |
| 168 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg); |
| 169 |
< |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 170 |
< |
":%s SVSMODE %s %lu %s %s", source_p->name, |
| 171 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes, extarg); |
| 172 |
< |
} |
| 152 |
> |
sendto_server(source_p, 0, 0, ":%s SVSMODE %s %lu %s %s", |
| 153 |
> |
source_p->id, |
| 154 |
> |
target_p->id, (unsigned long)target_p->tsinfo, modes, extarg); |
| 155 |
|
else |
| 156 |
< |
{ |
| 157 |
< |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 158 |
< |
":%s SVSMODE %s %lu %s", ID(source_p), |
| 177 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes); |
| 178 |
< |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 179 |
< |
":%s SVSMODE %s %lu %s", source_p->name, |
| 180 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes); |
| 181 |
< |
} |
| 156 |
> |
sendto_server(source_p, 0, 0, ":%s SVSMODE %s %lu %s", |
| 157 |
> |
source_p->id, |
| 158 |
> |
target_p->id, (unsigned long)target_p->tsinfo, modes); |
| 159 |
|
|
| 160 |
|
if (MyConnect(target_p) && (setmodes != target_p->umodes)) |
| 161 |
|
{ |
| 162 |
< |
char modebuf[IRCD_BUFSIZE]; |
| 162 |
> |
char modebuf[IRCD_BUFSIZE] = ""; |
| 163 |
|
|
| 164 |
< |
send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf); |
| 164 |
> |
send_umode(target_p, target_p, setmodes, modebuf); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
return 0; |
| 169 |
|
|
| 170 |
|
static struct Message svsmode_msgtab = |
| 171 |
|
{ |
| 172 |
< |
"SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
| 172 |
> |
"SVSMODE", NULL, 0, 0, 4, MAXPARA, MFLG_SLOW, 0, |
| 173 |
|
{ m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore } |
| 174 |
|
}; |
| 175 |
|
|