Expand description
§Authentication Module
The Authentication module provides user and group management functionality for the Xila operating system. It handles user authentication, password hashing, and secure storage of user/group information.
§Features
- User Management: Create, authenticate, rename and manage user accounts
- Group Management: Create and manage user groups
- Password Security: Secure password hashing using SHA-512 with salt
- File-based Storage: Persistent storage of user and group data in JSON format
- Async Operations: All operations are asynchronous for better performance
§File Structure
- Users are stored in
/system/accounts/users/, one record per user, in a file named after the user - Groups are stored in
/system/accounts/groups/ - Random salt generation uses
/devices/random/source
§User names
New and renamed accounts must satisfy [users::is_valid_user_name]: an
ASCII letter followed by at most 31 ASCII letters, digits, _ or -.
Existing accounts load whatever their name, but record lookups always
reject names that are not a single ordinary directory entry.
§Home directories
Like the home field of /etc/passwd, each account records its home. It is
set to /users/<user name> when the account is created and read from the
account afterwards (VirtualFileSystem::get_user_home), never recomputed
from the current name. The directory itself is created at the first login.
The built-in root account has no record; its home is [users::ROOT_HOME].
Renaming an account (change_user_name) keeps its recorded home, as Linux
usermod --login does without --move-home. Moving a home is a separate,
explicit operation that Xila does not perform implicitly.
§Account record versions
Records carry a version field (USER_RECORD_VERSION). Version 1 adds
the home field. Records without a version are version 0, written before
homes were recorded: their home is /users/<identifier>, the path they
already used. That fallback is applied in memory when the record is read,
so booting never writes to storage; a version 0 record is upgraded only when
it is rewritten anyway (password change or rename), and then records the
same /users/<identifier> home. Records of an unknown version, or version 1
records without a valid home, are rejected. Firmware older than version 1
ignores the new fields and falls back to /users/<identifier>.
Structs§
- Context
- The dependencies required by authentication operations.
- Group
- Represents a user group with associated metadata and member list.
- User
- Represents a user account with all associated metadata.
Enums§
- Error
- Comprehensive error enumeration for authentication operations.
Constants§
- SEED_
PENDING_ CONTENT - SEED_
PENDING_ PATH - Marker for an explicitly provisioned reference image. Not application metadata.
- USER_
RECORD_ VERSION - Version written to every account record.
Functions§
- authenticate_
user - Authenticates a user with their username and password.
- change_
user_ name - Renames a user account.
- change_
user_ password - Changes a user’s password by generating a new salt and hash.
- create_
group - Creates a new group with the specified parameters.
- create_
user - Creates a new user account with the specified parameters.
- get_
group_ file_ path - Constructs the file system path for a group’s data file.
- get_
user_ file_ path - Constructs the file system path for a user’s data file.
- initialize_
seeded - Load saved users and finish an explicitly pending seed installation. An unmarked disk never authorizes account creation or password replacement.
- load_
all_ users_ and_ groups - Loads all users and groups from the filesystem into memory.
- new_
user_ home - Home recorded for a new account:
/users/<user name>. - read_
group_ file - Reads and parses a group file from the filesystem.
- read_
user_ file - Reads and parses a user file from the filesystem.
Type Aliases§
- Result
- Result type alias for authentication operations.