Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/s_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern int auth_set_pong(struct AuthRequest *auth, unsigned int cookie);
extern int auth_set_user(struct AuthRequest *auth, const char *username, const char *hostname, const char *servername, const char *userinfo);
extern int auth_set_nick(struct AuthRequest *auth, const char *nickname);
extern int auth_set_password(struct AuthRequest *auth, const char *password);
extern int auth_set_account(struct AuthRequest *auth, const char *account_info);
extern int auth_cap_start(struct AuthRequest *auth);
extern int auth_cap_done(struct AuthRequest *auth);
extern int auth_spoof_user(struct AuthRequest *auth, const char *username, const char *hostname, const char *ip);
Expand Down
2 changes: 1 addition & 1 deletion ircd/ircd_netconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void config_burst(struct Client *cptr)
entry->timestamp, entry->key, entry->value);
}

Debug((DEBUG_INFO, "Config burst: %d entries sent to %s",
Debug((DEBUG_DEBUG, "Config burst: %d entries sent to %s",
config_count(), cli_name(cptr)));
}

Expand Down
1 change: 0 additions & 1 deletion ircd/m_sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@

#include <stdlib.h>


/** SASL timeout callback - called when a SASL session times out
* @param[in] ev Timer event (contains client pointer in timer data)
*/
Expand Down
56 changes: 52 additions & 4 deletions ircd/s_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,50 @@ static int auth_set_username(struct AuthRequest *auth)
return exit_client(sptr, sptr, &me, "USER: Bad username");
}

/** Set account for user associated with \a auth.
* @param[in] auth Authorization request for client.
*/
int auth_set_account(struct AuthRequest *auth, const char *account_info)
{
assert(auth != NULL);

struct Client *sptr = auth->client;
char *account_copy = NULL, *account = NULL, *id_str = NULL, *flags_str = NULL, *extra = NULL;

/* Parse account information: username:id:flags */
DupString(account_copy, account_info);
if (!account_copy)
return 1;

account = strtok(account_copy, ":");
id_str = strtok(NULL, ":");
flags_str = strtok(NULL, " ");
extra = strtok(NULL, "");

/* Copy account name to User structure */
ircd_strncpy(cli_user(sptr)->account, account, ACCOUNTLEN);

/* Parse account ID if provided */
if (id_str) {
cli_user(sptr)->acc_id = strtoul(id_str, NULL, 10);
}

if (flags_str) {
cli_user(sptr)->acc_flags = strtoul(flags_str, NULL, 10);
}

SetAccount(sptr);

/* Check for +x flag (host hiding) */
if (extra && strstr(extra, "+x") && feature_bool(FEAT_HOST_HIDING)) {
SetHiddenHost(sptr);
}

sendto_iauth(sptr, "A %s", cli_user(sptr)->account);
MyFree(account_copy);
return 0;
}

/** Notifies IAuth of a status change for the client.
*
* @param[in] auth Authorization request that was updated.
Expand Down Expand Up @@ -399,7 +443,8 @@ static void iauth_notify(struct AuthRequest *auth, enum AuthRequestFlag flag)
break;

case AR_IAUTH_PENDING:
sendto_iauth(sptr, "T");
if (!FlagHas(&auth->flags, AR_CAP_PENDING))
sendto_iauth(sptr, "T");
break;

default:
Expand Down Expand Up @@ -921,8 +966,7 @@ int auth_ping_timeout(struct Client *cptr)

/* Check for iauth timeout. */
if (FlagHas(&auth->flags, AR_IAUTH_PENDING)) {
if (IAuthHas(iauth, IAUTH_REQUIRED)
&& !FlagHas(&auth->flags, AR_IAUTH_SOFT_DONE)) {
if (IAuthHas(iauth, IAUTH_REQUIRED)) {
sendheader(cptr, REPORT_FAIL_IAUTH);
return exit_client_msg(cptr, cptr, &me, "Authorization Timeout");
}
Expand Down Expand Up @@ -1295,7 +1339,10 @@ void auth_send_xreply(struct Client *sptr, const char *routing,
int auth_cap_start(struct AuthRequest *auth)
{
assert(auth != NULL);
FlagSet(&auth->flags, AR_CAP_PENDING);
if (!FlagHas(&auth->flags, AR_CAP_PENDING)) {
FlagSet(&auth->flags, AR_CAP_PENDING);
sendto_iauth(auth->client, "c");
}
return 0;
}

Expand All @@ -1307,6 +1354,7 @@ int auth_cap_start(struct AuthRequest *auth)
int auth_cap_done(struct AuthRequest *auth)
{
assert(auth != NULL);
sendto_iauth(auth->client, "e");
return check_auth_finished(auth, AR_CAP_PENDING);
}

Expand Down
33 changes: 2 additions & 31 deletions ircd/sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "msg.h"
#include "capab.h"
#include "numnicks.h"
#include "s_auth.h"
#include "s_debug.h"
#include "s_bsd.h"
#include "numeric.h"
Expand Down Expand Up @@ -253,37 +254,7 @@ void sasl_send_xreply(struct Client* sptr, const char* routing, const char* repl
* If this is a SASL authentication after registration, the username will be set by the service using AC.
*/
if (!IsUser(cli)) {
/* Parse account information: username:id:flags */
DupString(account_copy, account_info);
if (!account_copy)
return;

username = strtok(account_copy, ":");
id_str = strtok(NULL, ":");
flags_str = strtok(NULL, " ");
extra = strtok(NULL, "");

/* Copy account name to User structure */
ircd_strncpy(cli_user(cli)->account, username, ACCOUNTLEN);

/* Parse account ID if provided */
if (id_str) {
cli_user(cli)->acc_id = strtoul(id_str, NULL, 10);
}

/* Parse account flags if provided */
if (flags_str) {
cli_user(cli)->acc_flags = strtoul(flags_str, NULL, 10);
}

SetAccount(cli);

/* Check for +x flag (host hiding) */
if (extra && strstr(extra, "+x") && feature_bool(FEAT_HOST_HIDING)) {
SetHiddenHost(cli);
}

MyFree(account_copy);
auth_set_account(cli_auth(cli), account_info);

/**
* For already registered users, we send RPL_LOGGEDIN. For non-registered users,
Expand Down
Loading