From e06248ef69b33d102a57aaa31fffcde3240dad9c Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Wed, 23 Sep 2026 10:08:44 +0200 Subject: user.set_password: change your own password; TUI "Byt lösenord" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Needs the current password (wrong ones rate limited like logins) and a password session, requires at least 10 characters, closes the user's other sessions and is audited without secrets. The TUI main menu gets "Byt lösenord" with masked prompts; ^R keeps working with the new password. Masked prompt buffers are wiped before they are freed. Co-Authored-By: Claude Opus 5.5 --- src/sessions.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/sessions.c') diff --git a/src/sessions.c b/src/sessions.c index 66ec375..21fc1ae 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -74,6 +74,23 @@ void sessions_destroy(const char *id) } } +int sessions_destroy_user(int64_t user_id, const char *keep_id) +{ + int n = 0; + struct session **pp = &g_sessions; + while (*pp) { + struct session *s = *pp; + if (s->user_id == user_id && (!keep_id || strcmp(s->id, keep_id))) { + *pp = s->next; + free(s); + n++; + continue; + } + pp = &s->next; + } + return n; +} + void sessions_free_all(void) { struct session *s = g_sessions; -- cgit v1.3