| 1 |
|
/* |
| 2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (C) 1999 by the Bahamut Development Team. |
| 5 |
< |
* Copyright (C) 2011 by the Hybrid Development Team. |
| 4 |
> |
* Copyright (c) 1999 Bahamut development team. |
| 5 |
> |
* Copyright (c) 2011-2014 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 |
| 28 |
|
#include "stdinc.h" |
| 29 |
|
#include "client.h" |
| 30 |
|
#include "ircd.h" |
| 31 |
< |
#include "numeric.h" |
| 32 |
< |
#include "s_serv.h" |
| 31 |
> |
#include "server.h" |
| 32 |
|
#include "send.h" |
| 33 |
|
#include "channel_mode.h" |
| 34 |
|
#include "parse.h" |
| 35 |
|
#include "modules.h" |
| 36 |
|
#include "irc_string.h" |
| 37 |
< |
#include "s_user.h" |
| 37 |
> |
#include "user.h" |
| 38 |
|
#include "conf.h" |
| 40 |
– |
#include "hook.h" |
| 39 |
|
|
| 40 |
|
|
| 41 |
< |
/*! \brief SVSMODE command handler (called by services) |
| 41 |
> |
/*! \brief SVSMODE command handler |
| 42 |
|
* |
| 45 |
– |
* \param client_p Pointer to allocated Client struct with physical connection |
| 46 |
– |
* to this server, i.e. with an open socket connected. |
| 43 |
|
* \param source_p Pointer to allocated Client struct from which the message |
| 44 |
|
* originally comes from. This can be a local or remote client. |
| 45 |
|
* \param parc Integer holding the number of supplied arguments. |
| 46 |
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 47 |
|
* pointers. |
| 48 |
|
* \note Valid arguments for this command are: |
| 49 |
< |
* - parv[0] = sender prefix |
| 49 |
> |
* - parv[0] = command |
| 50 |
|
* - parv[1] = nickname |
| 51 |
|
* - parv[2] = TS (or mode, depending on svs version) |
| 52 |
|
* - parv[3] = mode (or services id if old svs version) |
| 53 |
|
* - parv[4] = optional argument (services id) |
| 54 |
|
*/ |
| 55 |
< |
static void |
| 56 |
< |
ms_svsmode(struct Client *client_p, struct Client *source_p, |
| 61 |
< |
int parc, char *parv[]) |
| 55 |
> |
static int |
| 56 |
> |
ms_svsmode(struct Client *source_p, int parc, char *parv[]) |
| 57 |
|
{ |
| 58 |
|
struct Client *target_p = NULL; |
| 59 |
|
int what = MODE_ADD; |
| 60 |
< |
unsigned int flag = 0, setflags = 0; |
| 61 |
< |
char *m = NULL, *modes = NULL, *extarg = NULL; |
| 60 |
> |
unsigned int flag = 0, setmodes = 0; |
| 61 |
> |
const char *modes = NULL, *extarg = NULL; |
| 62 |
|
time_t ts = 0; |
| 63 |
|
|
| 64 |
|
if (!HasFlag(source_p, FLAGS_SERVICE)) |
| 65 |
< |
return; |
| 65 |
> |
return 0; |
| 66 |
|
|
| 67 |
|
if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-'))) |
| 68 |
|
{ |
| 76 |
|
extarg = (parc > 3) ? parv[3] : NULL; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
< |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
| 80 |
< |
return; |
| 79 |
> |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
| 80 |
> |
return 0; |
| 81 |
|
|
| 82 |
|
if (ts && (ts != target_p->tsinfo)) |
| 83 |
< |
return; |
| 83 |
> |
return 0; |
| 84 |
|
|
| 85 |
< |
setflags = target_p->umodes; |
| 85 |
> |
setmodes = target_p->umodes; |
| 86 |
|
|
| 87 |
< |
for (m = modes; *m; ++m) |
| 87 |
> |
for (const char *m = modes; *m; ++m) |
| 88 |
|
{ |
| 89 |
|
switch (*m) |
| 90 |
|
{ |
| 100 |
|
strlcpy(target_p->svid, extarg, sizeof(target_p->svid)); |
| 101 |
|
break; |
| 102 |
|
|
| 103 |
+ |
case 'x': |
| 104 |
+ |
if (!EmptyString(extarg) && valid_hostname(extarg)) |
| 105 |
+ |
user_set_hostmask(target_p, extarg, what); |
| 106 |
+ |
break; |
| 107 |
+ |
|
| 108 |
|
case 'o': |
| 109 |
|
if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER)) |
| 110 |
|
{ |
| 111 |
|
ClearOper(target_p); |
| 112 |
< |
Count.oper--; |
| 112 |
> |
--Count.oper; |
| 113 |
|
|
| 114 |
|
if (MyConnect(target_p)) |
| 115 |
|
{ |
| 116 |
|
dlink_node *dm = NULL; |
| 117 |
|
|
| 118 |
< |
detach_conf(target_p, OPER_TYPE); |
| 118 |
> |
detach_conf(target_p, CONF_OPER); |
| 119 |
|
ClrOFlag(target_p); |
| 120 |
|
DelUMode(target_p, ConfigFileEntry.oper_only_umodes); |
| 121 |
< |
|
| 122 |
< |
if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL) |
| 123 |
< |
free_dlink_node(dm); |
| 121 |
> |
|
| 122 |
> |
if ((dm = dlinkFindDelete(&oper_list, target_p))) |
| 123 |
> |
free_dlink_node(dm); |
| 124 |
|
} |
| 125 |
|
} |
| 126 |
|
|
| 141 |
|
|
| 142 |
|
break; |
| 143 |
|
|
| 144 |
< |
case ' ': |
| 145 |
< |
case '\n': |
| 146 |
< |
case '\r': |
| 147 |
< |
case '\t': |
| 144 |
> |
case 'S': /* Only servers may set +S in a burst */ |
| 145 |
> |
case 'W': /* Only servers may set +W in a burst */ |
| 146 |
|
break; |
| 147 |
+ |
|
| 148 |
|
default: |
| 149 |
|
if ((flag = user_modes[(unsigned char)*m])) |
| 150 |
< |
execute_callback(umode_cb, client_p, target_p, what, flag); |
| 150 |
> |
{ |
| 151 |
> |
if (what == MODE_ADD) |
| 152 |
> |
AddUMode(target_p, flag); |
| 153 |
> |
else |
| 154 |
> |
DelUMode(target_p, flag); |
| 155 |
> |
} |
| 156 |
> |
|
| 157 |
|
break; |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
if (extarg) |
| 162 |
< |
{ |
| 163 |
< |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 164 |
< |
":%s SVSMODE %s %lu %s %s", ID(source_p), |
| 160 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg); |
| 161 |
< |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 162 |
< |
":%s SVSMODE %s %lu %s %s", source_p->name, |
| 163 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes, extarg); |
| 164 |
< |
} |
| 162 |
> |
sendto_server(source_p, NOCAPS, NOCAPS, ":%s SVSMODE %s %lu %s %s", |
| 163 |
> |
source_p->id, |
| 164 |
> |
target_p->id, (unsigned long)target_p->tsinfo, modes, extarg); |
| 165 |
|
else |
| 166 |
< |
{ |
| 167 |
< |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 168 |
< |
":%s SVSMODE %s %lu %s", ID(source_p), |
| 169 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes); |
| 170 |
< |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 171 |
< |
":%s SVSMODE %s %lu %s", source_p->name, |
| 172 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes); |
| 173 |
< |
} |
| 166 |
> |
sendto_server(source_p, NOCAPS, NOCAPS, ":%s SVSMODE %s %lu %s", |
| 167 |
> |
source_p->id, |
| 168 |
> |
target_p->id, (unsigned long)target_p->tsinfo, modes); |
| 169 |
|
|
| 170 |
< |
if (MyConnect(target_p) && (setflags != target_p->umodes)) |
| 170 |
> |
if (MyConnect(target_p) && (setmodes != target_p->umodes)) |
| 171 |
|
{ |
| 172 |
< |
char modebuf[IRCD_BUFSIZE]; |
| 172 |
> |
char modebuf[IRCD_BUFSIZE] = ""; |
| 173 |
|
|
| 174 |
< |
send_umode(target_p, target_p, setflags, 0xffffffff, modebuf); |
| 174 |
> |
send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf); |
| 175 |
|
} |
| 176 |
+ |
|
| 177 |
+ |
return 0; |
| 178 |
|
} |
| 179 |
|
|
| 180 |
< |
static struct Message svsmode_msgtab = { |
| 180 |
> |
static struct Message svsmode_msgtab = |
| 181 |
> |
{ |
| 182 |
|
"SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
| 183 |
< |
{m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore} |
| 183 |
> |
{ m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore } |
| 184 |
|
}; |
| 185 |
|
|
| 186 |
|
static void |
| 195 |
|
mod_del_cmd(&svsmode_msgtab); |
| 196 |
|
} |
| 197 |
|
|
| 198 |
< |
struct module module_entry = { |
| 198 |
> |
struct module module_entry = |
| 199 |
> |
{ |
| 200 |
|
.node = { NULL, NULL, NULL }, |
| 201 |
|
.name = NULL, |
| 202 |
|
.version = "$Revision$", |