| 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" |
| 31 |
|
#include "s_serv.h" |
| 32 |
|
#include "send.h" |
| 33 |
|
#include "channel_mode.h" |
| 36 |
|
#include "irc_string.h" |
| 37 |
|
#include "s_user.h" |
| 38 |
|
#include "conf.h" |
| 40 |
– |
#include "hook.h" |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
/*! \brief SVSMODE command handler (called by services) |
| 48 |
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 49 |
|
* pointers. |
| 50 |
|
* \note Valid arguments for this command are: |
| 51 |
< |
* - parv[0] = sender prefix |
| 51 |
> |
* - parv[0] = command |
| 52 |
|
* - parv[1] = nickname |
| 53 |
|
* - parv[2] = TS (or mode, depending on svs version) |
| 54 |
|
* - parv[3] = mode (or services id if old svs version) |
| 55 |
|
* - parv[4] = optional argument (services id) |
| 56 |
|
*/ |
| 57 |
< |
static void |
| 57 |
> |
static int |
| 58 |
|
ms_svsmode(struct Client *client_p, struct Client *source_p, |
| 59 |
|
int parc, char *parv[]) |
| 60 |
|
{ |
| 61 |
|
struct Client *target_p = NULL; |
| 62 |
|
int what = MODE_ADD; |
| 63 |
< |
unsigned int flag = 0, setflags = 0; |
| 64 |
< |
char *m = NULL, *modes = NULL, *extarg = NULL; |
| 63 |
> |
unsigned int flag = 0, setmodes = 0; |
| 64 |
> |
const char *m = NULL, *modes = NULL, *extarg = NULL; |
| 65 |
|
time_t ts = 0; |
| 66 |
|
|
| 67 |
|
if (!HasFlag(source_p, FLAGS_SERVICE)) |
| 68 |
< |
return; |
| 68 |
> |
return 0; |
| 69 |
|
|
| 70 |
|
if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-'))) |
| 71 |
|
{ |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
if ((target_p = find_person(client_p, parv[1])) == NULL) |
| 83 |
< |
return; |
| 83 |
> |
return 0; |
| 84 |
|
|
| 85 |
|
if (ts && (ts != target_p->tsinfo)) |
| 86 |
< |
return; |
| 86 |
> |
return 0; |
| 87 |
|
|
| 88 |
< |
setflags = target_p->umodes; |
| 88 |
> |
setmodes = target_p->umodes; |
| 89 |
|
|
| 90 |
|
for (m = modes; *m; ++m) |
| 91 |
|
{ |
| 103 |
|
strlcpy(target_p->svid, extarg, sizeof(target_p->svid)); |
| 104 |
|
break; |
| 105 |
|
|
| 106 |
+ |
case 'x': |
| 107 |
+ |
if (!EmptyString(extarg) && valid_hostname(extarg)) |
| 108 |
+ |
user_set_hostmask(target_p, extarg, what); |
| 109 |
+ |
break; |
| 110 |
+ |
|
| 111 |
|
case 'o': |
| 112 |
|
if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER)) |
| 113 |
|
{ |
| 121 |
|
detach_conf(target_p, CONF_OPER); |
| 122 |
|
ClrOFlag(target_p); |
| 123 |
|
DelUMode(target_p, ConfigFileEntry.oper_only_umodes); |
| 124 |
< |
|
| 125 |
< |
if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL) |
| 126 |
< |
free_dlink_node(dm); |
| 124 |
> |
|
| 125 |
> |
if ((dm = dlinkFindDelete(&oper_list, target_p))) |
| 126 |
> |
free_dlink_node(dm); |
| 127 |
|
} |
| 128 |
|
} |
| 129 |
|
|
| 144 |
|
|
| 145 |
|
break; |
| 146 |
|
|
| 147 |
+ |
case 'S': /* Only servers may set +S in a burst */ |
| 148 |
+ |
case 'W': /* Only servers may set +W in a burst */ |
| 149 |
+ |
break; |
| 150 |
+ |
|
| 151 |
|
default: |
| 152 |
|
if ((flag = user_modes[(unsigned char)*m])) |
| 153 |
|
{ |
| 180 |
|
target_p->name, (unsigned long)target_p->tsinfo, modes); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
< |
if (MyConnect(target_p) && (setflags != target_p->umodes)) |
| 183 |
> |
if (MyConnect(target_p) && (setmodes != target_p->umodes)) |
| 184 |
|
{ |
| 185 |
|
char modebuf[IRCD_BUFSIZE]; |
| 186 |
|
|
| 187 |
< |
send_umode(target_p, target_p, setflags, 0xffffffff, modebuf); |
| 187 |
> |
send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf); |
| 188 |
|
} |
| 189 |
+ |
|
| 190 |
+ |
return 0; |
| 191 |
|
} |
| 192 |
|
|
| 193 |
< |
static struct Message svsmode_msgtab = { |
| 193 |
> |
static struct Message svsmode_msgtab = |
| 194 |
> |
{ |
| 195 |
|
"SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
| 196 |
< |
{m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore} |
| 196 |
> |
{ m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore } |
| 197 |
|
}; |
| 198 |
|
|
| 199 |
|
static void |
| 208 |
|
mod_del_cmd(&svsmode_msgtab); |
| 209 |
|
} |
| 210 |
|
|
| 211 |
< |
struct module module_entry = { |
| 211 |
> |
struct module module_entry = |
| 212 |
> |
{ |
| 213 |
|
.node = { NULL, NULL, NULL }, |
| 214 |
|
.name = NULL, |
| 215 |
|
.version = "$Revision$", |