Ejemplo n.º 1
0
static void ns_cmd_acc(char *origin)
{
	char *targ = strtok(NULL, " ");
	user_t *u;

	if (!targ)
		u = user_find_named(origin);
	else
		u = user_find_named(targ);

	if (!u)
	{
		notice(nicksvs.nick, origin, "User not online.");
		return;
	}

	logcommand(nicksvs.me, user_find_named(origin), CMDLOG_GET, "ACC %s", u->nick);

	if (!u->myuser)
	{
		notice(nicksvs.nick, origin, "%s ACC 0", u->nick);
		return;
	}
	else
		notice(nicksvs.nick, origin, "%s ACC 3", u->nick);
}
Ejemplo n.º 2
0
static void cs_cmd_hold(char *origin)
{
	char *target = strtok(NULL, " ");
	char *action = strtok(NULL, " ");
	mychan_t *mc;

	if (!target || !action)
	{
		notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "HOLD");
		notice(chansvs.nick, origin, "Usage: HOLD <#channel> <ON|OFF>");
		return;
	}

	if (*target != '#')
	{
		notice(chansvs.nick, origin, STR_INVALID_PARAMS, "HOLD");
		return;
	}

	if (!(mc = mychan_find(target)))
	{
		notice(chansvs.nick, origin, "\2%s\2 is not registered.", target);
		return;
	}
	
	if (!strcasecmp(action, "ON"))
	{
		if (mc->flags & MC_HOLD)
		{
			notice(chansvs.nick, origin, "\2%s\2 is already held.", target);
			return;
		}

		mc->flags |= MC_HOLD;

		wallops("%s set the HOLD option for the channel \2%s\2.", origin, target);
		logcommand(chansvs.me, user_find_named(origin), CMDLOG_ADMIN, "%s HOLD ON", mc->name);
		notice(chansvs.nick, origin, "\2%s\2 is now held.", target);
	}
	else if (!strcasecmp(action, "OFF"))
	{
		if (!(mc->flags & MC_HOLD))
		{
			notice(chansvs.nick, origin, "\2%s\2 is not held.", target);
			return;
		}

		mc->flags &= ~MC_HOLD;

		wallops("%s removed the HOLD option on the channel \2%s\2.", origin, target);
		logcommand(chansvs.me, user_find_named(origin), CMDLOG_ADMIN, "%s HOLD OFF", mc->name);
		notice(chansvs.nick, origin, "\2%s\2 is no longer held.", target);
	}
	else
	{
		notice(chansvs.nick, origin, STR_INVALID_PARAMS, "HOLD");
		notice(chansvs.nick, origin, "Usage: HOLD <#channel> <ON|OFF>");
	}
}
Ejemplo n.º 3
0
static void cs_cmd_devoice(sourceinfo_t *si, int parc, char *parv[])
{
	char *chan = parv[0];
	char *nick = parv[1];
	mychan_t *mc;
	user_t *tu;
	chanuser_t *cu;

	if (!chan)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "DEVOICE");
		command_fail(si, fault_needmoreparams, _("Syntax: DEVOICE <#channel> [nickname]"));
		return;
	}

	mc = mychan_find(chan);
	if (!mc)
	{
		command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan);
		return;
	}

	if (!chanacs_source_has_flag(mc, si, CA_VOICE))
	{
		command_fail(si, fault_noprivs, _("You are not authorized to perform this operation."));
		return;
	}

	/* figure out who we're going to devoice */
	if (!nick)
		tu = si->su;
	else
	{
		if (!(tu = user_find_named(nick)))
		{
			command_fail(si, fault_nosuch_target, _("\2%s\2 is not online."), nick);
			return;
		}
	}

	if (is_internal_client(tu))
		return;

	cu = chanuser_find(mc->chan, tu);
	if (!cu)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is not on \2%s\2."), tu->nick, mc->name);
		return;
	}

	modestack_mode_param(chansvs.nick, mc->chan, MTYPE_DEL, 'v', CLIENT_NAME(tu));
	cu->modes &= ~CSTATUS_VOICE;

	if (si->c == NULL && tu != si->su)
		change_notify(chansvs.nick, tu, "You have been devoiced on %s by %s", mc->name, get_source_name(si));

	logcommand(si, CMDLOG_DO, "DEVOICE: \2%s!%s@%s\2 on \2%s\2", tu->nick, tu->user, tu->vhost, mc->name);
	if (!chanuser_find(mc->chan, si->su))
		command_success_nodata(si, _("\2%s\2 has been devoiced on \2%s\2."), tu->nick, mc->name);
}
Ejemplo n.º 4
0
/* HELP <command> [params] */
static void os_cmd_help(char *origin)
{
	char *command = strtok(NULL, "");

	if (!has_any_privs(user_find_named(origin)))
	{
		notice(opersvs.nick, origin, "You are not authorized to use %s.", opersvs.nick);
		return;
	}

	if (!command)
	{
		notice(opersvs.nick, origin, "***** \2%s Help\2 *****", opersvs.nick);
		notice(opersvs.nick, origin, "\2%s\2 provides essential network management services, such as", opersvs.nick);
		notice(opersvs.nick, origin, "routing manipulation and access restriction. Please do not abuse");
		notice(opersvs.nick, origin, "your access to \2%s\2!", opersvs.nick);
		notice(opersvs.nick, origin, " ");
		notice(opersvs.nick, origin, "For information on a command, type:");
		notice(opersvs.nick, origin, "\2/%s%s help <command>\2", (ircd->uses_rcommand == FALSE) ? "msg " : "", opersvs.disp);
		notice(opersvs.nick, origin, " ");

		command_help(opersvs.nick, origin, os_cmdtree);

		notice(opersvs.nick, origin, "***** \2End of Help\2 *****", opersvs.nick);
		return;
	}

	/* take the command through the hash table */
	help_display(opersvs.nick, opersvs.disp, origin, command, os_helptree);
}
Ejemplo n.º 5
0
static void ns_cmd_status(char *origin)
{
	user_t *u = user_find_named(origin);

	logcommand(nicksvs.me, u, CMDLOG_GET, "STATUS");

	if (!u->myuser)
	{
		notice(nicksvs.nick, origin, "You are not logged in.");
		return;
	}

	notice(nicksvs.nick, origin, "You are logged in as \2%s\2.", u->myuser->name);

	if (is_soper(u->myuser))
	{
		operclass_t *operclass;

		operclass = u->myuser->soper->operclass;
		if (operclass == NULL)
			notice(nicksvs.nick, origin, "You are a services root administrator.");
		else
			notice(nicksvs.nick, origin, "You are a services operator of class %s.", operclass->name);
	}

	if (is_admin(u))
		notice(nicksvs.nick, origin, "You are a server administrator.");

	if (is_ircop(u))
		notice(nicksvs.nick, origin, "You are an IRC operator.");
}
Ejemplo n.º 6
0
static void cs_fcmd_topicappend(char *origin, char *chan)
{
        char *topic = strtok(NULL, "");
        mychan_t *mc;
        user_t *u = user_find_named(origin);
        char topicbuf[BUFSIZE];
        channel_t *c;

        if (!topic)
        {
                notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "!TOPICAPPEND");
                notice(chansvs.nick, origin, "Syntax: !TOPICAPPEND <topic>");
                return;
        }

        c = channel_find(chan);
        if (!c)
        {
                notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan);
                return;
        }

        mc = mychan_find(chan);
        if (!mc)
        {
                notice(chansvs.nick, origin, "Channel \2%s\2 is not registered.", chan);
                return;
        }

        if (!chanacs_user_has_flag(mc, u, CA_TOPIC))
        {
                notice(chansvs.nick, origin, "You are not authorized to perform this operation.");
                return;
        }
        
        if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer"))
	{
		notice(chansvs.nick, origin, "\2%s\2 is closed.", chan);
		return;
	}

        topicbuf[0] = '\0';

        if (c->topic)
        {
                strlcpy(topicbuf, c->topic, BUFSIZE);
                strlcat(topicbuf, " | ", BUFSIZE);
                strlcat(topicbuf, topic, BUFSIZE);
        }
        else
                strlcpy(topicbuf, topic, BUFSIZE);

	handle_topic(c, origin, CURRTIME, topicbuf);
        topic_sts(chan, origin, CURRTIME, topicbuf);

	logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPICAPPEND", mc->name);
}
Ejemplo n.º 7
0
Archivo: status.c Proyecto: hce/zohlai
static void ns_cmd_acc(sourceinfo_t *si, int parc, char *parv[])
{
    const char *targuser = parv[0];
    const char *targaccount = parv[1];
    user_t *u;
    myuser_t *mu;
    mynick_t *mn;
    bool show_id = config_options.show_entity_id || has_priv(si, PRIV_USER_AUSPEX);

    if (!targuser)
    {
        u = si->su;
        targuser = u != NULL ? u->nick : "?";
    }
    else
        u = user_find_named(targuser);

    if (!u)
    {
        command_fail(si, fault_nosuch_target, _("%s%s%s ACC 0 (offline)"), targuser, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : "");
        return;
    }

    if (!targaccount)
        targaccount = u->nick;
    if (!strcmp(targaccount, "*"))
        mu = u->myuser;
    else
        mu = myuser_find_ext(targaccount);

    if (!mu)
    {
        command_fail(si, fault_nosuch_target, _("%s%s%s ACC 0 (not registered)"), u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : "");
        return;
    }

    if (u->myuser == mu)
        command_success_nodata(si, "%s%s%s ACC 3 %s",
                               u->nick,
                               parc >= 2 ? " -> " : "",
                               parc >= 2 ? entity(mu)->name : "",
                               show_id ? entity(mu)->id : "");
    else if ((mn = mynick_find(u->nick)) != NULL && mn->owner == mu &&
             myuser_access_verify(u, mu))
        command_success_nodata(si, "%s%s%s ACC 2 %s",
                               u->nick,
                               parc >= 2 ? " -> " : "",
                               parc >= 2 ? entity(mu)->name : "",
                               show_id ? entity(mu)->id : "");
    else
        command_success_nodata(si, "%s%s%s ACC 1 %s",
                               u->nick,
                               parc >= 2 ? " -> " : "",
                               parc >= 2 ? entity(mu)->name : "",
                               show_id ? entity(mu)->id : "");
}
Ejemplo n.º 8
0
static void cs_cmd_drop(char *origin)
{
	user_t *u = user_find_named(origin);
	mychan_t *mc;
	char *name = strtok(NULL, " ");

	if (!name)
	{
		notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "DROP");
		notice(chansvs.nick, origin, "Syntax: DROP <#channel>");
		return;
	}

	if (*name != '#')
	{
		notice(chansvs.nick, origin, STR_INVALID_PARAMS, "DROP");
		notice(chansvs.nick, origin, "Syntax: DROP <#channel>");
		return;
	}

	if (!(mc = mychan_find(name)))
	{
		notice(chansvs.nick, origin, "\2%s\2 is not registered.", name);
		return;
	}

	if (!is_founder(mc, u->myuser) && !has_priv(u, PRIV_CHAN_ADMIN))
	{
		notice(chansvs.nick, origin, "You are not authorized to perform this operation.");
		return;
	}

	if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer") && !has_priv(u, PRIV_CHAN_ADMIN))
	{
		logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name);
		notice(chansvs.nick, origin, "The channel \2%s\2 is closed; it cannot be dropped.", mc->name);
		return;
	}

	if (!is_founder(mc, u->myuser))
	{
		logcommand(chansvs.me, u, CMDLOG_ADMIN, "%s DROP", mc->name);
		wallops("%s dropped the channel \2%s\2", origin, name);
	}
	else
		logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s DROP", mc->name);

	snoop("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, u->nick, u->myuser->name);

	hook_call_event("channel_drop", mc);
	if ((config_options.chan && irccasecmp(mc->name, config_options.chan)) || !config_options.chan)
		part(mc->name, chansvs.nick);
	mychan_delete(mc->name);
	notice(chansvs.nick, origin, "The channel \2%s\2 has been dropped.", name);
	return;
}
Ejemplo n.º 9
0
static void m_mode(sourceinfo_t *si, int parc, char *parv[])
{
	user_t *u;
	char *p;

	if (*parv[0] == '#')
		channel_mode(NULL, channel_find(parv[0]), parc - 1, &parv[1]);
	else
	{
		/* Yes this is a nick and not a UID -- jilles */
		u = user_find_named(parv[0]);
		if (u == NULL)
		{
			slog(LG_DEBUG, "m_mode(): user mode for unknown user %s", parv[0]);
			return;
		}
		user_mode(u, parv[1]);
		if (strchr(parv[1], 'x'))
		{
			u->flags |= UF_HIDEHOSTREQ;
			check_hidehost(u);
		}
		if (strchr(parv[1], 'h'))
		{
			if (parc > 2)
			{
				/* assume +h */
				p = strchr(parv[2], '@');
				if (p == NULL)
					strlcpy(u->vhost, parv[2], sizeof u->vhost);
				else
				{
					strlcpy(u->vhost, p + 1, sizeof u->vhost);
					strlcpy(u->user, parv[2], sizeof u->user);
					p = strchr(u->user, '@');
					if (p != NULL)
						*p = '\0';
				}
				slog(LG_DEBUG, "m_mode(): user %s setting vhost %s@%s", u->nick, u->user, u->vhost);
			}
			else
			{
				/* must be -h */
				/* XXX we don't know the original ident */
				slog(LG_DEBUG, "m_mode(): user %s turning off vhost", u->nick);
				strlcpy(u->vhost, u->host, sizeof u->vhost);
				/* revert to +x vhost if applicable */
				check_hidehost(u);
			}
		}
	}
}
Ejemplo n.º 10
0
static void os_cmd_restart(char *origin)
{
	snoop("UPDATE: \2%s\2", origin);
	wallops("Updating database by request of \2%s\2.", origin);
	expire_check(NULL);
	db_save(NULL);

	logcommand(opersvs.me, user_find_named(origin), CMDLOG_ADMIN, "RESTART");
	snoop("RESTART: \2%s\2", origin);
	wallops("Restarting by request of \2%s\2.", origin);

	runflags |= RF_RESTART;
}
Ejemplo n.º 11
0
static void cs_cmd_topic(char *origin)
{
	char *chan = strtok(NULL, " ");
	char *topic = strtok(NULL, "");
	mychan_t *mc;
	channel_t *c;
	user_t *u;

	if (!chan || !topic)
	{
		notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "TOPIC");
		notice(chansvs.nick, origin, "Syntax: TOPIC <#channel> <topic>");
		return;
	}

	c = channel_find(chan);
	if (!c)
	{
                notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan);
                return;
        }

	mc = mychan_find(chan);
	if (!mc)
	{
		notice(chansvs.nick, origin, "Channel \2%s\2 is not registered.", chan);
		return;
	}
	
	if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer"))
	{
		notice(chansvs.nick, origin, "\2%s\2 is closed.", chan);
		return;
	}

	u = user_find_named(origin);

	if (!chanacs_user_has_flag(mc, u, CA_TOPIC))
	{
		notice(chansvs.nick, origin, "You are not authorized to perform this operation.");
		return;
	}

	handle_topic(c, origin, CURRTIME, topic);
	topic_sts(chan, origin, CURRTIME, topic);

	logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPIC", mc->name);
	if (!chanuser_find(c, u))
		notice(chansvs.nick, origin, "Topic set to \2%s\2 on \2%s\2.", topic, chan);
}
Ejemplo n.º 12
0
static void bs_cmd_act(sourceinfo_t *si, int parc, char *parv[])
{
	char *channel = parv[0];
	char *message = parv[1];
	metadata_t *bs;
	user_t *bot;

	if (!channel || !message)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "ACT");
		command_fail(si, fault_needmoreparams, _("Syntax: ACT <#channel> <msg>"));
		return;
	}

	channel_t *c = channel_find(channel);
	mychan_t *mc = mychan_find(channel);

	if (!mc)
	{
		command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), channel);
		return;
	}

	if (!c)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is currently empty."), channel);
		return;
	}

	if (!(chanacs_source_flags(mc, si) & (CA_OP | CA_AUTOOP)))
	{
		command_fail(si, fault_noprivs, STR_NOT_AUTHORIZED);
		return;
	}

	if ((bs = metadata_find(mc, "private:botserv:bot-assigned")) != NULL)
		bot = user_find_named(bs->value);
	else
		bot = NULL;
	if (bot == NULL)
	{
		command_fail(si, fault_nosuch_key, _("\2%s\2 does not have a bot assigned."), mc->name);
		return;
	}

	msg(bot->nick, channel, "\001ACTION %s\001", message);
	logcommand(si, CMDLOG_DO, "ACT:\2%s\2: \2%s\2", channel, message);
}
Ejemplo n.º 13
0
static void make_forbid(sourceinfo_t *si, const char *account, const char *reason)
{
	myuser_t *mu;
	mynick_t *mn = NULL;
	user_t *u;

	if (!nicksvs.no_nick_ownership && IsDigit(*account))
	{
		command_fail(si, fault_badparams, "For security reasons, you can't forbid a UID.");
		return;
	}

	if (strchr(account, ' ') || strchr(account, '\n') || strchr(account, '\r') || account[0] == '=' || account[0] == '#' || account[0] == '@' || account[0] == '+' || account[0] == '%' || account[0] == '!' || strchr(account, ','))
	{
		command_fail(si, fault_badparams, "The account name \2%s\2 is invalid.", account);
		return;
	}

	/* make sure it isn't registered already */
	if (nicksvs.no_nick_ownership ? myuser_find(account) != NULL : mynick_find(account) != NULL)
	{
		command_fail(si, fault_alreadyexists, "\2%s\2 is already registered.", account);
		return;
	}

	mu = myuser_add(account, "*", FORBID_EMAIL, MU_CRYPTPASS | MU_ENFORCE | MU_HOLD | MU_NOBURSTLOGIN);
	mu->registered = CURRTIME;
	mu->lastlogin = CURRTIME;
	metadata_add(mu, "private:freeze:freezer", get_oper_name(si));
	metadata_add(mu, "private:freeze:reason", reason);
	metadata_add(mu, "private:freeze:timestamp", number_to_string(CURRTIME));
	if (!nicksvs.no_nick_ownership)
	{
		mn = mynick_add(mu, entity(mu)->name);
		mn->registered = CURRTIME;
		mn->lastseen = CURRTIME;
		u = user_find_named(entity(mu)->name);
		if (u != NULL)
		{
			notice(si->service->nick, u->nick,
					_("The nick \2%s\2 is now forbidden."),
					entity(mu)->name);
			hook_call_nick_enforce((&(hook_nick_enforce_t){ .u = u, .mn = mn }));
static void _ls_chocobo(sourceinfo_t *si, int parc, char *parv[])	/* silly */
{
	char *target = parv[0];

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "CHOCOBO");
		command_fail(si, fault_needmoreparams, "Syntax: CHOCOBO <target>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "Your chocobo has been sent to %s.", target);
	notice(loveserv->nick, target, "%s would like you to have this chocobo. \00308Kweh!\003", si->su->nick);
}
static void _ls_spank(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "SPANK");
		command_fail(si, fault_needmoreparams, "Syntax: SPANK <target>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "You have virtually spanked %s!", target);
	notice(loveserv->nick, target, "%s has given you a virtual playful spanking.", si->su->nick);
}
static void _ls_admirer(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "ADMIRER");
		command_fail(si, fault_needmoreparams, "Syntax: ADMIRER <target>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "%s has been told that they have a secret admirer. :)", target);
	notice(loveserv->nick, target, "You have a secret admirer ;)");
}
static void _ls_kiss(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "KISS");
		command_fail(si, fault_needmoreparams, "Syntax: KISS <target>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "You have virtually kissed %s!", target);
	notice(loveserv->nick, target, "%s has sent you a \00304kiss\003.", si->su->nick);
}
static void _ls_candy(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "CANDY");
		command_fail(si, fault_needmoreparams, "Syntax: CANDY <target>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "Your bag of candy has been sent to %s! :)", target);
	notice(loveserv->nick, target, "%s would like you to have this bag of heart-shaped candies.", si->su->nick);
}
static void _ls_rose(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "ROSE");
		command_fail(si, fault_needmoreparams, "Syntax: ROSE <target>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "Your rose has been sent to %s! :)", target);
	notice(loveserv->nick, target, "%s has sent you a pretty rose: \00303--<--<--<{\00304@", si->su->nick);
}
static void _ls_thankyou(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];
	char *note = parv[1];

	if (!target || !note)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "THANKYOU");
		command_fail(si, fault_needmoreparams, "Syntax: THANKYOU <target> <message>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "Your thank-you note to %s has been sent.", target);
	notice(loveserv->nick, target, "%s would like to thank you for: %s", si->su->nick, note);
}
static void _ls_lovenote(sourceinfo_t *si, int parc, char *parv[])
{
	char *target = parv[0];
	char *note = parv[1];

	if (!target || !note)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "LOVENOTE");
		command_fail(si, fault_needmoreparams, "Syntax: LOVENOTE <target> <message>");
		return;
	}

	if (!user_find_named(target))
	{
		command_fail(si, fault_nosuch_target, "As much as I'd love to do this, you need to specify a person who really exists!");
		return;
	}

	command_success_nodata(si, "Your love-note to %s has been sent.", target);
	notice(loveserv->nick, target, "%s has sent you a love-note which reads: %s", si->su->nick, note);
}
Ejemplo n.º 22
0
/* HELP <command> [params] */
void ms_cmd_help(char *origin)
{
	user_t *u = user_find_named(origin);
	char *command = strtok(NULL, "");

	if (!command)
	{
		notice(memosvs.nick, origin, "***** \2%s Help\2 *****", memosvs.nick);
		notice(memosvs.nick, origin, "\2%s\2 allows users to send memos to registered users.", memosvs.nick);
		notice(memosvs.nick, origin, " ");
		notice(memosvs.nick, origin, "For more information on a command, type:");
		notice(memosvs.nick, origin, "\2/%s%s help <command>\2", (ircd->uses_rcommand == FALSE) ? "msg " : "", memosvs.disp);
		notice(memosvs.nick, origin, " ");

		command_help(memosvs.nick, origin, ms_cmdtree);

		notice(memosvs.nick, origin, "***** \2End of Help\2 *****");
		return;
	}

	/* take the command through the hash table */
	help_display(memosvs.nick, memosvs.disp, origin, command, ms_helptree);
}
Ejemplo n.º 23
0
static void m_mode(sourceinfo_t *si, int parc, char *parv[])
{
	user_t *u;

	if (*parv[0] == '#')
		channel_mode(NULL, channel_find(parv[0]), parc - 1, &parv[1]);
	else
	{
		/* Yes this is a nick and not a UID -- jilles */
		u = user_find_named(parv[0]);
		if (u == NULL)
		{
			slog(LG_DEBUG, "m_mode(): user mode for unknown user %s", parv[0]);
			return;
		}
		user_mode(u, parv[1]);
		if (strchr(parv[1], 'x'))
		{
			u->flags |= UF_HIDEHOSTREQ;
			check_hidehost(u);
		}
	}
}
Ejemplo n.º 24
0
static void nick_ungroup(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 && !nicksvs.no_nick_ownership)
		sts(":%s ENCAP * IDENTIFIED %s %s OFF", ME, CLIENT_NAME(u), u->nick);
}
Ejemplo n.º 25
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);
}
Ejemplo n.º 26
0
static void ns_cmd_freeze(char *origin)
{
	myuser_t *mu;
	user_t *source = user_find_named(origin);
	char *target = strtok(NULL, " ");
	char *action = strtok(NULL, " ");
	char *reason = strtok(NULL, "");

	if (source == NULL)
		return;

	if (!target || !action)
	{
		notice(nicksvs.nick, origin, STR_INSUFFICIENT_PARAMS, "FREEZE");
		notice(nicksvs.nick, origin, "Usage: FREEZE <username> <ON|OFF> [reason]");
		return;
	}

	mu = myuser_find_ext(target);

	if (!mu)
        {
                notice(nicksvs.nick, origin, "\2%s\2 is not a registered nickname.", target);
                return;
        }

	if (!strcasecmp(action, "ON"))
	{
		if (!reason)
		{
			notice(nicksvs.nick, origin, STR_INSUFFICIENT_PARAMS, "FREEZE");
			notice(nicksvs.nick, origin, "Usage: FREEZE <username> ON <reason>");
			return;
		}

	if (is_soper(mu))
	{
                notice(nicksvs.nick, origin, "The nickname \2%s\2 belongs to a services operator; it cannot be frozen.", target);
		return;
	}


		if (metadata_find(mu, METADATA_USER, "private:freeze:freezer"))
		{
			notice(nicksvs.nick, origin, "\2%s\2 is already frozen.", target);
			return;
		}

		metadata_add(mu, METADATA_USER, "private:freeze:freezer", origin);
		metadata_add(mu, METADATA_USER, "private:freeze:reason", reason);
		metadata_add(mu, METADATA_USER, "private:freeze:timestamp", itoa(CURRTIME));

		wallops("%s froze the nickname \2%s\2 (%s).", origin, target, reason);
		logcommand(nicksvs.me, source, CMDLOG_ADMIN, "FREEZE %s ON", target);
		notice(nicksvs.nick, origin, "\2%s\2 is now frozen.", target);
	}
	else if (!strcasecmp(action, "OFF"))
	{
		if (!metadata_find(mu, METADATA_USER, "private:freeze:freezer"))
		{
			notice(nicksvs.nick, origin, "\2%s\2 is not frozen.", target);
			return;
		}

		metadata_delete(mu, METADATA_USER, "private:freeze:freezer");
		metadata_delete(mu, METADATA_USER, "private:freeze:reason");
		metadata_delete(mu, METADATA_USER, "private:freeze:timestamp");

		wallops("%s thawed the nickname \2%s\2.", origin, target);
		logcommand(nicksvs.me, source, CMDLOG_ADMIN, "FREEZE %s OFF", target);
		notice(nicksvs.nick, origin, "\2%s\2 has been thawed", target);
	}
	else
	{
		notice(nicksvs.nick, origin, STR_INSUFFICIENT_PARAMS, "FREEZE");
		notice(nicksvs.nick, origin, "Usage: FREEZE <account> <ON|OFF> [reason]");
	}
}
Ejemplo n.º 27
0
void ns_cmd_regain(sourceinfo_t *si, int parc, char *parv[])
{
	myuser_t *mu;
	char *target = parv[0];
	char *password = parv[1];
	user_t *target_u;
	mynick_t *mn;

	if (si->su == NULL)
	{
		command_fail(si, fault_noprivs, _("\2%s\2 can only be executed via IRC."), "REGAIN");
		return;
	}

	if (!target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "REGAIN");
		command_fail(si, fault_needmoreparams, _("Syntax: REGAIN <target> [password]"));
		return;
	}

	if (nicksvs.no_nick_ownership)
		mn = NULL, mu = myuser_find(target);
	else
	{
		mn = mynick_find(target);
		mu = mn != NULL ? mn->owner : NULL;
	}
	target_u = user_find_named(target);
	if (!mu)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is not a registered nickname."), target);
		return;
	}

	if (!target_u)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is not online."), target);
		return;
	}
	else if (target_u == si->su)
	{
		command_fail(si, fault_badparams, _("You may not ghost yourself."));
		return;
	}

	if ((!nicksvs.no_nick_ownership && mn && mu == si->smu) || /* we're identified under their nick's account */
			(!nicksvs.no_nick_ownership && password && mn && verify_password(mu, password))) /* we have their nick's password */
	{
		logcommand(si, CMDLOG_DO, "REGAIN %s!%s@%s", target_u->nick, target_u->user, target_u->vhost);

		kill_user(si->service->me, target_u, "REGAIN command used by %s",
				si->su != NULL && !strcmp(si->su->user, target_u->user) && !strcmp(si->su->vhost, target_u->vhost) ? si->su->nick : get_source_mask(si));

		command_success_nodata(si, _("\2%s\2 has been regained."), target);
		fnc_sts(si->service->me, si->su, target, FNC_REGAIN);

		/* don't update the nick's last seen time */
		mu->lastlogin = CURRTIME;

		return;
	}

	if (password && mu)
	{
		logcommand(si, CMDLOG_DO, "failed REGAIN %s (bad password)", target);
		command_fail(si, fault_authfail, _("Invalid password for \2%s\2."), mu->name);
	}
	else
	{
		logcommand(si, CMDLOG_DO, "failed REGAIN %s (invalid login)", target);
		command_fail(si, fault_noprivs, _("You may not regain \2%s\2."), target);
	}
}
Ejemplo n.º 28
0
static void cs_cmd_ban(sourceinfo_t *si, int parc, char *parv[])
{
	char *channel = parv[0];
	char *target = parv[1];
	char *newtarget;
	channel_t *c = channel_find(channel);
	mychan_t *mc = mychan_find(channel);
	user_t *tu;

	if (!channel || !target)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "BAN");
		command_fail(si, fault_needmoreparams, _("Syntax: BAN <#channel> <nickname|hostmask>"));
		return;
	}

	if (!mc)
	{
		command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), channel);
		return;
	}

	if (!c)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is currently empty."), channel);
		return;
	}

	if (!chanacs_source_has_flag(mc, si, CA_REMOVE))
	{
		command_fail(si, fault_noprivs, STR_NOT_AUTHORIZED);
		return;
	}

	if (metadata_find(mc, "private:close:closer"))
	{
		command_fail(si, fault_noprivs, _("\2%s\2 is closed."), channel);
		return;
	}

	if ((tu = user_find_named(target)))
	{
		char hostbuf[BUFSIZE];

		hostbuf[0] = '\0';

		mowgli_strlcat(hostbuf, "*!*@", BUFSIZE);
		mowgli_strlcat(hostbuf, tu->vhost, BUFSIZE);

		modestack_mode_param(chansvs.nick, c, MTYPE_ADD, 'b', hostbuf);
		chanban_add(c, hostbuf, 'b');
		logcommand(si, CMDLOG_DO, "BAN: \2%s\2 on \2%s\2 (for user \2%s!%s@%s\2)", hostbuf, mc->name, tu->nick, tu->user, tu->vhost);
		if (si->su == NULL || !chanuser_find(mc->chan, si->su))
			command_success_nodata(si, _("Banned \2%s\2 on \2%s\2."), target, channel);
		return;
	}
	else if ((is_extban(target) && (newtarget = target)) || ((newtarget = pretty_mask(target)) && validhostmask(newtarget)))
	{
		modestack_mode_param(chansvs.nick, c, MTYPE_ADD, 'b', newtarget);
		chanban_add(c, newtarget, 'b');
		logcommand(si, CMDLOG_DO, "BAN: \2%s\2 on \2%s\2", newtarget, mc->name);
		if (si->su == NULL || !chanuser_find(mc->chan, si->su))
			command_success_nodata(si, _("Banned \2%s\2 on \2%s\2."), newtarget, channel);
		return;
	}
	else
	{
		command_fail(si, fault_badparams, _("Invalid nickname/hostmask provided: \2%s\2"), target);
		command_fail(si, fault_badparams, _("Syntax: BAN <#channel> <nickname|hostmask>"));
		return;
	}
}
Ejemplo n.º 29
0
static void cs_cmd_unban(sourceinfo_t *si, int parc, char *parv[])
{
        const char *channel = parv[0];
        const char *target = parv[1];
        channel_t *c = channel_find(channel);
	mychan_t *mc = mychan_find(channel);
	user_t *tu;
	chanban_t *cb;

	if (!channel)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "UNBAN");
		command_fail(si, fault_needmoreparams, _("Syntax: UNBAN <#channel> <nickname|hostmask>"));
		return;
	}

	if (!target)
	{
		if (si->su == NULL)
		{
			command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "UNBAN");
			command_fail(si, fault_needmoreparams, _("Syntax: UNBAN <#channel> <nickname|hostmask>"));
			return;
		}
		target = si->su->nick;
	}

	if (!mc)
	{
		command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), channel);
		return;
	}

	if (!c)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is currently empty."), channel);
		return;
	}

	if (!chanacs_source_has_flag(mc, si, CA_REMOVE) &&
			(si->su == NULL ||
			 !chanacs_source_has_flag(mc, si, CA_EXEMPT) ||
			 irccasecmp(target, si->su->nick)))
	{
		command_fail(si, fault_noprivs, STR_NOT_AUTHORIZED);
		return;
	}

	if ((tu = user_find_named(target)))
	{
		mowgli_node_t *n, *tn;
		char hostbuf2[BUFSIZE];
		int count = 0;

		snprintf(hostbuf2, BUFSIZE, "%s!%s@%s", tu->nick, tu->user, tu->vhost);
		for (n = next_matching_ban(c, tu, 'b', c->bans.head); n != NULL; n = next_matching_ban(c, tu, 'b', tn))
		{
			tn = n->next;
			cb = n->data;

			logcommand(si, CMDLOG_DO, "UNBAN: \2%s\2 on \2%s\2 (for user \2%s\2)", cb->mask, mc->name, hostbuf2);
			modestack_mode_param(chansvs.nick, c, MTYPE_DEL, cb->type, cb->mask);
			chanban_delete(cb);
			count++;
		}
		if (count > 0)
			command_success_nodata(si, _("Unbanned \2%s\2 on \2%s\2 (%d ban%s removed)."),
				target, channel, count, (count != 1 ? "s" : ""));
		else
			command_success_nodata(si, _("No bans found matching \2%s\2 on \2%s\2."), target, channel);
		return;
	}
	else if ((cb = chanban_find(c, target, 'b')) != NULL || validhostmask(target))
	{
		if (cb)
		{
			modestack_mode_param(chansvs.nick, c, MTYPE_DEL, 'b', target);
			chanban_delete(cb);
			logcommand(si, CMDLOG_DO, "UNBAN: \2%s\2 on \2%s\2", target, mc->name);
			if (si->su == NULL || !chanuser_find(mc->chan, si->su))
				command_success_nodata(si, _("Unbanned \2%s\2 on \2%s\2."), target, channel);
		}
		else
			command_fail(si, fault_nosuch_key, _("No such ban \2%s\2 on \2%s\2."), target, channel);

		return;
	}
        else
        {
		command_fail(si, fault_badparams, _("Invalid nickname/hostmask provided: \2%s\2"), target);
		command_fail(si, fault_badparams, _("Syntax: UNBAN <#channel> [nickname|hostmask]"));
		return;
        }
}
Ejemplo n.º 30
0
static void cs_cmd_kick(sourceinfo_t *si, int parc, char *parv[])
{
	char *chan = parv[0];
	char *nick = parv[1];
	char *reason = parv[2];
	mychan_t *mc;
	user_t *tu;
	chanuser_t *cu;
	char reasonbuf[BUFSIZE];

	if (!chan || !nick)
	{
		command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "KICK");
		command_fail(si, fault_needmoreparams, _("Syntax: KICK <#channel> <nickname> [reason]"));
		return;
	}

	mc = mychan_find(chan);
	if (!mc)
	{
		command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan);
		return;
	}

	if (!chanacs_source_has_flag(mc, si, CA_REMOVE))
	{
		command_fail(si, fault_noprivs, _("You are not authorized to perform this operation."));
		return;
	}
	
	if (metadata_find(mc, "private:close:closer"))
	{
		command_fail(si, fault_noprivs, _("\2%s\2 is closed."), chan);
		return;
	}

	/* figure out who we're going to kick */
	if (!(tu = user_find_named(nick)))
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is not online."), nick);
		return;
	}

	/* if target is a service, bail. --nenolod */
	if (is_internal_client(tu))
		return;

	cu = chanuser_find(mc->chan, tu);
	if (!cu)
	{
		command_fail(si, fault_nosuch_target, _("\2%s\2 is not on \2%s\2."), tu->nick, mc->name);
		return;
	}

	if (cu->modes & CSTATUS_OWNER || cu->modes & CSTATUS_PROTECT)
	{
		command_fail(si, fault_noprivs, _("\2%s\2 is protected from kicks; you cannot kick them."), tu->nick);
		return;
	}

	snprintf(reasonbuf, BUFSIZE, "(%s) %s", get_source_name(si), reason ? reason : "No reason given");
	try_kick(chansvs.me->me, mc->chan, tu, reasonbuf);
	logcommand(si, CMDLOG_DO, "KICK: \2%s!%s@%s\2 from \2%s\2", tu->nick, tu->user, tu->vhost, mc->name);
	if (si->su != tu && !chanuser_find(mc->chan, si->su))
		command_success_nodata(si, _("\2%s\2 has been kicked from \2%s\2."), tu->nick, mc->name);
}