Beispiel #1
0
/*
 * Note: At least at protocol level ERROR has only one parameter,
 * although this is called internally from other functions
 * --msa
 *
 *      parv[0] = sender prefix
 *      parv[*] = parameters
 */
int
m_error(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	const char *para;
	para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";

	if(IsAnyServer(client_p))
	{
		ilog(L_SERVER, "Received ERROR message from %s: %s",
		     log_client_name(source_p, SHOW_IP), para);
	}

	if(IsAnyServer(client_p) && ConfigFileEntry.hide_error_messages < 2)
	{
		sendto_realops_flags(UMODE_ALL, L_ADMIN,
				     "ERROR :from %s -- %s",
				     EmptyString(client_p->name) ? "" : client_p->name, para);

		if(!ConfigFileEntry.hide_error_messages)
			sendto_realops_flags(UMODE_ALL, L_OPER,
					     "ERROR :from %s -- %s",
					     EmptyString(client_p->name) ? "" : client_p->name,
					     para);
	}

	exit_client(client_p, source_p, source_p, "ERROR");

	return 0;
}
Beispiel #2
0
/*
 * Note: At least at protocol level ERROR has only one parameter,
 * although this is called internally from other functions
 * --msa
 *
 *      parv[*] = parameters
 */
static void
m_error(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	const char *para;
	int hideit = ConfigFileEntry.hide_error_messages;

	para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";

	if (IsAnyServer(client_p))
	{
		ilog(L_SERVER, "Received ERROR message from %s: %s",
		     log_client_name(source_p, SHOW_IP), para);
	}

	if(is_safe_error(para))
		hideit = 0;
	if(IsAnyServer(client_p))
	{
		if (hideit < 2)
			sendto_realops_snomask(SNO_GENERAL, hideit ? L_ADMIN : (is_remote_connect(client_p) ? L_NETWIDE : L_ALL),
					"ERROR :from %s -- %s",
					client_p->name, para);
		if (hideit > 0)
			sendto_realops_snomask(SNO_GENERAL, (hideit == 1 ? L_OPER : L_ALL) | (is_remote_connect(client_p) ? L_NETWIDE : L_ALL),
					"ERROR :from %s -- <hidden>",
					client_p->name);
	}

	exit_client(client_p, source_p, source_p, "ERROR");
}
Beispiel #3
0
/*
 * Note: At least at protocol level ERROR has only one parameter,
 * although this is called internally from other functions
 * --msa
 *
 *      parv[0] = sender prefix
 *      parv[*] = parameters
 */
int
m_error(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	const char *para;
	int hideit = ConfigFileEntry.hide_error_messages;

	para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";

	if(IsAnyServer(client_p))
	{
		if(is_safe_error(para))
			hideit = 0;
		ilog(L_SERVER, "Received ERROR message from %s: %s",
		     log_client_name(source_p, SHOW_IP), para);
		if (hideit < 2)
			sendto_realops_flags(UMODE_ALL, hideit ? L_ADMIN : L_ALL,
					     "ERROR :from %s -- %s",
					     EmptyString(client_p->name) ? "" : client_p->name, para);
		if (hideit > 0)
			sendto_realops_flags(UMODE_ALL, hideit == 1 ? L_OPER : L_ALL,
					     "ERROR :from %s -- <hidden>",
					     EmptyString(client_p->name) ? "" : client_p->name);
	}

	exit_client(client_p, source_p, source_p, "ERROR");

	return 0;
}
Beispiel #4
0
/*
 * Note: At least at protocol level ERROR has only one parameter,
 * although this is called internally from other functions
 * --msa
 *
 *      parv[0] = sender prefix
 *      parv[*] = parameters
 */
void
m_error(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
    const char *para;
#ifndef HIDE_SERVERS_IPS
    static int showip = HIDE_IP;
#else
    static int showip = MASK_IP;
#endif

    if(IsAnyServer(client_p))
    {
        para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";

        ilog(L_ERROR, "Received ERROR message from %s: %s",
             log_client_name(source_p, SHOW_IP), para);

        if(ConfigFileEntry.hide_error_messages < 2)
        {
            sendto_realops_flags(UMODE_ALL, L_ADMIN,
                                 "ERROR :from %s -- %s",
                                 get_client_name(client_p, showip), para);

            if(!ConfigFileEntry.hide_error_messages)
                sendto_realops_flags(UMODE_ALL, L_OPER,
                                     "ERROR :from %s -- %s",
                                     get_client_name(client_p, showip), para);
        }
    }

    exit_client(client_p, source_p, source_p, "ERROR");
}
Beispiel #5
0
/*
 * handle_command
 *
 * inputs	- pointer to message block
 *		- pointer to client
 *		- pointer to client message is from
 *		- count of number of args
 *		- pointer to argv[] array
 * output	- -1 if error from server
 * side effects	-
 */
static int
handle_command(struct Message *mptr, struct Client *client_p,
	       struct Client *from, int i, char *hpara[MAXPARA])
{
	MessageHandler handler = 0;

	if(IsServer(client_p))
		mptr->rcount++;

	mptr->count++;

	/* New patch to avoid server flooding from unregistered connects
	   - Pie-Man 07/27/2000 */

	if(!IsRegistered(client_p))
	{
		/* if its from a possible server connection
		 * ignore it.. more than likely its a header thats sneaked through
		 */

		if(IsAnyServer(client_p) && !(mptr->flags & MFLG_UNREG))
			return (1);
	}

	handler = mptr->handlers[client_p->handler];

	/* check right amount of params is passed... --is */
	if(i < (int)mptr->parameters)
	{
		if(!IsServer(client_p))
		{
			sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
				   me.name, BadPtr(hpara[0]) ? "*" : hpara[0], mptr->cmd);
			if(MyClient(client_p))
				return (1);
			else
				return (-1);
		}

		sendto_realops_flags(UMODE_ALL, L_ALL,
				     "Dropping server %s due to (invalid) command '%s'"
				     "with only %d arguments (expecting %d).",
				     client_p->name, mptr->cmd, i, mptr->parameters);
		ilog(L_CRIT, "Insufficient parameters (%d) for command '%s' from %s.",
		     i, mptr->cmd, client_p->name);

		exit_client(client_p, client_p, client_p,
			    "Not enough arguments to server command.");
		return (-1);
	}

	(*handler) (client_p, from, i, hpara);
	return (1);
}
Beispiel #6
0
void
m_unregistered(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	if(IsAnyServer(client_p))
		return;

	/* bit of a hack.
	 * I don't =really= want to waste a bit in a flag
	 * number_of_nick_changes is only really valid after the client
	 * is fully registered..
	 */
	if(client_p->localClient->number_of_nick_changes == 0)
	{
		sendto_one(client_p, form_str(ERR_NOTREGISTERED), me.name);
		client_p->localClient->number_of_nick_changes++;
	}
}
Beispiel #7
0
int
m_unregistered(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	/* bit of a hack.
	 * I don't =really= want to waste a bit in a flag
	 * number_of_nick_changes is only really valid after the client
	 * is fully registered..
	 */
	if(IsAnyServer(client_p)) 
		return 0;
		
	if(client_p->localClient->number_of_nick_changes == 0)
	{
		sendto_one_numeric(client_p, s_RPL(ERR_NOTREGISTERED));
		client_p->localClient->number_of_nick_changes++;
	}

	return 0;
}
Beispiel #8
0
/*
 * handle_command
 *
 * inputs	- pointer to message block
 *		- pointer to client
 *		- pointer to client message is from
 *		- count of number of args
 *		- pointer to argv[] array
 * output	- -1 if error from server
 * side effects	-
 */
static int
handle_command(struct Message *mptr, struct Client *client_p,
	       struct Client *from, int i, const char **hpara)
{
	struct MessageEntry ehandler;
	MessageHandler handler = 0;
	static time_t last_warning;

	if(IsAnyDead(client_p))
		return -1;

	if(IsServer(client_p))
		mptr->rcount++;

	mptr->count++;

	/* New patch to avoid server flooding from unregistered connects
	   - Pie-Man 07/27/2000 */

	if(!IsRegistered(client_p))
	{
		/* if its from a possible server connection
		 * ignore it.. more than likely its a header thats sneaked through
		 */

		if(IsAnyServer(client_p) && !(mptr->flags & MFLG_UNREG))
			return (1);
	}

	ehandler = mptr->handlers[from->handler];
	handler = ehandler.handler;

	/* check right amount of params is passed... --is */
	if(i < ehandler.min_para ||
	   (ehandler.min_para && EmptyString(hpara[ehandler.min_para - 1])))
	{
		if(!IsServer(client_p))
		{
			sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
				   me.name,
				   EmptyString(client_p->name) ? "*" : client_p->name, mptr->cmd);
			if(MyClient(client_p))
				return (1);
			else
				return (-1);
		}

		sendto_realops_flags(UMODE_ALL, L_ALL,
				     "Dropping server %s due to (invalid) command '%s'"
				     " with only %d arguments (expecting %d).",
				     client_p->name, mptr->cmd, i, ehandler.min_para);
		ilog(L_SERVER,
		     "Insufficient parameters (%d) for command '%s' from %s.",
		     i, mptr->cmd, client_p->name);

		exit_client(client_p, client_p, client_p,
			    "Not enough arguments to server command.");
		return (-1);
	}

	(*handler) (client_p, from, i, hpara);
	if(!IsAnyDead(client_p) && IsCork(client_p) && !IsCapable(client_p, CAP_ZIP))
	{
		if(last_warning + 300 <= rb_time())
		{
			sendto_realops_flags(UMODE_DEBUG, L_ALL,
					     "Bug: client %s was left corked after command %s",
					     client_p->name, mptr->cmd);
			last_warning = rb_time();
		}
		client_p->localClient->cork_count = 0;
		send_pop_queue(client_p);
	}
	return (1);
}