Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Commit

Permalink
Fix expire_check(), do_login() and do_logout() for multiuser.
Browse files Browse the repository at this point in the history
Fix the make_hostmask() fiasco dKingston inflicted on us.
  • Loading branch information
rakaur committed May 11, 2011
1 parent 4901309 commit 70f01ea
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 82 deletions.
15 changes: 7 additions & 8 deletions help/logout
@@ -1,16 +1,15 @@
Help for LOGOUT:

LOGOUT logs you out of services so that you
can log into another username or whatever else
melts your butter. Note that you are automatically
logged out when you sign off.
can log into another username, etc. Note that
you are automatically logged out when you sign off.

If the last two parameters are present it will
logout whomever is currently logged in as the
supplied username.
If the last parameter is present it will log out the
indicated nickname from the username you're currently
logged in as.

Syntax: LOGOUT [username] [password]
Syntax: LOGOUT [nickname]

Examples:
/msg &nick& LOGOUT
/msg &nick& LOGOUT foo bar
/msg &nick& LOGOUT foo
1 change: 0 additions & 1 deletion inc/extern.h
Expand Up @@ -82,7 +82,6 @@ E void *scalloc(size_t elsize, size_t els);
E void *srealloc(void *oldptr, size_t newsize);
E char *sstrdup(const char *s);
E void strip(char *line);
E char *make_hostmask(char *nick, char *user, char *host);
E void slog(uint32_t level, const char *fmt, ...);
E uint32_t time_msec(void);
E uint8_t regex_match(regex_t * preg, char *pattern, char *string,
Expand Down
6 changes: 4 additions & 2 deletions src/cmode.c
Expand Up @@ -189,8 +189,10 @@ void channel_mode(channel_t *chan, uint8_t parc, char *parv[])

if ((MC_SECURE & mc->flags) && (status_mode_list[i].mode == 'o'))
{
char *hostbuf = make_hostmask(cu->user->nick, cu->user->user,
cu->user->host);
char hostbuf[BUFSIZE];

snprintf(hostbuf, BUFSIZE, "%s!%s@%s",
cu->user->nick, cu->user->user, cu->user->host);

if ((!is_founder(mc, mu)) && (cu->user != svs.svs) &&
(!is_xop(mc, mu, (CA_AOP | CA_SOP))) &&
Expand Down
29 changes: 9 additions & 20 deletions src/function.c
Expand Up @@ -177,21 +177,6 @@ void strip(char *line)
}
}

/* creates a hostmask based on params */
char *make_hostmask(char *nick, char *user, char *host)
{
static char buf[BUFSIZE];
buf[0] = '\0';

strlcat(buf, nick, BUFSIZE);
strlcat(buf, "!", BUFSIZE);
strlcat(buf, user, BUFSIZE);
strlcat(buf, "@", BUFSIZE);
strlcat(buf, host, BUFSIZE);

return buf;
}

/* logs something to shrike.log */
void slog(uint32_t level, const char *fmt, ...)
{
Expand Down Expand Up @@ -682,13 +667,13 @@ boolean_t is_successor(mychan_t *mychan, myuser_t *myuser)

boolean_t is_xop(mychan_t *mychan, myuser_t *myuser, uint8_t level)
{
char *hostbuf;
char hostbuf[BUFSIZE];

if (!myuser)
return FALSE;

hostbuf = make_hostmask(myuser->user->nick, myuser->user->user,
myuser->user->host);
snprintf(hostbuf, BUFSIZE, "%s!%s@%s",
myuser->user->nick, myuser->user->user, myuser->user->host);

if (chanacs_find(mychan, myuser, level))
return TRUE;
Expand Down Expand Up @@ -736,7 +721,9 @@ boolean_t should_op(mychan_t *mychan, myuser_t *myuser)

boolean_t should_op_host(mychan_t *mychan, char *host)
{
char *hostbuf = make_hostmask(svs.nick, svs.user, svs.host);
char hostbuf[BUFSIZE];

snprintf(hostbuf, BUFSIZE, "%s!%s@%s", svs.nick, svs.user, svs.host);

if (!match(host, hostbuf))
return FALSE;
Expand Down Expand Up @@ -772,7 +759,9 @@ boolean_t should_voice(mychan_t *mychan, myuser_t *myuser)

boolean_t should_voice_host(mychan_t *mychan, char *host)
{
char *hostbuf = make_hostmask(svs.nick, svs.user, svs.host);
char hostbuf[BUFSIZE];

snprintf(hostbuf, BUFSIZE, "%s!%s@%s", svs.nick, svs.user, svs.host);

if (!match(host, hostbuf))
return FALSE;
Expand Down
13 changes: 3 additions & 10 deletions src/node.c
Expand Up @@ -768,7 +768,7 @@ chanuser_t *chanuser_add(channel_t *chan, char *nick)
chanuser_t *cu, *tcu;
mychan_t *mc;
uint32_t flags = 0;
char *hostbuf;
char hostbuf[BUFSIZE];

if (*chan->name != '#')
{
Expand All @@ -794,7 +794,7 @@ chanuser_t *chanuser_add(channel_t *chan, char *nick)
return NULL;
}

hostbuf = make_hostmask(u->nick, u->user, u->host);
snprintf(hostbuf, BUFSIZE, "%s!%s@%s", u->nick, u->user, u->host);

/* see if we need to deop them */
if ((mc = mychan_find(chan->name)))
Expand Down Expand Up @@ -888,16 +888,9 @@ chanuser_t *chanuser_add(channel_t *chan, char *nick)

if (mc)
{
/* XXX - for some reason make_hostmask doesn't work here */
char newhostbuf[BUFSIZE];

newhostbuf[0] = '\0';

strlcat(newhostbuf, u->nick, BUFSIZE);
strlcat(newhostbuf, "!", BUFSIZE);
strlcat(newhostbuf, u->user, BUFSIZE);
strlcat(newhostbuf, "@", BUFSIZE);
strlcat(newhostbuf, u->host, BUFSIZE);
snprintf(newhostbuf, BUFSIZE, "%s!%s@%s", u->nick, u->user, u->host);

if (should_voice_host(mc, newhostbuf))
{
Expand Down

0 comments on commit 70f01ea

Please sign in to comment.