};
/** Return whether flag \a flag is set on \a iauth. */
-#define IAuthHas(iauth, flag) FlagHas(&iauth->i_flags, flag)
+#define IAuthHas(iauth, flag) ((iauth) && FlagHas(&(iauth)->i_flags, flag))
/** Set flag \a flag on \a iauth. */
-#define IAuthSet(iauth, flag) FlagSet(&iauth->i_flags, flag)
+#define IAuthSet(iauth, flag) FlagSet(&(iauth)->i_flags, flag)
/** Clear flag \a flag from \a iauth. */
-#define IAuthClr(iauth, flag) FlagClr(&iauth->i_flags, flag)
+#define IAuthClr(iauth, flag) FlagClr(&(iauth)->i_flags, flag)
/** Get connected flag for \a iauth. */
-#define i_GetConnected(iauth) (s_fd(i_socket(iauth)) > -1)
+#define i_GetConnected(iauth) ((iauth) && s_fd(i_socket(iauth)) > -1)
/** Return socket event generator for \a iauth. */
#define i_socket(iauth) (&(iauth)->i_socket)
/** Return outbound message queue for \a iauth. */
#define i_sendQ(iauth) (&(iauth)->i_sendQ)
/** Return debug level for \a iauth. */
-#define i_debug(iauth) (iauth->i_debug)
+#define i_debug(iauth) ((iauth)->i_debug)
/** Active instance of IAuth. */
struct IAuth *iauth;
if (!lower && !upper)
goto badid;
/* Final character must not be punctuation. */
- if (!IsAlnum(ch))
+ if (!IsAlnum(last))
goto badid;
}
return 0;
}
+ /* If appropriate, do preliminary assignment to connection class. */
+ if (IsUserPort(auth->client)
+ && !FlagHas(&auth->flags, AR_IAUTH_HURRY)
+ && preregister_user(auth->client))
+ return CPTR_KILLED;
+
/* Check if iauth is done. */
if (FlagHas(&auth->flags, AR_IAUTH_PENDING))
{
/* Set "hurry" flag in auth request. */
FlagSet(&auth->flags, AR_IAUTH_HURRY);
- /* Do preliminary assignment to connection class. */
- if (preregister_user(auth->client))
- return CPTR_KILLED;
-
/* Check password now (to avoid challenge/response conflicts). */
aconf = cli_confs(auth->client)->value.aconf;
if (!EmptyString(aconf->passwd)
cli_fd(auth->client), AR_IAUTH_PENDING));
return 0;
}
+ else
+ FlagSet(&auth->flags, AR_IAUTH_HURRY);
+
destroy_auth_request(auth, send_reports);
if (!IsUserPort(auth->client))
local_addr.port = 0;
memcpy(&remote_addr.addr, &cli_ip(auth->client), sizeof(remote_addr.addr));
remote_addr.port = 113;
- fd = os_socket(&local_addr, SOCK_STREAM, "auth query");
+ fd = os_socket(&local_addr, SOCK_STREAM, "auth query", 0);
if (fd < 0) {
++ServerStats->is_abad;
if (IsUserPort(auth->client))
/** Close all %IAuth connections marked as closing. */
void auth_close_unused(void)
{
- if (iauth && IAuthHas(iauth, IAUTH_CLOSING)) {
+ if (IAuthHas(iauth, IAUTH_CLOSING)) {
int ii;
iauth_disconnect(iauth);
if (iauth->i_argv) {
{
struct SLink *link;
- for (link = iauth->i_config; link; link = link->next)
+ if (iauth) for (link = iauth->i_config; link; link = link->next)
{
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":%s",
link->value.cp);
{
struct SLink *link;
- for (link = iauth->i_stats; link; link = link->next)
+ if (iauth) for (link = iauth->i_stats; link; link = link->next)
{
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":%s",
link->value.cp);