httpd: reuse the slot of a valid cookie, end sessions on passwd

Review feedback on #560 (DrDoof):

- A login that came with a cookie that is still valid took a second
  slot. The first one looked fresh, so the next login could push out
  someone who is using the switch. The slot of the cookie now gets the
  new id.
- Changing the password leaves no old login valid: session_init() from
  parse_passwd(). With one session the next login pushed a leftover one
  out, with several it would stay valid until the next restart.
- The 32-bit comparison of the last use times moves into a leaf function,
  so the compiler does not give it a 4-byte scratch in internal RAM.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Brunoz78andClaude Sonnet 5.5 committed 2026-10-25 10:51:23 +01:00
1 parent a7db0ca8b6
commit e1c79ec4cd
3 files changed
+110 -12

No files matched your search

+4
View File
@@ -24,6 +24,7 @@
#include "sfp.h"
#include "dhcp.h"
#include "syslog.h"
#include "sessions.h"
#include "dns.h"
#include "ntp.h"
#include "uip/uip.h"
@@ -1479,6 +1480,9 @@ void parse_passwd(void)
passwd[j++] = c;
} while (c != NUL && j < 20);
passwd[j] = NUL;
/* Logins made with the old password end here. With one session the next
* login pushed a leftover one out; with several it would stay valid. */
session_init();
return;
}
cmd_error("Missing password\n");