cmd_error(c, "Maximum number of tokens was reached");
struct auth_token *at = auth_create_token(aa);
- char *tok = auth_set_token_generated(at, get_string(c->request, "comment"));
+ char *tok = auth_set_token_generated(at, get_string(c->request, "comment"), c->pool);
set_string(c, c->reply, "token", tok);
- xfree(tok);
msg(L_INFO, "Created token: login=<%s> zone=<%s> id=<%s>", aa->user->login, aa->zone->name, at->ident);
struct auth_acct *aa = cmd_need_target_acct(c);
uint validity;
- if (get_uint(c->request, "validity", &validity))
+ if (!get_uint(c->request, "validity", &validity))
cmd_error(c, "Validity must be given");
if (!aa->zone->max_temp_validity)
if (validity > aa->zone->max_temp_validity)
cmd_error(c, "This zone limits temporary token validity to %d seconds", aa->zone->max_temp_validity);
- char *tok = temp_generate(aa->zone->name, aa->user->login, validity);
+ char *tok = temp_generate(aa->zone->name, aa->user->login, validity, c->pool);
set_string(c, c->reply, "token", tok);
- xfree(tok);
- msg(L_INFO, "Created temp token: login=<%s> zone=<%s> validity=%u", aa->user->login, aa->zone->name, validity);
+ const char *shortened = temp_shorten(tok, c->pool);
+
+ msg(L_INFO, "Created temp token: login=<%s> zone=<%s> temp=<%s> validity=%u", aa->user->login, aa->zone->name, shortened, validity);
cmd_ok(c);
}
static void cmd_login_by_temp(struct client *c, struct auth_zone *az, const char *given_passwd)
{
const char *login = cmd_need_string(c, "login");
+ const char *shortened = temp_shorten(given_passwd, c->pool);
- const char *reason = temp_check(az->name, login, given_passwd);
+ const char *reason = temp_check(az->name, login, given_passwd, c->pool);
if (reason)
{
- msg(L_INFO, "Login failed: %s user=<%s> zone=<%s> type=<temp>", reason, login, az->name);
+ msg(L_INFO, "Login failed: %s user=<%s> zone=<%s> temp=<%s>", reason, login, az->name, shortened);
goto reject;
}
struct auth_user *au = auth_find_user(login, 0);
if (!au)
{
- msg(L_INFO, "Login failed: No user=<%s> type=<temp>", login);
+ msg(L_INFO, "Login failed: No user=<%s> temp=<%s>", login, shortened);
goto reject;
}
struct auth_acct *aa = auth_find_acct(au, az, 0);
if (!aa)
{
- msg(L_INFO, "Login failed: No account user=<%s> zone=<%s> type=<temp>", login, az->name);
+ msg(L_INFO, "Login failed: No account user=<%s> zone=<%s> temp=<%s>", login, az->name, shortened);
goto reject;
}
- msg(L_INFO, "Login successful: user=<%s> zone=<%s> type=<temp>", login, az->name);
+ msg(L_INFO, "Login successful: user=<%s> zone=<%s> temp=<%s>", login, az->name, shortened);
cmd_ok(c);
+ return;
reject:
cmd_error(c, "Temporary token refused");