exit_client() now takes 3 parameters rather than 5:

** Exit this IRC client, and all the dependents (users, servers) if this is a server.
* @param sptr        The client to exit.
* @param recv_mtags  Message tags to use as a base (if any).
* @param comment     The (s)quit message
* @returns FLUSH_BUFFER is returned if a local client disconnects,
*          otherwise 0 is returned. This so it can be used from
*          command functions like: return exit_client(sptr, ....);
This commit is contained in:
Bram Matthys 2019-10-02 14:54:09 +02:00
parent 1c746afdf1
commit ab3feff7c2
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
23 changed files with 105 additions and 109 deletions

View file

@ -290,7 +290,7 @@ extern char *get_client_host(Client *);
extern char *myctime(time_t);
extern char *short_date(time_t, char *buf);
extern char *long_date(time_t);
extern int exit_client(Client *cptr, Client *sptr, Client *from, MessageTag *recv_mtags, char *comment);
extern int exit_client(Client *sptr, MessageTag *recv_mtags, char *comment);
extern void initstats(), tstats(Client *, char *);
extern char *check_string(char *);
extern char *make_nick_user_host(char *, char *, char *);

View file

@ -1149,7 +1149,7 @@ int process_packet(Client *cptr, char *readbuf, int length, int killsafely)
cptr->user ? cptr->user->realhost : "*",
DBufLength(&cptr->local->recvQ), get_recvq(cptr));
if (!killsafely)
exit_client(cptr, cptr, cptr, NULL, "Excess Flood");
exit_client(cptr, NULL, "Excess Flood");
else
dead_link(cptr, "Excess Flood");
return 0;
@ -1236,7 +1236,7 @@ void read_packet(int fd, int revents, void *data)
get_client_name(cptr, FALSE));
}
exit_client(cptr, cptr, cptr, NULL, "Read error");
exit_client(cptr, NULL, "Read error");
return;
}

View file

@ -361,12 +361,12 @@ int check_tkls(Client *cptr)
snprintf(banbuf, sizeof(banbuf), "User has been banned (%s)", bconf->reason);
else
snprintf(banbuf, sizeof(banbuf), "Banned (%s)", bconf->reason);
(void)exit_client(cptr, cptr, &me, NULL, banbuf);
(void)exit_client(cptr, NULL, banbuf);
} else {
if (IsUser(cptr))
(void)exit_client(cptr, cptr, &me, NULL, "User has been banned");
(void)exit_client(cptr, NULL, "User has been banned");
else
(void)exit_client(cptr, cptr, &me, NULL, "Banned");
(void)exit_client(cptr, NULL, "Banned");
}
return 0; /* stop processing this user, as (s)he is dead now. */
}
@ -415,7 +415,7 @@ EVENT(check_unknowns)
cptr->name, cptr->ip?cptr->ip:"<unknown ip>");
}
(void)exit_client(cptr, cptr, &me, NULL, "Registration Timeout");
(void)exit_client(cptr, NULL, "Registration Timeout");
continue;
}
}
@ -462,7 +462,7 @@ int check_ping(Client *cptr)
(long long)TStime(), (long long)cptr->local->since, (long long)ping));
(void)ircsnprintf(scratch, sizeof(scratch), "Ping timeout: %lld seconds",
(long long) (TStime() - cptr->local->lasttime));
return exit_client(cptr, cptr, &me, NULL, scratch);
return exit_client(cptr, NULL, scratch);
}
else if (IsRegistered(cptr) && !IsPingSent(cptr))
{
@ -526,7 +526,7 @@ EVENT(check_deadsockets)
ircd_log(LOG_ERROR, "Closing deadsock: %d/%s", cptr->local->fd, cptr->name);
#endif
ClearDeadSocket(cptr); /* CPR. So we send the error. */
(void)exit_client(cptr, cptr, &me, NULL, cptr->local->error_str ? cptr->local->error_str : "Dead socket");
(void)exit_client(cptr, NULL, cptr->local->error_str ? cptr->local->error_str : "Dead socket");
continue;
}
}
@ -540,7 +540,7 @@ EVENT(check_deadsockets)
ircd_log(LOG_ERROR, "Closing deadsock: %d/%s", cptr->local->fd, cptr->name);
#endif
ClearDeadSocket(cptr); /* CPR. So we send the error. */
(void)exit_client(cptr, cptr, &me, NULL, cptr->local->error_str ? cptr->local->error_str : "Dead socket");
(void)exit_client(cptr, NULL, cptr->local->error_str ? cptr->local->error_str : "Dead socket");
continue;
}
}

View file

@ -513,18 +513,20 @@ static void exit_one_client(Client *sptr, MessageTag *mtags_i, const char *comme
remove_client_from_list(sptr);
}
/* Exit this IRC client, and all the dependents if this is a server.
*
* For convenience, this function returns a suitable value for
* cmd_function() return values:
* FLUSH_BUFFER if (cptr == sptr)
* 0 if (cptr != sptr)
/** Exit this IRC client, and all the dependents (users, servers) if this is a server.
* @param sptr The client to exit.
* @param recv_mtags Message tags to use as a base (if any).
* @param comment The (s)quit message
* @returns FLUSH_BUFFER is returned if a local client disconnects,
* otherwise 0 is returned. This so it can be used from
* command functions like: return exit_client(sptr, ....);
*/
int exit_client(Client *cptr, Client *sptr, Client *from, MessageTag *recv_mtags, char *comment)
int exit_client(Client *sptr, MessageTag *recv_mtags, char *comment)
{
long long on_for;
ConfigItem_listen *listen_conf;
MessageTag *mtags_generated = NULL;
int my_client = MyConnect(sptr) ? 1 : 0; /* needs to flag early */
/* We replace 'recv_mtags' here with a newly
* generated id if 'recv_mtags' is NULL or is
@ -604,14 +606,8 @@ int exit_client(Client *cptr, Client *sptr, Client *from, MessageTag *recv_mtags
if (sptr->local->fd >= 0 && !IsConnecting(sptr))
{
if (cptr != NULL && sptr != cptr)
sendto_one(sptr, NULL,
"ERROR :Closing Link: %s %s (%s)",
get_client_name(sptr, FALSE), cptr->name,
comment);
else
sendto_one(sptr, NULL, "ERROR :Closing Link: %s (%s)",
get_client_name(sptr, FALSE), comment);
sendto_one(sptr, NULL, "ERROR :Closing Link: %s (%s)",
get_client_name(sptr, FALSE), comment);
}
/*
** Currently only server connections can have
@ -650,14 +646,14 @@ int exit_client(Client *cptr, Client *sptr, Client *from, MessageTag *recv_mtags
else
ircsnprintf(splitstr, sizeof splitstr, "%s %s", sptr->srvptr->name, sptr->name);
remove_dependents(sptr, cptr, recv_mtags, comment, splitstr);
remove_dependents(sptr, sptr->direction, recv_mtags, comment, splitstr);
RunHook2(HOOKTYPE_SERVER_QUIT, sptr, recv_mtags);
}
else if (IsUser(sptr) && !IsKilled(sptr))
{
sendto_server(cptr, PROTO_SID, 0, recv_mtags, ":%s QUIT :%s", ID(sptr), comment);
sendto_server(cptr, 0, PROTO_SID, recv_mtags, ":%s QUIT :%s", sptr->name, comment);
sendto_server(sptr, PROTO_SID, 0, recv_mtags, ":%s QUIT :%s", ID(sptr), comment);
sendto_server(sptr, 0, PROTO_SID, recv_mtags, ":%s QUIT :%s", sptr->name, comment);
}
/* Finally, the client/server itself exits.. */
@ -665,7 +661,7 @@ int exit_client(Client *cptr, Client *sptr, Client *from, MessageTag *recv_mtags
free_message_tags(mtags_generated);
return cptr == sptr ? FLUSH_BUFFER : 0;
return my_client ? FLUSH_BUFFER : 0;
}
void initstats(void)
@ -1152,7 +1148,7 @@ int banned_client(Client *acptr, char *bantype, char *reason, int global, int no
if (noexit != NO_EXIT_CLIENT)
{
return exit_client(acptr, acptr, acptr, NULL, buf);
return exit_client(acptr, NULL, buf);
} else {
/* Special handling for direct Z-line code */
send_raw_direct(acptr, "ERROR :Closing Link: [%s] (%s)",

View file

@ -70,7 +70,7 @@ CMD_FUNC(cmd_close)
{
sendnumeric(sptr, RPL_CLOSING,
get_client_name(acptr, TRUE), acptr->status);
(void)exit_client(acptr, acptr, acptr, NULL, "Oper Closing");
(void)exit_client(acptr, NULL, "Oper Closing");
closed++;
}

View file

@ -428,7 +428,7 @@ int ct_pre_lconnect(Client *sptr)
sendto_realops("[ConnThrottle] For more information see https://www.unrealircd.org/docs/ConnThrottle");
ucounter->throttling_banner_displayed = 1;
}
return exit_client(sptr, sptr, &me, NULL, cfg.reason);
return exit_client(sptr, NULL, cfg.reason);
}
return 0;

View file

@ -75,7 +75,7 @@ static int do_jumpserver_exit_client(Client *sptr)
sendnumeric(sptr, RPL_REDIR, jss->ssl_server, NULL, jss->ssl_port);
else
sendnumeric(sptr, RPL_REDIR, jss->server, jss->port);
return exit_client(sptr, sptr, sptr, NULL, jss->reason);
return exit_client(sptr, NULL, jss->reason);
}
static void redirect_all_clients(void)

View file

@ -257,7 +257,7 @@ CMD_FUNC(cmd_kill)
if (MyUser(sptr))
RunHook3(HOOKTYPE_LOCAL_KILL, sptr, acptr, parv[2]);
n = exit_client(sptr->direction, acptr, sptr, mtags, buf2);
n = exit_client(acptr, mtags, buf2);
free_message_tags(mtags);

View file

@ -1662,7 +1662,7 @@ CMD_FUNC(_cmd_umode)
{
sendto_realops("QUARANTINE: Oper %s on server %s killed, due to quarantine", sptr->name, sptr->srvptr->name);
sendto_server(NULL, 0, 0, NULL, ":%s KILL %s :%s (Quarantined: no oper privileges allowed)", me.name, sptr->name, me.name);
return exit_client(sptr->direction, sptr, &me, NULL, "Quarantined: no oper privileges allowed");
return exit_client(sptr, NULL, "Quarantined: no oper privileges allowed");
}
/* A local user trying to set himself +o/+O is denied here.
* A while later (outside this loop) it is handled as well (and +C, +N, etc too)

View file

@ -158,7 +158,7 @@ void nick_collision(Client *cptr, char *newnick, char *newid, Client *new, Clien
/* Exit the client */
ircstats.is_kill++;
SetKilled(new);
(void)exit_client(NULL, new, &me, mtags, comment);
(void)exit_client(new, mtags, comment);
free_message_tags(mtags);
}
@ -193,7 +193,7 @@ void nick_collision(Client *cptr, char *newnick, char *newid, Client *new, Clien
/* Exit the client */
ircstats.is_kill++;
SetKilled(existing);
(void)exit_client(NULL, existing, &me, mtags, comment);
(void)exit_client(existing, mtags, comment);
free_message_tags(mtags);
}
@ -352,7 +352,7 @@ CMD_FUNC(cmd_uid)
me.name, sptr->name, me.name, acptr->direction->name,
get_client_name(sptr, FALSE));
SetKilled(sptr);
return exit_client(sptr->direction, sptr, &me, NULL, "Nick/Server collision");
return exit_client(sptr, NULL, "Nick/Server collision");
}
/* Now check if 'nick' already exists - collision with a user (or still in handshake, unknown) */
@ -364,7 +364,7 @@ CMD_FUNC(cmd_uid)
if (MyConnect(acptr) && IsUnknown(acptr))
{
SetKilled(acptr);
exit_client(NULL, acptr, &me, NULL, "Overridden");
exit_client(acptr, NULL, "Overridden");
goto nickkill2done;
}
@ -542,7 +542,7 @@ CMD_FUNC(cmd_nick)
sptr->user ? sptr->user->server :
cptr->name);
SetKilled(sptr);
n = exit_client(cptr, sptr, &me, mtags, "BadNick");
n = exit_client(sptr, mtags, "BadNick");
free_message_tags(mtags);
@ -682,7 +682,7 @@ CMD_FUNC(cmd_nick)
*/
get_client_name(cptr, FALSE));
SetKilled(sptr);
return exit_client(cptr, sptr, &me, NULL, "Nick/Server collision");
return exit_client(sptr, NULL, "Nick/Server collision");
}
if (MyUser(cptr) && !ValidatePermissionsForPath("immune:nick-flood",sptr,NULL,NULL,NULL))
@ -703,7 +703,7 @@ CMD_FUNC(cmd_nick)
if (acptr == cptr)
return 0;
SetKilled(acptr);
exit_client(NULL, acptr, &me, NULL, "Overridden");
exit_client(acptr, NULL, "Overridden");
goto nickkilldone;
}
/* A sanity check in the user field... */
@ -720,7 +720,7 @@ CMD_FUNC(cmd_nick)
messed up, trash the old one and accept the new one.
Remember - at this point there is a new nick coming in!
Handle appropriately. -- Barubary */
exit_client(NULL, acptr, &me, NULL, "Lost user field");
exit_client(acptr, NULL, "Lost user field");
goto nickkilldone;
}
/*
@ -1115,7 +1115,7 @@ int _register_user(Client *sptr, char *nick, char *username, char *umode, char *
* so have a generic exit_client() here to be safe.
*/
if (i != FLUSH_BUFFER)
return exit_client(sptr->direction, sptr, &me, NULL, "Rejected");
return exit_client(sptr, NULL, "Rejected");
return FLUSH_BUFFER;
}
@ -1212,7 +1212,7 @@ int _register_user(Client *sptr, char *nick, char *username, char *umode, char *
{
if (stripuser[0] == '\0')
{
return exit_client(sptr, sptr, sptr, NULL, "Hostile username. Please use only 0-9 a-z A-Z _ - and . in your username.");
return exit_client(sptr, NULL, "Hostile username. Please use only 0-9 a-z A-Z _ - and . in your username.");
}
strlcpy(olduser, user->username + noident, USERLEN+1);
@ -1361,7 +1361,7 @@ int _register_user(Client *sptr, char *nick, char *username, char *umode, char *
sendto_one(sptr, NULL, ":%s KILL %s :%s (No such server: %s)",
me.name, sptr->name, me.name, user->server);
SetKilled(sptr);
return exit_client(sptr, sptr, &me, NULL,
return exit_client(sptr, NULL,
"USER without prefix(2.8) or wrong prefix");
}
else if (acptr->direction != sptr->direction)
@ -1373,7 +1373,7 @@ int _register_user(Client *sptr, char *nick, char *username, char *umode, char *
me.name, sptr->name, me.name, user->server,
acptr->direction->name, acptr->direction->local->sockhost);
SetKilled(sptr);
return exit_client(sptr, sptr, &me, NULL,
return exit_client(sptr, NULL,
"USER server wrong direction");
} else
{
@ -1399,7 +1399,7 @@ int _register_user(Client *sptr, char *nick, char *username, char *umode, char *
sendto_ops("USER with invalid IP (%s) (%s) -- "
"IP must be base64 encoded binary representation of either IPv4 or IPv6",
sptr->name, ip);
return exit_client(sptr, sptr, &me, NULL, "USER with invalid IP");
return exit_client(sptr, NULL, "USER with invalid IP");
}
safe_strdup(sptr->ip, ipstring);
}
@ -1586,13 +1586,13 @@ int AllowClient(Client *cptr, struct hostent *hp, char *sockhost, char *username
if (!IsSecure(cptr) && !IsLocalhost(cptr) && (iConf.plaintext_policy_user == POLICY_DENY))
{
return exit_client(cptr, cptr, &me, NULL, iConf.plaintext_policy_user_message);
return exit_client(cptr, NULL, iConf.plaintext_policy_user_message);
}
if (IsSecure(cptr) && (iConf.outdated_tls_policy_user == POLICY_DENY) && outdated_tls_client(cptr))
{
char *msg = outdated_tls_client_build_string(iConf.outdated_tls_policy_user_message, cptr);
return exit_client(cptr, cptr, &me, NULL, msg);
return exit_client(cptr, NULL, msg);
}
for (aconf = conf_allow; aconf; aconf = aconf->next)
@ -1681,7 +1681,7 @@ int AllowClient(Client *cptr, struct hostent *hp, char *sockhost, char *username
if (cnt > aconf->maxperip)
{
/* Already got too many with that ip# */
return exit_client(cptr, cptr, &me, NULL, iConf.reject_message_too_many_connections);
return exit_client(cptr, NULL, iConf.reject_message_too_many_connections);
}
}
}
@ -1702,9 +1702,9 @@ int AllowClient(Client *cptr, struct hostent *hp, char *sockhost, char *username
else
{
sendnumeric(cptr, RPL_REDIR, aconf->server ? aconf->server : defserv, aconf->port ? aconf->port : 6667);
return exit_client(cptr, cptr, &me, NULL, iConf.reject_message_server_full);
return exit_client(cptr, NULL, iConf.reject_message_server_full);
}
return 0;
}
return exit_client(cptr, cptr, &me, NULL, iConf.reject_message_unauthorized);
return exit_client(cptr, NULL, iConf.reject_message_unauthorized);
}

View file

@ -94,7 +94,7 @@ int _check_banned(Client *cptr, int exitflags)
"Throttled: Reconnecting too fast - "
"Email %s for more information.",
KLINE_ADDRESS);
return exit_client(cptr, cptr, &me, NULL, zlinebuf);
return exit_client(cptr, NULL, zlinebuf);
}
}
else if (val == 1)

View file

@ -165,7 +165,7 @@ CMD_FUNC(cmd_protoctl)
snprintf(buf, sizeof(buf), "Server %s has utf8 in set::allowed-nickchars but %s does not. Link rejected.",
me.name, *sptr->name ? sptr->name : "other side");
sendto_realops("\002ERROR\001 %s", buf);
return exit_client(sptr, sptr, &me, NULL, buf);
return exit_client(sptr, NULL, buf);
}
/* We compare the character sets to see if we should warn opers about any mismatch... */
if (strcmp(value, charsys_get_current_languages()))
@ -173,7 +173,7 @@ CMD_FUNC(cmd_protoctl)
sendto_realops("\002WARNING!!!!\002 Link %s does not have the same set::allowed-nickchars settings (or is "
"a different UnrealIRCd version), this MAY cause display issues. Our charset: '%s', theirs: '%s'",
get_client_name(sptr, FALSE), charsys_get_current_languages(), value);
/* return exit_client(sptr, sptr, &me, NULL, "Nick charset mismatch"); */
/* return exit_client(sptr, NULL, "Nick charset mismatch"); */
}
if (sptr->serv)
safe_strdup(sptr->serv->features.nickchars, value);
@ -188,20 +188,20 @@ CMD_FUNC(cmd_protoctl)
char *sid = value;
if (!IsServer(sptr) && !IsEAuth(sptr) && !IsHandshake(sptr))
return exit_client(sptr, sptr, &me, NULL, "Got PROTOCTL SID before EAUTH, that's the wrong order!");
return exit_client(sptr, NULL, "Got PROTOCTL SID before EAUTH, that's the wrong order!");
if (*sptr->id && (strlen(sptr->id)==3))
return exit_client(sptr, sptr, &me, NULL, "Got PROTOCTL SID twice");
return exit_client(sptr, NULL, "Got PROTOCTL SID twice");
if (IsServer(sptr))
return exit_client(sptr, sptr, &me, NULL, "Got PROTOCTL SID after SERVER, that's the wrong order!");
return exit_client(sptr, NULL, "Got PROTOCTL SID after SERVER, that's the wrong order!");
if ((asptr = hash_find_id(sid, NULL)) != NULL)
{
sendto_one(sptr, NULL, "ERROR :SID %s already exists from %s", asptr->id, asptr->name);
sendto_snomask(SNO_SNOTICE, "Link %s rejected - SID %s already exists from %s",
get_client_name(sptr, FALSE), asptr->id, asptr->name);
return exit_client(sptr, sptr, &me, NULL, "SID collision");
return exit_client(sptr, NULL, "SID collision");
}
if (*sptr->id)
@ -238,7 +238,7 @@ CMD_FUNC(cmd_protoctl)
"WARNING: Bogus server name (%s) from %s in EAUTH (maybe just a fishy client)",
servername ? servername : "", get_client_name(sptr, TRUE));
return exit_client(sptr, sptr, &me, NULL, "Bogus server name");
return exit_client(sptr, NULL, "Bogus server name");
}
@ -300,7 +300,7 @@ CMD_FUNC(cmd_protoctl)
asptr->id, asptr->name);
sendto_realops("Link %s cancelled, server with SID %s (%s) already exists",
get_client_name(asptr, TRUE), asptr->id, asptr->name);
return exit_client(sptr, sptr, sptr, NULL, "Server Exists (or non-unique me::sid)");
return exit_client(sptr, NULL, "Server Exists (or non-unique me::sid)");
}
asptr = find_pending_net_duplicates(sptr, &srv, &sid);
@ -311,7 +311,7 @@ CMD_FUNC(cmd_protoctl)
sendto_realops("Link %s cancelled, server would introduce server with SID %s, which "
"server %s is also about to introduce. Just wait a moment for it to synchronize...",
get_client_name(asptr, TRUE), sid, get_client_name(srv, TRUE));
return exit_client(sptr, sptr, sptr, NULL, "Server Exists (just wait a moment)");
return exit_client(sptr, NULL, "Server Exists (just wait a moment)");
}
/* Send our PROTOCTL SERVERS= back if this was NOT a response */
@ -365,7 +365,7 @@ CMD_FUNC(cmd_protoctl)
{
sendto_realops("%s", msg);
ircd_log(LOG_ERROR, "%s", msg);
return exit_client(sptr, sptr, sptr, NULL, linkerr);
return exit_client(sptr, NULL, linkerr);
}
}
else if (!strcmp(name, "MLOCK"))

View file

@ -71,10 +71,10 @@ CMD_FUNC(cmd_quit)
Hook *tmphook;
if (STATIC_QUIT)
return exit_client(sptr->direction, sptr, sptr, recv_mtags, STATIC_QUIT);
return exit_client(sptr, recv_mtags, STATIC_QUIT);
if (IsVirus(sptr))
return exit_client(sptr->direction, sptr, sptr, recv_mtags, "Client exited");
return exit_client(sptr, recv_mtags, "Client exited");
n = run_spamfilter(sptr, comment, SPAMF_QUIT, NULL, 0, NULL);
if (n == FLUSH_BUFFER)
@ -144,13 +144,13 @@ CMD_FUNC(cmd_quit)
else
strlcpy(commentbuf, comment, sizeof(commentbuf));
return exit_client(sptr->direction, sptr, sptr, recv_mtags, commentbuf);
return exit_client(sptr, recv_mtags, commentbuf);
}
else
{
/* Remote quits and non-person quits always use their original comment.
* Also pass recv_mtags so to keep the msgid and such.
*/
return exit_client(sptr->direction, sptr, sptr, recv_mtags, comment);
return exit_client(sptr, recv_mtags, comment);
}
}

View file

@ -476,7 +476,7 @@ CMD_FUNC(cmd_smod)
if (abort)
{
sendto_umode_global(UMODE_OPER, "ABORTING LINK: %s <=> %s", me.name, sptr->name);
return exit_client(sptr->direction, sptr, &me, NULL, "ABORTING LINK");
return exit_client(sptr, NULL, "ABORTING LINK");
}
return 0;

View file

@ -132,7 +132,7 @@ int _check_deny_version(Client *cptr, char *software, int protocol, char *flags)
result = 0;
if (result)
return exit_client(cptr, cptr, cptr, NULL, "Denied by deny version { } block");
return exit_client(cptr, NULL, "Denied by deny version { } block");
if (flags)
{
@ -158,7 +158,7 @@ int _check_deny_version(Client *cptr, char *software, int protocol, char *flags)
}
if (result)
return exit_client(cptr, cptr, cptr, NULL, "Denied by deny version { } block");
return exit_client(cptr, NULL, "Denied by deny version { } block");
}
return 0;
@ -250,7 +250,7 @@ int _verify_link(Client *sptr, char *servername, ConfigItem_link **link_out)
if (!sptr->local->passwd)
{
sendto_one(sptr, NULL, "ERROR :Missing password");
return exit_client(sptr, sptr, &me, NULL, "Missing password");
return exit_client(sptr, NULL, "Missing password");
}
/* First check if the server is in the list */
@ -276,7 +276,7 @@ int _verify_link(Client *sptr, char *servername, ConfigItem_link **link_out)
sendto_one(sptr, NULL, "ERROR :%s", xerrmsg);
sendto_ops_and_log("Outgoing link aborted to %s(%s@%s) (%s) %s",
sptr->serv->conf->servername, sptr->ident, sptr->local->sockhost, xerrmsg, inpath);
return exit_client(sptr, sptr, &me, NULL, xerrmsg);
return exit_client(sptr, NULL, xerrmsg);
}
link = sptr->serv->conf;
goto skip_host_check;
@ -312,7 +312,7 @@ errlink:
/* And send the "verbose" error msg only to locally connected ircops */
sendto_ops_and_log("Link denied for %s(%s@%s) (%s) %s",
servername, sptr->ident, sptr->local->sockhost, xerrmsg, inpath);
return exit_client(sptr, sptr, &me, NULL,
return exit_client(sptr, NULL,
"Link denied (No link block found with your server name or link::incoming::mask did not match)");
}
@ -356,7 +356,7 @@ skip_host_check:
sendto_one(sptr, NULL,
"ERROR :Link '%s' denied (Authentication failed) %s",
servername, inpath);
return exit_client(sptr, sptr, &me, NULL,
return exit_client(sptr, NULL,
"Link denied (Authentication failed)");
}
@ -372,7 +372,7 @@ skip_host_check:
servername, inpath);
sendto_ops_and_log("Link denied for '%s' (Not using SSL/TLS and verify-certificate is on) %s",
servername, inpath);
return exit_client(sptr, sptr, &me, NULL,
return exit_client(sptr, NULL,
"Link denied (Not using SSL/TLS)");
}
if (!verify_certificate(sptr->local->ssl, link->servername, &errstr))
@ -383,7 +383,7 @@ skip_host_check:
sendto_ops_and_log("Link denied for '%s' (Certificate verification failed) %s",
servername, inpath);
sendto_ops_and_log("Reason for certificate verification failure: %s", errstr);
return exit_client(sptr, sptr, &me, NULL,
return exit_client(sptr, NULL,
"Link denied (Certificate verification failed)");
}
}
@ -401,7 +401,7 @@ skip_host_check:
sendto_ops_and_log("Link %s rejected, server trying to link with my name (%s)",
get_client_name(sptr, TRUE), me.name);
sendto_one(sptr, NULL, "ERROR: Server %s exists (it's me!)", me.name);
return exit_client(sptr, sptr, sptr, NULL, "Server Exists");
return exit_client(sptr, NULL, "Server Exists");
}
acptr = acptr->direction;
@ -415,7 +415,7 @@ skip_host_check:
("Link %s cancelled, server %s already exists from %s",
get_client_name(acptr, TRUE), servername,
(ocptr->direction ? ocptr->direction->name : "<nobody>"));
return exit_client(acptr, acptr, acptr, NULL,
return exit_client(acptr, NULL,
"Server Exists");
}
if ((bconf = Find_ban(NULL, servername, CONF_BAN_SERVER)))
@ -424,25 +424,25 @@ skip_host_check:
("Cancelling link %s, banned server",
get_client_name(sptr, TRUE));
sendto_one(sptr, NULL, "ERROR :Banned server (%s)", bconf->reason ? bconf->reason : "no reason");
return exit_client(sptr, sptr, &me, NULL, "Banned server");
return exit_client(sptr, NULL, "Banned server");
}
if (link->class->clients + 1 > link->class->maxclients)
{
sendto_ops_and_log("Cancelling link %s, full class",
get_client_name(sptr, TRUE));
return exit_client(sptr, sptr, &me, NULL, "Full class");
return exit_client(sptr, NULL, "Full class");
}
if (!IsLocalhost(sptr) && (iConf.plaintext_policy_server == POLICY_DENY) && !IsSecure(sptr))
{
sendto_one(sptr, NULL, "ERROR :Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')");
sendto_ops_and_log("Rejected insecure server %s. See https://www.unrealircd.org/docs/FAQ#ERROR:_Servers_need_to_use_SSL.2FTLS", sptr->name);
return exit_client(sptr, sptr, &me, NULL, "Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')");
return exit_client(sptr, NULL, "Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')");
}
if (IsSecure(sptr) && (iConf.outdated_tls_policy_server == POLICY_DENY) && outdated_tls_client(sptr))
{
sendto_one(sptr, NULL, "ERROR :Server is using an outdated SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')");
sendto_ops_and_log("Rejected server %s using outdated %s. See https://www.unrealircd.org/docs/FAQ#server-outdated-tls", tls_get_cipher(sptr->local->ssl), sptr->name);
return exit_client(sptr, sptr, &me, NULL, "Server using outdates SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')");
return exit_client(sptr, NULL, "Server using outdates SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')");
}
if (link_out)
*link_out = link;
@ -492,11 +492,11 @@ CMD_FUNC(cmd_server)
if (parc < 4 || (!*parv[3]))
{
sendto_one(sptr, NULL, "ERROR :Not enough SERVER parameters");
return exit_client(sptr->direction, sptr, &me, NULL, "Not enough parameters");
return exit_client(sptr, NULL, "Not enough parameters");
}
if (MyConnect(sptr) && IsUnknown(sptr) && (sptr->local->listener->options & LISTENER_CLIENTSONLY))
return exit_client(sptr, sptr, &me, NULL, "This port is for clients only");
return exit_client(sptr, NULL, "This port is for clients only");
/* Now, let us take a look at the parameters we got
* Passes here:
@ -519,13 +519,13 @@ CMD_FUNC(cmd_server)
"WARNING: Bogus server name (%s) from %s (maybe just a fishy client)",
servername, get_client_name(sptr, TRUE));
return exit_client(sptr->direction, sptr, &me, NULL, "Bogus server name");
return exit_client(sptr, NULL, "Bogus server name");
}
if ((IsUnknown(sptr) || IsHandshake(sptr)) && !sptr->local->passwd)
{
sendto_one(sptr, NULL, "ERROR :Missing password");
return exit_client(sptr, sptr, &me, NULL, "Missing password");
return exit_client(sptr, NULL, "Missing password");
}
/*
@ -583,7 +583,7 @@ CMD_FUNC(cmd_server)
&& crule_eval(deny->rule)) {
sendto_ops_and_log("Refused connection from %s. Rejected by deny link { } block.",
get_client_host(sptr));
return exit_client(sptr, sptr, sptr, NULL, "Disallowed by connection rule");
return exit_client(sptr, NULL, "Disallowed by connection rule");
}
}
if (aconf->options & CONNECT_QUARANTINE)
@ -629,7 +629,7 @@ CMD_FUNC(cmd_server_remote)
sendto_ops_and_log("Link %s rejected, server trying to link with my name (%s)",
get_client_name(sptr, TRUE), me.name);
sendto_one(sptr, NULL, "ERROR: Server %s exists (it's me!)", me.name);
return exit_client(sptr, sptr, sptr, NULL, "Server Exists");
return exit_client(sptr, NULL, "Server Exists");
}
// FIXME: verify this code:
@ -645,14 +645,14 @@ CMD_FUNC(cmd_server_remote)
get_client_name(acptr, TRUE), servername,
(ocptr->direction ? ocptr->direction->name : "<nobody>"));
if (acptr == cptr) {
return exit_client(acptr, acptr, acptr, NULL, "Server Exists");
return exit_client(acptr, NULL, "Server Exists");
} else {
/* AFAIK this can cause crashes if this happends remotely because
* we will still receive msgs for some time because of lag.
* Two possible solutions: unlink the directly connected server (cptr)
* and/or fix all those commands which blindly trust server input. -- Syzop
*/
exit_client(acptr, acptr, acptr, NULL, "Server Exists");
exit_client(acptr, NULL, "Server Exists");
return 0;
}
}
@ -661,7 +661,7 @@ CMD_FUNC(cmd_server_remote)
sendto_ops_and_log("Cancelling link %s, banned server %s",
get_client_name(cptr, TRUE), servername);
sendto_one(cptr, NULL, "ERROR :Banned server (%s)", bconf->reason ? bconf->reason : "no reason");
return exit_client(cptr, cptr, &me, NULL, "Brought in banned server");
return exit_client(cptr, NULL, "Brought in banned server");
}
/* OK, let us check in the data now now */
hop = atol(parv[2]);
@ -669,20 +669,20 @@ CMD_FUNC(cmd_server_remote)
if (!cptr->serv->conf)
{
sendto_ops_and_log("Internal error: lost conf for %s!!, dropping link", cptr->name);
return exit_client(cptr, cptr, cptr, NULL, "Lost configuration");
return exit_client(cptr, NULL, "Lost configuration");
}
aconf = cptr->serv->conf;
if (!aconf->hub)
{
sendto_ops_and_log("Link %s cancelled, is Non-Hub but introduced Leaf %s",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, NULL, "Non-Hub Link");
return exit_client(cptr, NULL, "Non-Hub Link");
}
if (!match_simple(aconf->hub, servername))
{
sendto_ops_and_log("Link %s cancelled, linked in %s, which hub config disallows",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, NULL, "Not matching hub configuration");
return exit_client(cptr, NULL, "Not matching hub configuration");
}
if (aconf->leaf)
{
@ -690,14 +690,14 @@ CMD_FUNC(cmd_server_remote)
{
sendto_ops_and_log("Link %s(%s) cancelled, disallowed by leaf configuration",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, NULL, "Disallowed by leaf configuration");
return exit_client(cptr, NULL, "Disallowed by leaf configuration");
}
}
if (aconf->leaf_depth && (hop > aconf->leaf_depth))
{
sendto_ops_and_log("Link %s(%s) cancelled, too deep depth",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, NULL, "Too deep link depth (leaf)");
return exit_client(cptr, NULL, "Too deep link depth (leaf)");
}
acptr = make_client(cptr, find_server(sptr->name, cptr));
(void)make_server(acptr);

View file

@ -57,7 +57,7 @@ int sinfo_server(Client *sptr, int parc, char *parv[])
* failure to do so will lead to potential desyncs or other major
* issues.
*/
return exit_client(sptr, sptr, &me, NULL, "Protocol error: you cannot send SINFO about yourself");
return exit_client(sptr, NULL, "Protocol error: you cannot send SINFO about yourself");
}
/* :SID SINFO up_since protocol umodes chanmodes nickchars :software name

View file

@ -160,5 +160,5 @@ CMD_FUNC(cmd_squit)
SetSQuit(acptr);
}
return exit_client(sptr->direction, acptr, sptr, recv_mtags, comment);
return exit_client(acptr, recv_mtags, comment);
}

View file

@ -83,7 +83,7 @@ CMD_FUNC(cmd_svskill)
new_message(acptr, recv_mtags, &mtags);
sendto_server(sptr, 0, 0, mtags, ":%s SVSKILL %s :%s", sptr->name, parv[1], comment);
SetKilled(acptr);
n = exit_client(sptr->direction, acptr, sptr, mtags, comment);
n = exit_client(acptr, mtags, comment);
free_message_tags(mtags);
return n;
}

View file

@ -79,7 +79,7 @@ CMD_FUNC(cmd_svsnick)
if ((ocptr = find_client(parv[2], NULL)) && ocptr != acptr) /* Collision */
{
exit_client(acptr, acptr, sptr, NULL,
exit_client(acptr, NULL,
"Nickname collision due to Services enforced "
"nickname change, your nick was overruled");
return 0;

View file

@ -4149,7 +4149,7 @@ int _place_host_ban(Client *sptr, BanAction action, char *reason, long duration)
case BAN_ACT_SOFT_KILL:
case BAN_ACT_KILL:
default:
return exit_client(sptr, sptr, sptr, NULL, reason);
return exit_client(sptr, NULL, reason);
}
return -1;
}

View file

@ -80,7 +80,7 @@ CMD_FUNC(cmd_user)
return 0;
if (MyConnect(sptr) && (sptr->local->listener->options & LISTENER_SERVERSONLY))
return exit_client(sptr->direction, sptr, sptr, NULL, "This port is for servers only");
return exit_client(sptr, NULL, "This port is for servers only");
if (parc > 2 && (username = strchr(parv[1], '@')))
*username = '\0';

View file

@ -342,7 +342,7 @@ int dowebirc(Client *cptr, char *ip, char *host, char *options)
char scratch[64];
if (IsWEBIRC(cptr))
return exit_client(cptr, cptr, &me, NULL, "Double CGI:IRC request (already identified)");
return exit_client(cptr, NULL, "Double CGI:IRC request (already identified)");
if (host && !strcmp(ip, host))
host = NULL; /* host did not resolve, make it NULL */
@ -353,7 +353,7 @@ int dowebirc(Client *cptr, char *ip, char *host, char *options)
(inet_pton(AF_INET6, ip, scratch) != 1))
{
/* then we have an invalid IP */
return exit_client(cptr, cptr, &me, NULL, "Invalid IP address");
return exit_client(cptr, NULL, "Invalid IP address");
}
/* STEP 2: Update GetIP() */
@ -427,7 +427,7 @@ CMD_FUNC(cmd_webirc)
/* Check if allowed host */
e = Find_webirc(sptr, password, WEBIRC_WEBIRC, &error);
if (!e)
return exit_client(sptr, sptr, &me, NULL, error);
return exit_client(sptr, NULL, error);
/* And do our job.. */
return dowebirc(sptr, ip, host, options);
@ -464,7 +464,7 @@ int webirc_local_pass(Client *sptr, char *password)
ip = password + WEBIRC_STRINGLEN;
host = strchr(ip, '_');
if (!host)
return exit_client(sptr, sptr, &me, NULL, "Invalid CGI:IRC IP received");
return exit_client(sptr, NULL, "Invalid CGI:IRC IP received");
*host++ = '\0';
return dowebirc(sptr, ip, host, NULL);

View file

@ -45,7 +45,7 @@ int ban_flooder(Client *cptr)
* from the same IP.
*/
if (find_tkl_exception(TKL_UNKNOWN_DATA_FLOOD, cptr))
return exit_client(cptr, cptr, &me, NULL, "Flood from unknown connection");
return exit_client(cptr, NULL, "Flood from unknown connection");
/* place_host_ban also takes care of removing any other clients with same host/ip */
return place_host_ban(cptr, BAN_ACT_ZLINE, "Flood from unknown connection", UNKNOWN_FLOOD_BANTIME);
}
@ -559,7 +559,7 @@ static int do_numeric(int numeric, Client *sptr, MessageTag *recv_mtags, int par
static int cancel_clients(Client *cptr, Client *sptr, char *cmd)
{
if (IsServer(cptr) || IsServer(sptr) || IsMe(sptr)) return 0;
return exit_client(cptr, cptr, &me, NULL, "Fake prefix");
return exit_client(cptr, NULL, "Fake prefix");
}
static void remove_unknown(Client *cptr, char *sender)