Files
SUB-OS/include/security/auth.h
T
subhobhai943andClaude Opus 4.8 c982d6b538 feat(auth): Boot-time login prompt; fix(configure): arch selection via dialog
Login:
- Add console_login() (security/auth.c): an interactive boot-time username /
  password gate rendered on the framebuffer console before any session starts.
  It blocks until valid credentials are entered, masks the password, scrubs it
  from the stack, and sets the current user. Default account is SUB / SUB, shown
  as a hint. Wired into the boot handoff in kernel/main.c ahead of both the GUI
  desktop and the emergency TTY shell.

Configure:
- scripts/kconfig/menuconfig.py: fix the architecture (and optimization) picker.
  The lxdialog front-end used --radiolist, where <Enter> confirms the ORIGINAL
  choice and only <Space> moves the dot -- so highlighting a new architecture
  and pressing <Enter> appeared to do nothing. Single-choice groups now use
  --menu (with --default-item), where <Enter> selects the highlighted row
  directly. Also stop the unconditional save-on-exit from overriding an explicit
  "No" at the exit confirmation.

Verified: SUB/SUB logs in (injected via QEMU monitor) -> "Login successful" ->
desktop starts; the desktop stays blocked until login. dialog --menu selection
of aarch64 persists to .config/autoconf.h and retargets `make`. Clean build on
x86_64/aarch64/armv8i.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fh5z6V7nGPbHvqVG5p4CXX
2026-08-25 17:57:47 +05:30

40 lines
1.2 KiB
C

#ifndef _SECURITY_AUTH_H
#define _SECURITY_AUTH_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#define MAX_USERS 16
typedef struct user_account {
uint32_t uid;
uint32_t gid;
char username[32];
char full_name[64];
char home_dir[64];
char shell[32];
char password_hash[65]; // 64-char SHA256 hex string + null
bool in_use;
} user_account_t;
void auth_init(void);
int auth_add_user(const char* username, const char* password, uint32_t uid, uint32_t gid, const char* home, const char* shell);
bool auth_verify_password(const char* username, const char* password);
int auth_change_password(const char* username, const char* new_password);
const user_account_t* auth_get_user_by_name(const char* username);
const user_account_t* auth_get_user_by_uid(uint32_t uid);
const user_account_t* auth_get_current_user(void);
int auth_set_current_user(const char* username);
size_t auth_get_user_count(void);
const user_account_t* auth_get_user_by_index(size_t index);
/* Interactive boot-time login: prompts for a username and password on the
* console and blocks until a valid pair is entered, then sets the current
* user. Default account is SUB / SUB. */
void console_login(void);
#endif // _SECURITY_AUTH_H