Example #1
0
static void nick_group(hook_user_req_t *hdata)
{
	user_t *u;

	u = hdata->si->su != NULL && !irccasecmp(hdata->si->su->nick, hdata->mn->nick) ? hdata->si->su : user_find_named(hdata->mn->nick);
	if (u != NULL && should_reg_umode(u))
		sts(":%s ENCAP * IDENTIFIED %s %s", ME, CLIENT_NAME(u), u->nick);
}
Example #2
0
static void nick_group(hook_user_req_t *hdata)
{
	user_t *u;

	u = hdata->si->su != NULL && !irccasecmp(hdata->si->su->nick, hdata->mn->nick) ? hdata->si->su : user_find_named(hdata->mn->nick);
	if (u != NULL && should_reg_umode(u))
		sts(":%s ENCAP * SVSMODE %s %lu +rd %lu", nicksvs.nick, u->nick, (unsigned long)u->ts, (unsigned long)CURRTIME);
}
Example #3
0
/* protocol-specific stuff to do on login */
static void chatd_on_login(user_t *u, myuser_t *mu, const char *wantedhost)
{
	return_if_fail(u != NULL);

	sts(":%s ENCAP * SU %s %s", ME, CLIENT_NAME(u), entity(mu)->name);

	if (should_reg_umode(u))
		sts(":%s ENCAP * IDENTIFIED %s %s", ME, CLIENT_NAME(u), u->nick);
}
Example #4
0
static void m_euid(sourceinfo_t *si, int parc, char *parv[])
{
	server_t *s;
	user_t *u;

	/* got the right number of args for an introduction? */
	if (parc >= 11)
	{
		s = si->s;
		slog(LG_DEBUG, "m_euid(): new user on `%s': %s", s->name, parv[0]);

		u = user_add(parv[0],				/* nick */
			parv[4],				/* user */
			*parv[8] != '*' ? parv[8] : parv[5],	/* hostname */
			parv[5],				/* hostname (visible) */
			parv[6],				/* ip */
			parv[7],				/* uid */
			parv[parc - 1],				/* gecos */
			s,					/* object parent (server) */
			atoi(parv[2]));				/* hopcount */
		if (u == NULL)
			return;

		user_mode(u, parv[3]);
		if (*parv[9] != '*')
		{
			handle_burstlogin(u, parv[9], 0);
			/* If an account is given in burst, then either they logged in with sasl,
			 * or they logged in before a split and are now returning. Either way we need
			 * to check for identified-to-nick status and update the ircd state accordingly.
			 * For sasl they should be marked identified, and when returning from a split
			 * their nick may have been ungrouped, they may have changed nicks, or their account
			 * may have been dropped.
			 */
			if (authservice_loaded)
				sts(":%s ENCAP * IDENTIFIED %s %s %s", ME, CLIENT_NAME(u), u->nick,
						should_reg_umode(u) ? "" : "OFF");
		}

		/* server_eob() cannot know if a user was introduced
		 * with NICK/UID or EUID and handle_nickchange() must
		 * be called exactly once for each new user -- jilles */
		if (s->flags & SF_EOB)
			handle_nickchange(u);
	}
	else
	{
		int i;
		slog(LG_DEBUG, "m_euid(): got EUID with wrong number of params");

		for (i = 0; i < parc; i++)
			slog(LG_DEBUG, "m_euid():   parv[%d] = %s", i, parv[i]);
	}
}
Example #5
0
/* protocol-specific stuff to do on login */
static void plexus_on_login(user_t *u, myuser_t *account, const char *wantedhost)
{
	if (!me.connected || u == NULL)
		return;

	/* Can only do this for nickserv, and can only record identified
	 * state if logged in to correct nick, sorry -- jilles
	 */
	if (!should_reg_umode(u))
		return;

#ifdef USE_NETADMIN
	if (has_priv_user(u, PRIV_ADMIN))
		sts(":%s ENCAP * SVSMODE %s %lu +rdN %lu", nicksvs.nick, u->nick, (unsigned long)u->ts, (unsigned long)CURRTIME);
	else
#endif
		sts(":%s ENCAP * SVSMODE %s %lu +rd %lu", nicksvs.nick, u->nick, (unsigned long)u->ts, (unsigned long)CURRTIME);
}
Example #6
0
static void m_nick(sourceinfo_t *si, int parc, char *parv[])
{
	server_t *s;
	user_t *u;

	/* got the right number of args for an introduction? */
	if (parc == 8)
	{
		s = server_find(parv[6]);
		if (!s)
		{
			slog(LG_DEBUG, "m_nick(): new user on nonexistant server: %s", parv[6]);
			return;
		}

		slog(LG_DEBUG, "m_nick(): new user on `%s': %s", s->name, parv[0]);

		u = user_add(parv[0], parv[4], parv[5], NULL, NULL, NULL, parv[7], s, atoi(parv[2]));
		if (u == NULL)
			return;

		user_mode(u, parv[3]);

		/* If server is not yet EOB we will do this later.
		 * This avoids useless "please identify" -- jilles */
		if (s->flags & SF_EOB)
			handle_nickchange(user_find(parv[0]));
	}

	/* if it's only 2 then it's a nickname change */
	else if (parc == 2)
	{
		bool realchange;

		if (!si->su)
		{
			slog(LG_DEBUG, "m_nick(): server trying to change nick: %s", si->s != NULL ? si->s->name : "<none>");
			return;
		}

		slog(LG_DEBUG, "m_nick(): nickname change from `%s': %s", si->su->nick, parv[0]);

		realchange = irccasecmp(si->su->nick, parv[0]);

		if (user_changenick(si->su, parv[0], atoi(parv[1])))
			return;

		/* fix up +e if necessary -- jilles */
		if (realchange && should_reg_umode(si->su))
			/* changed nick to registered one, reset +e */
			sts(":%s ENCAP * IDENTIFIED %s %s", ME, CLIENT_NAME(si->su), si->su->nick);

		/* It could happen that our PING arrived late and the
		 * server didn't acknowledge EOB yet even though it is
		 * EOB; don't send double notices in that case -- jilles */
		if (si->su->server->flags & SF_EOB)
			handle_nickchange(si->su);
	}
	else
	{
		int i;
		slog(LG_DEBUG, "m_nick(): got NICK with wrong number of params");

		for (i = 0; i < parc; i++)
			slog(LG_DEBUG, "m_nick():   parv[%d] = %s", i, parv[i]);
	}
}
Example #7
0
static void m_nick(sourceinfo_t *si, int parc, char *parv[])
{
    server_t *s;
    user_t *u;
    bool realchange;

    /* -> NICK jilles 1 1136143909 ~jilles 192.168.1.5 jaguar.test :Jilles Tjoelker */
    if (parc == 7)
    {
        s = server_find(parv[5]);
        if (!s)
        {
            slog(LG_DEBUG, "m_nick(): new user on nonexistant server: %s", parv[5]);
            return;
        }

        slog(LG_DEBUG, "m_nick(): new user on `%s': %s", s->name, parv[0]);

        u = user_add(parv[0], parv[3], parv[4], NULL, NULL, NULL, parv[6], s, atoi(parv[2]));
        if (u == NULL)
            return;

        /* Ok, we have the user ready to go.
         * Here's the deal -- if the user's SVID is before
         * the start time, and not 0, then check to see
         * if it's a registered account or not.
         *
         * If it IS registered, deal with that accordingly,
         * via handle_burstlogin(). --nenolod
         */
        handle_nickchange(u);
    }
    /* if it's only 2 then it's a nickname change */
    else if (parc == 2)
    {
        if (!si->su)
        {
            slog(LG_DEBUG, "m_nick(): server trying to change nick: %s", si->s != NULL ? si->s->name : "<none>");
            return;
        }

        slog(LG_DEBUG, "m_nick(): nickname change from `%s': %s", si->su->nick, parv[0]);

        realchange = irccasecmp(si->su->nick, parv[0]);

        if (user_changenick(si->su, parv[0], atoi(parv[1])))
            return;

        /* fix up +r if necessary -- jilles */
        if (realchange && should_reg_umode(si->su))
            /* changed nick to registered one, reset +r */
            sts(":%s SVSMODE %s +rd %lu", nicksvs.nick, parv[0], (unsigned long)CURRTIME);

        handle_nickchange(si->su);
    }
    else
    {
        int i;
        slog(LG_DEBUG, "m_nick(): got NICK with wrong number of params");

        for (i = 0; i < parc; i++)
            slog(LG_DEBUG, "m_nick():   parv[%d] = %s", i, parv[i]);
    }
}
Example #8
0
static mowgli_node_t *unreal_next_matching_ban(channel_t *c, user_t *u, int type, mowgli_node_t *first)
{
    chanban_t *cb;
    mowgli_node_t *n;
    char hostbuf[NICKLEN+USERLEN+HOSTLEN];
    char realbuf[NICKLEN+USERLEN+HOSTLEN];
    char ipbuf[NICKLEN+USERLEN+HOSTLEN];
    char *p;
    bool matched;
    int exttype;
    channel_t *target_c;

    snprintf(hostbuf, sizeof hostbuf, "%s!%s@%s", u->nick, u->user, u->vhost);
    snprintf(realbuf, sizeof realbuf, "%s!%s@%s", u->nick, u->user, u->host);
    /* will be nick!user@ if ip unknown, doesn't matter */
    snprintf(ipbuf, sizeof ipbuf, "%s!%s@%s", u->nick, u->user, u->ip);

    MOWGLI_ITER_FOREACH(n, first)
    {
        cb = n->data;

        if (cb->type != type)
            continue;

        if ((!match(cb->mask, hostbuf) || !match(cb->mask, realbuf) || !match(cb->mask, ipbuf)))
            return n;
        if (cb->mask[0] == '~')
        {
            p = cb->mask + 1;
            exttype = *p++;
            if (exttype == '\0')
                continue;
            /* check parameter */
            if (*p++ != ':')
                p = NULL;
            switch (exttype)
            {
            case 'a':
                matched = u->myuser != NULL && !(u->myuser->flags & MU_WAITAUTH) && (p == NULL || !match(p, entity(u->myuser)->name));
                break;
            case 'c':
                if (p == NULL)
                    continue;
                target_c = channel_find(p);
                if (target_c == NULL || (target_c->modes & (CMODE_PRIV | CMODE_SEC)))
                    continue;
                matched = chanuser_find(target_c, u) != NULL;
                break;
            case 'r':
                if (p == NULL)
                    continue;
                matched = !match(p, u->gecos);
                break;
            case 'R':
                matched = should_reg_umode(u);
                break;
            case 'q':
                matched = !match(p, hostbuf) || !match(p, ipbuf);
                break;
            default:
                continue;
            }
            if (matched)
                return n;
        }
    }