Ejemplo n.º 1
0
static int
do_local_user(struct Client *client_p, struct Client *source_p,
              const char *username, const char *realname)
{
    s_assert(NULL != source_p);
    s_assert(source_p->username != username);

    make_user(source_p);

    lookup_blacklists(source_p);
    source_p->flags |= FLAGS_SENTUSER;

    rb_strlcpy(source_p->info, realname, sizeof(source_p->info));

    if(!IsGotId(source_p))
        rb_strlcpy(source_p->username, username, sizeof(source_p->username));

    if(source_p->name[0])
    {
        /* NICK already received, now I have USER... */
        return register_local_user(client_p, source_p);
    }

    return 0;
}
Ejemplo n.º 2
0
static int
do_local_user(struct Client *client_p, struct Client *source_p,
	      const char *username, const char *realname)
{
	s_assert(NULL != source_p);
	s_assert(source_p->username != username);

	make_user(source_p);

	if (!(source_p->flags & FLAGS_SENTUSER))
	{
		lookup_blacklists(source_p);
		source_p->flags |= FLAGS_SENTUSER;
	}

	rb_strlcpy(source_p->info, realname, sizeof(source_p->info));

	if(!IsGotId(source_p))
	{
		/* This is in this location for a reason..If there is no identd
		 * and ping cookies are enabled..we need to have a copy of this
		 */
		rb_strlcpy(source_p->username, username, sizeof(source_p->username));
	}

	if(source_p->name[0])
	{
		/* NICK already received, now I have USER... */
		return register_local_user(client_p, source_p, username);
	}

	return 0;
}
Ejemplo n.º 3
0
static int
mr_pong(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    if(parc == 2 && !EmptyString(parv[1]))
    {
        if(ConfigFileEntry.ping_cookie && source_p->user && source_p->name[0])
        {
            unsigned long incoming_ping = strtoul(parv[1], NULL, 16);
            if(incoming_ping)
            {
                if(source_p->localClient->random_ping == incoming_ping)
                {
                    char buf[USERLEN + 1];
                    strlcpy(buf, source_p->username, sizeof(buf));
                    source_p->flags2 |= FLAGS2_PING_COOKIE;
                    register_local_user(client_p, source_p, buf);
                }
                else
                {
                    sendto_one(source_p, form_str(ERR_WRONGPONG),
                               me.name, source_p->name,
                               source_p->localClient->random_ping);
                    return 0;
                }
            }
        }

    }
    else
        sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);

    source_p->flags &= ~FLAGS_PINGSENT;

    return 0;
}
Ejemplo n.º 4
0
/* do_local_user()
 *
 * inputs       -
 * output       - NONE
 * side effects -
 */
static void
do_local_user(struct Client *source_p,
              const char *username, const char *host, const char *server,
              const char *realname)
{
  assert(source_p != NULL);
  assert(source_p->username != username);
  assert(IsUnknown(source_p));

  source_p->localClient->registration &= ~REG_NEED_USER;

  /*
   * don't take the clients word for it, ever
   */
  source_p->servptr = &me;

  strlcpy(source_p->info, realname, sizeof(source_p->info));

  /* stash for later */
  strlcpy(source_p->localClient->client_host, host, sizeof(source_p->localClient->client_host));
  strlcpy(source_p->localClient->client_server, server, sizeof(source_p->localClient->client_server));

  if (!IsGotId(source_p))
    strlcpy(source_p->username, username, sizeof(source_p->username));

  if (!source_p->localClient->registration)
    register_local_user(source_p);
}
Ejemplo n.º 5
0
static void
mr_pong(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
	assert(source_p == client_p);

	if(parc == 2 && *parv[1] != '\0')
	{
		if(ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
		{
			unsigned long incoming_ping = strtoul(parv[1], NULL, 10);

			if(incoming_ping)
			{
				if(source_p->localClient->random_ping == incoming_ping)
				{
					char buf[USERLEN + 1];

					strlcpy(buf, source_p->username, sizeof(buf));
					SetPingCookie(source_p);
					register_local_user(client_p, source_p,
							    source_p->name, buf);
				}
				else
				{
					sendto_one(source_p, form_str(ERR_WRONGPONG),
						   me.name, source_p->name,
						   source_p->localClient->random_ping);
					return;
				}
			}
		}
	}
	else
		sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
}
Ejemplo n.º 6
0
/*! \brief PONG command handler
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *      - parv[0] = command
 *      - parv[1] = origin/ping cookie
 */
static int
mr_pong(struct Client *source_p, int parc, char *parv[])
{
    assert(MyConnect(source_p));

    if (parc == 2 && !EmptyString(parv[1]))
    {
        if (ConfigGeneral.ping_cookie && source_p->connection->random_ping)
        {
            unsigned int incoming_ping = strtoul(parv[1], NULL, 10);

            if (source_p->connection->random_ping == incoming_ping)
            {
                SetPingCookie(source_p);

                if (!source_p->connection->registration)
                    register_local_user(source_p);
            }
            else
                sendto_one_numeric(source_p, &me, ERR_WRONGPONG,
                                   source_p->connection->random_ping);
        }
    }
    else
        sendto_one_numeric(source_p, &me, ERR_NOORIGIN);

    return 0;
}
Ejemplo n.º 7
0
static void
mr_pong(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	if(parc == 2 && !EmptyString(parv[1]))
	{
		if(ConfigFileEntry.ping_cookie && source_p->flags & FLAGS_SENTUSER && source_p->name[0])
		{
			unsigned long incoming_ping = strtoul(parv[1], NULL, 16);
			if(incoming_ping)
			{
				if(source_p->localClient->random_ping == incoming_ping)
				{
					source_p->flags |= FLAGS_PING_COOKIE;
					register_local_user(client_p, source_p);
				}
				else
				{
					sendto_one(source_p, form_str(ERR_WRONGPONG),
						   me.name, source_p->name,
						   source_p->localClient->random_ping);
					return;
				}
			}
		}

	}
	else
		sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, source_p->name);

	source_p->flags &= ~FLAGS_PINGSENT;
}
Ejemplo n.º 8
0
static void
cap_end(struct Client *source_p, const char *arg)
{
	if(IsRegistered(source_p))
		return;

	source_p->flags &= ~FLAGS_CLICAP;

	if(source_p->name[0] && source_p->flags & FLAGS_SENTUSER)
	{
		register_local_user(source_p, source_p);
	}
}
Ejemplo n.º 9
0
static void
cap_end(struct Client *source_p, const char *arg)
{
    if(IsRegistered(source_p))
        return;

    source_p->flags &= ~FLAGS_CLICAP;

    if(source_p->name[0] && source_p->flags & FLAGS_SENTUSER) {
        char buf[USERLEN+1];
        rb_strlcpy(buf, source_p->username, sizeof(buf));
        register_local_user(source_p, source_p, buf);
    }
}
Ejemplo n.º 10
0
static void
cap_end(struct Client *source_p, const char *arg)
{
	if(IsRegistered(source_p))
		return;

	source_p->flags2 &= ~FLAGS2_CLICAP;

	if(!EmptyString(source_p->name) && HasSentUser(source_p))
	{
		char buf[USERLEN+1];
		strlcpy(buf, source_p->username, sizeof(buf));
		register_local_user(source_p, source_p, buf);
	}
}
Ejemplo n.º 11
0
/* do_user()
 *
 * inputs       -
 * output       - NONE
 * side effects -
 */
static void
do_user(struct Client *source_p,
        const char *username,
        const char *realname)
{
  assert(IsUnknown(source_p));

  source_p->connection->registration &= ~REG_NEED_USER;
  source_p->servptr = &me;  /* Don't take the clients word for it, ever */

  strlcpy(source_p->info, realname, sizeof(source_p->info));

  if (!HasFlag(source_p, FLAGS_GOTID))
    strlcpy(source_p->username, username, sizeof(source_p->username));

  if (source_p->connection->registration == 0)
    register_local_user(source_p);
}
Ejemplo n.º 12
0
static int
cap_end(struct Client *source_p, const char *caplist)
{
  if (!IsUnknown(source_p))  /* registration has completed... */
    return 0;  /* so just ignore the message... */

  /* capability negotiation is now done... */
  source_p->localClient->registration &= ~REG_NEED_CAP;

  /* if client is now done... */
  if (!source_p->localClient->registration)
  {
    register_local_user(source_p);
    return 0;
  }

  return 0;  /* Can't do registration yet... */
}
Ejemplo n.º 13
0
/*
 * set_initial_nick
 * inputs
 * output
 * side effects	-
 *
 * This function is only called to set up an initially registering
 * client. 
 */
int
set_initial_nick(struct Client *client_p, struct Client *source_p,
                 char *nick)
{
 char buf[USERLEN + 1];
 /* Client setting NICK the first time */
  
 /* This had to be copied here to avoid problems.. */
 source_p->tsinfo = CurrentTime;
 if (source_p->name[0])
  del_from_client_hash_table(source_p->name, source_p);
 strcpy(source_p->name, nick);
 add_to_client_hash_table(nick, source_p);
 /* fd_desc is long enough */
 fd_note(client_p->localClient->fd, "Nick: %s", nick);
  
 /* They have the nick they want now.. */
 *client_p->llname = '\0';

 if (source_p->user)
 {
  strlcpy(buf, source_p->username, USERLEN);
  /*
   * USER already received, now we have NICK.
   * *NOTE* For servers "NICK" *must* precede the
   * user message (giving USER before NICK is possible
   * only for local client connection!). register_user
   * may reject the client and call exit_client for it
   * --must test this and exit m_nick too!!!
   */
#ifdef USE_IAUTH
  /*
   * Send the client to the iauth module for verification
   */
  BeginAuthorization(source_p);
#else
  if (register_local_user(client_p, source_p, nick, buf) == CLIENT_EXITED)
   return CLIENT_EXITED;
#endif
 }
 return 0;
}
Ejemplo n.º 14
0
/* set_initial_nick()
 *
 * inputs
 * output
 * side effects -
 *
 * This function is only called to set up an initially registering
 * client.
 */
static void
set_initial_nick(struct Client *source_p, const char *nick)
{
  /* Client setting NICK the first time */

  /* This had to be copied here to avoid problems.. */
  source_p->tsinfo = CurrentTime;
  source_p->localClient->registration &= ~REG_NEED_NICK;

  if (source_p->name[0])
    hash_del_client(source_p);

  strlcpy(source_p->name, nick, sizeof(source_p->name));
  hash_add_client(source_p);

  /* fd_desc is long enough */
  fd_note(&source_p->localClient->fd, "Nick: %s", nick);

  if (!source_p->localClient->registration)
    register_local_user(source_p);
}
Ejemplo n.º 15
0
static int
cap_end(struct Client *sptr, const char *caplist)
{
  if (!IsUnknown(sptr))    /* registration has completed... */
    return 0;    /* so just ignore the message... */

  /* capability negotiation is now done... */
  sptr->localClient->registration &= ~REG_NEED_CAP;

  /* if client is now done... */
  if (!sptr->localClient->registration)
  {
    char buf[USERLEN + 1];

    strlcpy(buf, sptr->username, sizeof(buf));
    register_local_user(sptr, sptr, sptr->name, buf);
    return 0;
  }

  return 0;    /* Can't do registration yet... */
}
Ejemplo n.º 16
0
/* set_initial_nick()
 *
 * inputs
 * output
 * side effects -
 *
 * This function is only called to set up an initially registering
 * client.
 */
static void
set_initial_nick(struct Client *source_p, const char *nick)
{
  const int samenick = !irccmp(source_p->name, nick);

  if (!samenick)
    source_p->tsinfo = CurrentTime;

  source_p->connection->registration &= ~REG_NEED_NICK;

  if (source_p->name[0])
    hash_del_client(source_p);

  strlcpy(source_p->name, nick, sizeof(source_p->name));
  hash_add_client(source_p);

  /* fd_desc is long enough */
  fd_note(&source_p->connection->fd, "Nick: %s", source_p->name);

  if (!source_p->connection->registration)
    register_local_user(source_p);
}