| 1 |
|
/* |
| 2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 4 |
> |
* Copyright (c) 1997-2017 ircd-hybrid development team |
| 5 |
|
* |
| 6 |
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
* it under the terms of the GNU General Public License as published by |
| 63 |
|
{ MODE_REGISTERED, 'r' }, |
| 64 |
|
{ MODE_SECRET, 's' }, |
| 65 |
|
{ MODE_TOPICLIMIT, 't' }, |
| 66 |
+ |
{ MODE_NOCTCP, 'C' }, |
| 67 |
|
{ MODE_MODREG, 'M' }, |
| 68 |
|
{ MODE_OPERONLY, 'O' }, |
| 69 |
|
{ MODE_REGONLY, 'R' }, |
| 70 |
|
{ MODE_SSLONLY, 'S' }, |
| 71 |
+ |
{ MODE_NONOTICE, 'T' }, |
| 72 |
|
{ 0, '\0' } |
| 73 |
|
}; |
| 74 |
|
|
| 85 |
|
static char * |
| 86 |
|
check_string(char *s) |
| 87 |
|
{ |
| 88 |
< |
char *str = s; |
| 88 |
> |
char *const str = s; |
| 89 |
|
static char star[] = "*"; |
| 90 |
|
|
| 91 |
|
if (EmptyString(str)) |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
/* |
| 107 |
< |
* Ban functions to work with mode +b/e/d/I |
| 107 |
> |
* Ban functions to work with mode +b/e/I |
| 108 |
|
*/ |
| 109 |
|
/* add the specified ID to the channel. |
| 110 |
|
* -is 8/9/00 |
| 113 |
|
int |
| 114 |
|
add_id(struct Client *client_p, struct Channel *chptr, char *banid, unsigned int type) |
| 115 |
|
{ |
| 116 |
< |
dlink_list *list = NULL; |
| 117 |
< |
dlink_node *node = NULL; |
| 116 |
< |
struct Ban *banptr = NULL; |
| 117 |
< |
size_t len = 0; |
| 116 |
> |
dlink_list *list; |
| 117 |
> |
dlink_node *node; |
| 118 |
|
char name[NICKLEN + 1] = ""; |
| 119 |
|
char user[USERLEN + 1] = ""; |
| 120 |
|
char host[HOSTLEN + 1] = ""; |
| 151 |
|
* Re-assemble a new n!u@h and print it back to banid for sending |
| 152 |
|
* the mode to the channel. |
| 153 |
|
*/ |
| 154 |
< |
len = sprintf(banid, "%s!%s@%s", name, user, host); |
| 154 |
> |
size_t len = snprintf(banid, IRCD_BUFSIZE, "%s!%s@%s", name, user, host); |
| 155 |
|
|
| 156 |
|
switch (type) |
| 157 |
|
{ |
| 158 |
|
case CHFL_BAN: |
| 159 |
|
list = &chptr->banlist; |
| 160 |
< |
clear_ban_cache(chptr); |
| 160 |
> |
clear_ban_cache_list(&chptr->locmembers); |
| 161 |
|
break; |
| 162 |
|
case CHFL_EXCEPTION: |
| 163 |
|
list = &chptr->exceptlist; |
| 164 |
< |
clear_ban_cache(chptr); |
| 164 |
> |
clear_ban_cache_list(&chptr->locmembers); |
| 165 |
|
break; |
| 166 |
|
case CHFL_INVEX: |
| 167 |
|
list = &chptr->invexlist; |
| 168 |
|
break; |
| 169 |
|
default: |
| 170 |
< |
assert(0); |
| 171 |
< |
return 0; |
| 170 |
> |
list = NULL; /* Let it crash */ |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
DLINK_FOREACH(node, list->head) |
| 174 |
|
{ |
| 175 |
< |
banptr = node->data; |
| 175 |
> |
const struct Ban *ban = node->data; |
| 176 |
|
|
| 177 |
< |
if (!irccmp(banptr->name, name) && |
| 178 |
< |
!irccmp(banptr->user, user) && |
| 179 |
< |
!irccmp(banptr->host, host)) |
| 177 |
> |
if (!irccmp(ban->name, name) && |
| 178 |
> |
!irccmp(ban->user, user) && |
| 179 |
> |
!irccmp(ban->host, host)) |
| 180 |
|
return 0; |
| 181 |
|
} |
| 182 |
|
|
| 183 |
< |
banptr = mp_pool_get(ban_pool); |
| 184 |
< |
banptr->name = xstrdup(name); |
| 185 |
< |
banptr->user = xstrdup(user); |
| 186 |
< |
banptr->host = xstrdup(host); |
| 187 |
< |
banptr->when = CurrentTime; |
| 188 |
< |
banptr->len = len - 2; /* -2 for ! + @ */ |
| 189 |
< |
banptr->type = parse_netmask(host, &banptr->addr, &banptr->bits); |
| 183 |
> |
struct Ban *ban = mp_pool_get(ban_pool); |
| 184 |
> |
ban->when = CurrentTime; |
| 185 |
> |
ban->len = len - 2; /* -2 for ! + @ */ |
| 186 |
> |
ban->type = parse_netmask(host, &ban->addr, &ban->bits); |
| 187 |
> |
strlcpy(ban->name, name, sizeof(ban->name)); |
| 188 |
> |
strlcpy(ban->user, user, sizeof(ban->user)); |
| 189 |
> |
strlcpy(ban->host, host, sizeof(ban->host)); |
| 190 |
|
|
| 191 |
|
if (IsClient(client_p)) |
| 192 |
< |
{ |
| 193 |
< |
banptr->who = MyCalloc(strlen(client_p->name) + |
| 194 |
< |
strlen(client_p->username) + |
| 195 |
< |
strlen(client_p->host) + 3); |
| 197 |
< |
sprintf(banptr->who, "%s!%s@%s", client_p->name, |
| 198 |
< |
client_p->username, client_p->host); |
| 199 |
< |
} |
| 200 |
< |
else if (IsHidden(client_p) || (IsServer(client_p) && ConfigServerHide.hide_servers)) |
| 201 |
< |
banptr->who = xstrdup(me.name); |
| 192 |
> |
snprintf(ban->who, sizeof(ban->who), "%s!%s@%s", client_p->name, |
| 193 |
> |
client_p->username, client_p->host); |
| 194 |
> |
else if (IsHidden(client_p) || ConfigServerHide.hide_servers) |
| 195 |
> |
strlcpy(ban->who, me.name, sizeof(ban->who)); |
| 196 |
|
else |
| 197 |
< |
banptr->who = xstrdup(client_p->name); |
| 197 |
> |
strlcpy(ban->who, client_p->name, sizeof(ban->who)); |
| 198 |
|
|
| 199 |
< |
dlinkAdd(banptr, &banptr->node, list); |
| 199 |
> |
dlinkAdd(ban, &ban->node, list); |
| 200 |
|
|
| 201 |
|
return 1; |
| 202 |
|
} |
| 211 |
|
static int |
| 212 |
|
del_id(struct Channel *chptr, char *banid, unsigned int type) |
| 213 |
|
{ |
| 214 |
< |
dlink_list *list = NULL; |
| 215 |
< |
dlink_node *node = NULL; |
| 214 |
> |
dlink_list *list; |
| 215 |
> |
dlink_node *node; |
| 216 |
|
char name[NICKLEN + 1] = ""; |
| 217 |
|
char user[USERLEN + 1] = ""; |
| 218 |
|
char host[HOSTLEN + 1] = ""; |
| 235 |
|
* Re-assemble a new n!u@h and print it back to banid for sending |
| 236 |
|
* the mode to the channel. |
| 237 |
|
*/ |
| 238 |
< |
sprintf(banid, "%s!%s@%s", name, user, host); |
| 238 |
> |
snprintf(banid, IRCD_BUFSIZE, "%s!%s@%s", name, user, host); |
| 239 |
|
|
| 240 |
|
switch (type) |
| 241 |
|
{ |
| 242 |
|
case CHFL_BAN: |
| 243 |
|
list = &chptr->banlist; |
| 244 |
< |
clear_ban_cache(chptr); |
| 244 |
> |
clear_ban_cache_list(&chptr->locmembers); |
| 245 |
|
break; |
| 246 |
|
case CHFL_EXCEPTION: |
| 247 |
|
list = &chptr->exceptlist; |
| 248 |
< |
clear_ban_cache(chptr); |
| 248 |
> |
clear_ban_cache_list(&chptr->locmembers); |
| 249 |
|
break; |
| 250 |
|
case CHFL_INVEX: |
| 251 |
|
list = &chptr->invexlist; |
| 252 |
|
break; |
| 253 |
|
default: |
| 254 |
< |
assert(0); |
| 261 |
< |
return 0; |
| 254 |
> |
list = NULL; /* Let it crash */ |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
DLINK_FOREACH(node, list->head) |
| 258 |
|
{ |
| 259 |
< |
struct Ban *banptr = node->data; |
| 259 |
> |
struct Ban *ban = node->data; |
| 260 |
|
|
| 261 |
< |
if (!irccmp(name, banptr->name) && |
| 262 |
< |
!irccmp(user, banptr->user) && |
| 263 |
< |
!irccmp(host, banptr->host)) |
| 261 |
> |
if (!irccmp(name, ban->name) && |
| 262 |
> |
!irccmp(user, ban->user) && |
| 263 |
> |
!irccmp(host, ban->host)) |
| 264 |
|
{ |
| 265 |
< |
remove_ban(banptr, list); |
| 265 |
> |
remove_ban(ban, list); |
| 266 |
|
return 1; |
| 267 |
|
} |
| 268 |
|
} |
| 294 |
|
{ |
| 295 |
|
*mbuf++ = 'l'; |
| 296 |
|
|
| 297 |
< |
if (IsServer(client_p) || HasFlag(client_p, FLAGS_SERVICE) || IsMember(client_p, chptr)) |
| 298 |
< |
pbuf += sprintf(pbuf, "%d ", chptr->mode.limit); |
| 297 |
> |
if (IsServer(client_p) || IsMember(client_p, chptr)) |
| 298 |
> |
pbuf += sprintf(pbuf, "%u ", chptr->mode.limit); |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
if (chptr->mode.key[0]) |
| 302 |
|
{ |
| 303 |
|
*mbuf++ = 'k'; |
| 304 |
|
|
| 305 |
< |
if (IsServer(client_p) || HasFlag(client_p, FLAGS_SERVICE) || IsMember(client_p, chptr)) |
| 305 |
> |
if (IsServer(client_p) || IsMember(client_p, chptr)) |
| 306 |
|
sprintf(pbuf, "%s ", chptr->mode.key); |
| 307 |
|
} |
| 308 |
|
|
| 340 |
|
* side effects - clear ban cache |
| 341 |
|
*/ |
| 342 |
|
void |
| 343 |
< |
clear_ban_cache(struct Channel *chptr) |
| 343 |
> |
clear_ban_cache_list(dlink_list *list) |
| 344 |
|
{ |
| 345 |
< |
dlink_node *node = NULL; |
| 345 |
> |
dlink_node *node; |
| 346 |
|
|
| 347 |
< |
DLINK_FOREACH(node, chptr->locmembers.head) |
| 355 |
< |
{ |
| 356 |
< |
struct Membership *ms = node->data; |
| 357 |
< |
ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED); |
| 358 |
< |
} |
| 359 |
< |
} |
| 360 |
< |
|
| 361 |
< |
void |
| 362 |
< |
clear_ban_cache_client(struct Client *client_p) |
| 363 |
< |
{ |
| 364 |
< |
dlink_node *node = NULL; |
| 365 |
< |
|
| 366 |
< |
DLINK_FOREACH(node, client_p->channel.head) |
| 347 |
> |
DLINK_FOREACH(node, list->head) |
| 348 |
|
{ |
| 349 |
< |
struct Membership *ms = node->data; |
| 350 |
< |
ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED); |
| 349 |
> |
struct Membership *member = node->data; |
| 350 |
> |
member->flags &= ~(CHFL_BAN_SILENCED | CHFL_BAN_CHECKED); |
| 351 |
|
} |
| 352 |
|
} |
| 353 |
|
|
| 389 |
|
sendto_one_numeric(source_p, &me, |
| 390 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 391 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 392 |
+ |
|
| 393 |
|
*errors |= SM_ERR_NOOPS; |
| 394 |
|
return; |
| 395 |
|
} |
| 440 |
|
sendto_one_numeric(source_p, &me, |
| 441 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 442 |
|
ERR_ONLYSERVERSCANCHANGE, chptr->name); |
| 443 |
+ |
|
| 444 |
|
*errors |= SM_ERR_ONLYSERVER; |
| 445 |
|
return; |
| 446 |
|
} |
| 485 |
|
chm_operonly(struct Client *source_p, struct Channel *chptr, int parc, int *parn, |
| 486 |
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
| 487 |
|
{ |
| 488 |
< |
if (alev < CHACCESS_CHANOP) |
| 488 |
> |
if (alev < CHACCESS_HALFOP) |
| 489 |
|
{ |
| 490 |
|
if (!(*errors & SM_ERR_NOOPS)) |
| 491 |
|
sendto_one_numeric(source_p, &me, |
| 537 |
|
chm_ban(struct Client *source_p, struct Channel *chptr, int parc, int *parn, |
| 538 |
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
| 539 |
|
{ |
| 557 |
– |
char *mask = NULL; |
| 558 |
– |
|
| 540 |
|
if (dir == MODE_QUERY || parc <= *parn) |
| 541 |
|
{ |
| 542 |
< |
dlink_node *node = NULL; |
| 542 |
> |
dlink_node *node; |
| 543 |
|
|
| 544 |
|
if (*errors & SM_ERR_RPL_B) |
| 545 |
|
return; |
| 548 |
|
|
| 549 |
|
DLINK_FOREACH(node, chptr->banlist.head) |
| 550 |
|
{ |
| 551 |
< |
const struct Ban *banptr = node->data; |
| 551 |
> |
const struct Ban *ban = node->data; |
| 552 |
|
sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->name, |
| 553 |
< |
banptr->name, banptr->user, banptr->host, |
| 554 |
< |
banptr->who, banptr->when); |
| 553 |
> |
ban->name, ban->user, ban->host, |
| 554 |
> |
ban->who, ban->when); |
| 555 |
|
} |
| 556 |
|
|
| 557 |
|
sendto_one_numeric(source_p, &me, RPL_ENDOFBANLIST, chptr->name); |
| 564 |
|
sendto_one_numeric(source_p, &me, |
| 565 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 566 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 567 |
+ |
|
| 568 |
|
*errors |= SM_ERR_NOOPS; |
| 569 |
|
return; |
| 570 |
|
} |
| 572 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
| 573 |
|
return; |
| 574 |
|
|
| 575 |
< |
mask = nuh_mask[*parn]; |
| 576 |
< |
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
| 575 |
> |
char *mask = nuh_mask[*parn]; |
| 576 |
> |
strlcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
| 577 |
|
++(*parn); |
| 578 |
|
|
| 579 |
< |
if (!MyConnect(source_p)) |
| 580 |
< |
if (strchr(mask, ' ')) |
| 599 |
< |
return; |
| 579 |
> |
if (*mask == ':' || (!MyConnect(source_p) && strchr(mask, ' '))) |
| 580 |
> |
return; |
| 581 |
|
|
| 582 |
|
switch (dir) |
| 583 |
|
{ |
| 603 |
|
chm_except(struct Client *source_p, struct Channel *chptr, int parc, int *parn, |
| 604 |
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
| 605 |
|
{ |
| 625 |
– |
char *mask = NULL; |
| 626 |
– |
|
| 606 |
|
if (dir == MODE_QUERY || parc <= *parn) |
| 607 |
|
{ |
| 608 |
< |
dlink_node *node = NULL; |
| 608 |
> |
dlink_node *node; |
| 609 |
|
|
| 610 |
|
if (*errors & SM_ERR_RPL_E) |
| 611 |
|
return; |
| 614 |
|
|
| 615 |
|
DLINK_FOREACH(node, chptr->exceptlist.head) |
| 616 |
|
{ |
| 617 |
< |
const struct Ban *banptr = node->data; |
| 639 |
< |
|
| 617 |
> |
const struct Ban *ban = node->data; |
| 618 |
|
sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->name, |
| 619 |
< |
banptr->name, banptr->user, banptr->host, |
| 620 |
< |
banptr->who, banptr->when); |
| 619 |
> |
ban->name, ban->user, ban->host, |
| 620 |
> |
ban->who, ban->when); |
| 621 |
|
} |
| 622 |
|
|
| 623 |
|
sendto_one_numeric(source_p, &me, RPL_ENDOFEXCEPTLIST, chptr->name); |
| 630 |
|
sendto_one_numeric(source_p, &me, |
| 631 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 632 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 633 |
+ |
|
| 634 |
|
*errors |= SM_ERR_NOOPS; |
| 635 |
|
return; |
| 636 |
|
} |
| 638 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
| 639 |
|
return; |
| 640 |
|
|
| 641 |
< |
mask = nuh_mask[*parn]; |
| 642 |
< |
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
| 641 |
> |
char *mask = nuh_mask[*parn]; |
| 642 |
> |
strlcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
| 643 |
|
++(*parn); |
| 644 |
|
|
| 645 |
< |
if (!MyConnect(source_p)) |
| 646 |
< |
if (strchr(mask, ' ')) |
| 668 |
< |
return; |
| 645 |
> |
if (*mask == ':' || (!MyConnect(source_p) && strchr(mask, ' '))) |
| 646 |
> |
return; |
| 647 |
|
|
| 648 |
|
switch (dir) |
| 649 |
|
{ |
| 669 |
|
chm_invex(struct Client *source_p, struct Channel *chptr, int parc, int *parn, |
| 670 |
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
| 671 |
|
{ |
| 694 |
– |
char *mask = NULL; |
| 695 |
– |
|
| 672 |
|
if (dir == MODE_QUERY || parc <= *parn) |
| 673 |
|
{ |
| 674 |
< |
dlink_node *node = NULL; |
| 674 |
> |
dlink_node *node; |
| 675 |
|
|
| 676 |
|
if (*errors & SM_ERR_RPL_I) |
| 677 |
|
return; |
| 680 |
|
|
| 681 |
|
DLINK_FOREACH(node, chptr->invexlist.head) |
| 682 |
|
{ |
| 683 |
< |
const struct Ban *banptr = node->data; |
| 708 |
< |
|
| 683 |
> |
const struct Ban *ban = node->data; |
| 684 |
|
sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->name, |
| 685 |
< |
banptr->name, banptr->user, banptr->host, |
| 686 |
< |
banptr->who, banptr->when); |
| 685 |
> |
ban->name, ban->user, ban->host, |
| 686 |
> |
ban->who, ban->when); |
| 687 |
|
} |
| 688 |
|
|
| 689 |
|
sendto_one_numeric(source_p, &me, RPL_ENDOFINVEXLIST, chptr->name); |
| 696 |
|
sendto_one_numeric(source_p, &me, |
| 697 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 698 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 699 |
+ |
|
| 700 |
|
*errors |= SM_ERR_NOOPS; |
| 701 |
|
return; |
| 702 |
|
} |
| 704 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
| 705 |
|
return; |
| 706 |
|
|
| 707 |
< |
mask = nuh_mask[*parn]; |
| 708 |
< |
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
| 707 |
> |
char *mask = nuh_mask[*parn]; |
| 708 |
> |
strlcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
| 709 |
|
++(*parn); |
| 710 |
|
|
| 711 |
< |
if (!MyConnect(source_p)) |
| 712 |
< |
if (strchr(mask, ' ')) |
| 737 |
< |
return; |
| 711 |
> |
if (*mask == ':' || (!MyConnect(source_p) && strchr(mask, ' '))) |
| 712 |
> |
return; |
| 713 |
|
|
| 714 |
|
switch (dir) |
| 715 |
|
{ |
| 744 |
|
sendto_one_numeric(source_p, &me, |
| 745 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 746 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 747 |
+ |
|
| 748 |
|
*errors |= SM_ERR_NOOPS; |
| 749 |
|
return; |
| 750 |
|
} |
| 759 |
|
{ |
| 760 |
|
if (!(*errors & SM_ERR_NOTONCHANNEL)) |
| 761 |
|
sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name); |
| 762 |
+ |
|
| 763 |
|
*errors |= SM_ERR_NOTONCHANNEL; |
| 764 |
|
return; |
| 765 |
|
} |
| 767 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
| 768 |
|
return; |
| 769 |
|
|
| 770 |
< |
/* no redundant mode changes */ |
| 771 |
< |
if (dir == MODE_ADD && has_member_flags(member, CHFL_VOICE)) |
| 772 |
< |
return; |
| 773 |
< |
if (dir == MODE_DEL && !has_member_flags(member, CHFL_VOICE)) |
| 774 |
< |
return; |
| 770 |
> |
switch (dir) |
| 771 |
> |
{ |
| 772 |
> |
case MODE_ADD: |
| 773 |
> |
if (has_member_flags(member, CHFL_VOICE)) |
| 774 |
> |
return; /* No redundant mode changes */ |
| 775 |
> |
|
| 776 |
> |
AddMemberFlag(member, CHFL_VOICE); |
| 777 |
> |
break; |
| 778 |
> |
case MODE_DEL: |
| 779 |
> |
if (!has_member_flags(member, CHFL_VOICE)) |
| 780 |
> |
return; /* No redundant mode changes */ |
| 781 |
> |
|
| 782 |
> |
DelMemberFlag(member, CHFL_VOICE); |
| 783 |
> |
break; |
| 784 |
> |
} |
| 785 |
|
|
| 786 |
|
mode_changes[mode_count].letter = c; |
| 787 |
|
mode_changes[mode_count].arg = target_p->name; |
| 788 |
|
mode_changes[mode_count].id = target_p->id; |
| 789 |
|
mode_changes[mode_count++].dir = dir; |
| 803 |
– |
|
| 804 |
– |
if (dir == MODE_ADD) |
| 805 |
– |
AddMemberFlag(member, CHFL_VOICE); |
| 806 |
– |
else |
| 807 |
– |
DelMemberFlag(member, CHFL_VOICE); |
| 790 |
|
} |
| 791 |
|
|
| 792 |
|
static void |
| 802 |
|
sendto_one_numeric(source_p, &me, |
| 803 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 804 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 805 |
+ |
|
| 806 |
|
*errors |= SM_ERR_NOOPS; |
| 807 |
|
return; |
| 808 |
|
} |
| 817 |
|
{ |
| 818 |
|
if (!(*errors & SM_ERR_NOTONCHANNEL)) |
| 819 |
|
sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name); |
| 820 |
+ |
|
| 821 |
|
*errors |= SM_ERR_NOTONCHANNEL; |
| 822 |
|
return; |
| 823 |
|
} |
| 825 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
| 826 |
|
return; |
| 827 |
|
|
| 828 |
< |
/* no redundant mode changes */ |
| 829 |
< |
if (dir == MODE_ADD && has_member_flags(member, CHFL_HALFOP)) |
| 830 |
< |
return; |
| 831 |
< |
if (dir == MODE_DEL && !has_member_flags(member, CHFL_HALFOP)) |
| 832 |
< |
return; |
| 828 |
> |
switch (dir) |
| 829 |
> |
{ |
| 830 |
> |
case MODE_ADD: |
| 831 |
> |
if (has_member_flags(member, CHFL_HALFOP)) |
| 832 |
> |
return; /* No redundant mode changes */ |
| 833 |
> |
|
| 834 |
> |
AddMemberFlag(member, CHFL_HALFOP); |
| 835 |
> |
break; |
| 836 |
> |
case MODE_DEL: |
| 837 |
> |
if (!has_member_flags(member, CHFL_HALFOP)) |
| 838 |
> |
return; /* No redundant mode changes */ |
| 839 |
> |
|
| 840 |
> |
DelMemberFlag(member, CHFL_HALFOP); |
| 841 |
> |
break; |
| 842 |
> |
} |
| 843 |
|
|
| 844 |
|
mode_changes[mode_count].letter = c; |
| 845 |
|
mode_changes[mode_count].arg = target_p->name; |
| 846 |
|
mode_changes[mode_count].id = target_p->id; |
| 847 |
|
mode_changes[mode_count++].dir = dir; |
| 854 |
– |
|
| 855 |
– |
if (dir == MODE_ADD) |
| 856 |
– |
AddMemberFlag(member, CHFL_HALFOP); |
| 857 |
– |
else |
| 858 |
– |
DelMemberFlag(member, CHFL_HALFOP); |
| 848 |
|
} |
| 849 |
|
|
| 850 |
|
static void |
| 860 |
|
sendto_one_numeric(source_p, &me, |
| 861 |
|
alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL : |
| 862 |
|
ERR_CHANOPRIVSNEEDED, chptr->name); |
| 863 |
+ |
|
| 864 |
|
*errors |= SM_ERR_NOOPS; |
| 865 |
|
return; |
| 866 |
|
} |
| 875 |
|
{ |
| 876 |
|
if (!(*errors & SM_ERR_NOTONCHANNEL)) |
| 877 |
|
sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name); |
| 878 |
+ |
|
| 879 |
|
*errors |= SM_ERR_NOTONCHANNEL; |
| 880 |
|
return; |
| 881 |
|
} |
| 883 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
| 884 |
|
return; |
| 885 |
|
|
| 886 |
< |
/* no redundant mode changes */ |
| 887 |
< |
if (dir == MODE_ADD && has_member_flags(member, CHFL_CHANOP)) |
| 888 |
< |
return; |
| 889 |
< |
if (dir == MODE_DEL && !has_member_flags(member, CHFL_CHANOP)) |
| 890 |
< |
return; |
| 886 |
> |
switch (dir) |
| 887 |
> |
{ |
| 888 |
> |
case MODE_ADD: |
| 889 |
> |
if (has_member_flags(member, CHFL_CHANOP)) |
| 890 |
> |
return; /* No redundant mode changes */ |
| 891 |
> |
|
| 892 |
> |
AddMemberFlag(member, CHFL_CHANOP); |
| 893 |
> |
break; |
| 894 |
> |
case MODE_DEL: |
| 895 |
> |
if (!has_member_flags(member, CHFL_CHANOP)) |
| 896 |
> |
return; /* No redundant mode changes */ |
| 897 |
> |
|
| 898 |
> |
DelMemberFlag(member, CHFL_CHANOP); |
| 899 |
> |
break; |
| 900 |
> |
} |
| 901 |
|
|
| 902 |
|
mode_changes[mode_count].letter = c; |
| 903 |
|
mode_changes[mode_count].arg = target_p->name; |
| 904 |
|
mode_changes[mode_count].id = target_p->id; |
| 905 |
|
mode_changes[mode_count++].dir = dir; |
| 905 |
– |
|
| 906 |
– |
if (dir == MODE_ADD) |
| 907 |
– |
AddMemberFlag(member, CHFL_CHANOP); |
| 908 |
– |
else |
| 909 |
– |
DelMemberFlag(member, CHFL_CHANOP); |
| 906 |
|
} |
| 907 |
|
|
| 908 |
|
static void |
| 909 |
|
chm_limit(struct Client *source_p, struct Channel *chptr, int parc, int *parn, |
| 910 |
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
| 911 |
|
{ |
| 916 |
– |
int limit = 0; |
| 917 |
– |
|
| 912 |
|
if (alev < CHACCESS_HALFOP) |
| 913 |
|
{ |
| 914 |
|
if (!(*errors & SM_ERR_NOOPS)) |
| 924 |
|
|
| 925 |
|
if (dir == MODE_ADD && parc > *parn) |
| 926 |
|
{ |
| 927 |
< |
char *lstr = parv[(*parn)++]; |
| 927 |
> |
char *const lstr = parv[(*parn)++]; |
| 928 |
> |
int limit = 0; |
| 929 |
|
|
| 930 |
|
if (EmptyString(lstr) || (limit = atoi(lstr)) <= 0) |
| 931 |
|
return; |
| 977 |
|
|
| 978 |
|
if (dir == MODE_ADD && parc > *parn) |
| 979 |
|
{ |
| 980 |
< |
char *key = fix_key(parv[(*parn)++]); |
| 980 |
> |
char *const key = fix_key(parv[(*parn)++]); |
| 981 |
|
|
| 982 |
|
if (EmptyString(key)) |
| 983 |
|
return; |
| 1081 |
|
{ chm_nosuch, 0 }, /* @ */ |
| 1082 |
|
{ chm_nosuch, 0 }, /* A */ |
| 1083 |
|
{ chm_nosuch, 0 }, /* B */ |
| 1084 |
< |
{ chm_nosuch, 0 }, /* C */ |
| 1084 |
> |
{ chm_simple, MODE_NOCTCP }, /* C */ |
| 1085 |
|
{ chm_nosuch, 0 }, /* D */ |
| 1086 |
|
{ chm_nosuch, 0 }, /* E */ |
| 1087 |
|
{ chm_nosuch, 0 }, /* F */ |
| 1098 |
|
{ chm_nosuch, 0 }, /* Q */ |
| 1099 |
|
{ chm_simple, MODE_REGONLY}, /* R */ |
| 1100 |
|
{ chm_simple, MODE_SSLONLY}, /* S */ |
| 1101 |
< |
{ chm_nosuch, 0 }, /* T */ |
| 1101 |
> |
{ chm_simple, MODE_NONOTICE}, /* T */ |
| 1102 |
|
{ chm_nosuch, 0 }, /* U */ |
| 1103 |
|
{ chm_nosuch, 0 }, /* V */ |
| 1104 |
|
{ chm_nosuch, 0 }, /* W */ |
| 1322 |
|
parabuf[0] = '\0'; |
| 1323 |
|
parptr = parabuf; |
| 1324 |
|
|
| 1325 |
< |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id, |
| 1326 |
< |
(unsigned long)chptr->channelts, chptr->name); |
| 1325 |
> |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %ju %s ", source_p->id, |
| 1326 |
> |
chptr->creationtime, chptr->name); |
| 1327 |
|
|
| 1328 |
|
/* Loop the list of modes we have */ |
| 1329 |
< |
for (unsigned i = 0; i < mode_count; ++i) |
| 1329 |
> |
for (unsigned int i = 0; i < mode_count; ++i) |
| 1330 |
|
{ |
| 1331 |
|
if (mode_changes[i].letter == 0) |
| 1332 |
|
continue; |
| 1350 |
|
(pbl + arglen + BAN_FUDGE) >= MODEBUFLEN) |
| 1351 |
|
{ |
| 1352 |
|
if (nc) |
| 1353 |
< |
sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf); |
| 1353 |
> |
sendto_server(source_p, 0, 0, "%s %s", modebuf, parabuf); |
| 1354 |
|
|
| 1355 |
|
nc = 0; |
| 1356 |
|
mc = 0; |
| 1357 |
|
|
| 1358 |
< |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id, |
| 1359 |
< |
(unsigned long)chptr->channelts, chptr->name); |
| 1358 |
> |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %ju %s ", source_p->id, |
| 1359 |
> |
chptr->creationtime, chptr->name); |
| 1360 |
|
|
| 1361 |
|
pbl = 0; |
| 1362 |
|
parabuf[0] = '\0'; |
| 1376 |
|
|
| 1377 |
|
if (arg) |
| 1378 |
|
{ |
| 1379 |
< |
len = sprintf(parptr, "%s ", arg); |
| 1379 |
> |
len = sprintf(parptr, (pbl == 0) ? "%s" : " %s", arg); |
| 1380 |
|
pbl += len; |
| 1381 |
|
parptr += len; |
| 1382 |
|
++mc; |
| 1383 |
|
} |
| 1384 |
|
} |
| 1385 |
|
|
| 1391 |
– |
if (pbl && parabuf[pbl - 1] == ' ') |
| 1392 |
– |
parabuf[pbl - 1] = '\0'; |
| 1393 |
– |
|
| 1386 |
|
if (nc) |
| 1387 |
< |
sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf); |
| 1387 |
> |
sendto_server(source_p, 0, 0, "%s %s", modebuf, parabuf); |
| 1388 |
|
} |
| 1389 |
|
|
| 1390 |
|
/* void send_mode_changes(struct Client *client_p, |
| 1399 |
|
*/ |
| 1400 |
|
/* ensure parabuf < MODEBUFLEN -db */ |
| 1401 |
|
static void |
| 1402 |
< |
send_mode_changes(struct Client *source_p, struct Channel *chptr) |
| 1402 |
> |
send_mode_changes_client(struct Client *source_p, struct Channel *chptr) |
| 1403 |
|
{ |
| 1404 |
|
int mbl = 0, pbl = 0, arglen = 0, nc = 0, mc = 0; |
| 1405 |
|
int len = 0; |
| 1407 |
|
const char *arg = NULL; |
| 1408 |
|
char *parptr = NULL; |
| 1409 |
|
|
| 1418 |
– |
/* Bail out if we have nothing to do... */ |
| 1419 |
– |
if (!mode_count) |
| 1420 |
– |
return; |
| 1421 |
– |
|
| 1410 |
|
if (IsServer(source_p)) |
| 1411 |
|
mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) || |
| 1412 |
|
ConfigServerHide.hide_servers) ? |
| 1437 |
|
modebuf[mbl - 1] = '\0'; |
| 1438 |
|
|
| 1439 |
|
if (nc) |
| 1440 |
< |
sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf); |
| 1440 |
> |
sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf); |
| 1441 |
|
|
| 1442 |
|
nc = 0; |
| 1443 |
|
mc = 0; |
| 1468 |
|
|
| 1469 |
|
if (arg) |
| 1470 |
|
{ |
| 1471 |
< |
len = sprintf(parptr, "%s ", arg); |
| 1471 |
> |
len = sprintf(parptr, (pbl == 0) ? "%s" : " %s", arg); |
| 1472 |
|
pbl += len; |
| 1473 |
|
parptr += len; |
| 1474 |
|
++mc; |
| 1475 |
|
} |
| 1476 |
|
} |
| 1477 |
|
|
| 1490 |
– |
if (pbl && parabuf[pbl - 1] == ' ') |
| 1491 |
– |
parabuf[pbl - 1] = '\0'; |
| 1492 |
– |
|
| 1478 |
|
if (nc) |
| 1479 |
< |
sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf); |
| 1495 |
< |
|
| 1496 |
< |
send_mode_changes_server(source_p, chptr); |
| 1479 |
> |
sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf); |
| 1480 |
|
} |
| 1481 |
|
|
| 1482 |
|
/* |
| 1526 |
|
} |
| 1527 |
|
} |
| 1528 |
|
|
| 1529 |
< |
send_mode_changes(source_p, chptr); |
| 1529 |
> |
/* Bail out if we have nothing to do... */ |
| 1530 |
> |
if (!mode_count) |
| 1531 |
> |
return; |
| 1532 |
> |
|
| 1533 |
> |
send_mode_changes_client(source_p, chptr); |
| 1534 |
> |
send_mode_changes_server(source_p, chptr); |
| 1535 |
|
} |