feat(login): implement initial utility structure and configuration parser #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR establishes the foundational structure for the login utility, focusing primarily on parsing the
/etc/login.defsconfiguration file and setting up the basic command-line interface.This is the first step towards implementing parts of shadow-utils. The goal of this PR is to get the configuration loading and argument parsing logic in place so that subsequent PRs can focus on the actual authentication, PAM integration, and session management logic.
Key Changes
login_defs.rs)I've implemented a robust parser for login.defs that mirrors the behavior of shadow-utils. The parser collects warnings (e.g., file not found, permission errors, invalid values) instead of crashing, allowing login to fall back to safe defaults. It maps configuration keys to strongly typed fields (e.g.,
Option<u32>for timeouts,Option<PathBuf>for files). It handles most keys in shadow-utils'slogin.defs(5), including all the ones that seem required for login.Add clap argument parsing, along with a
LoginConfigurationstruct to hold parsed arguments.Added a preliminary check to ensure the
loginbinary is running with root privileges (or SUID), returning a standard "must be suid to work properly" error if not. This gave some behavior for a basic test case to be created.Most dependencies are updated except for uucore. Adopting this codebase to the current uucore appears to need some code changes due to the
help_aboutandhelp_usagemacros changing. A change tobuild.rswas needed; it appears to be part of Bumpphf_codegen& fix compilation error #169 and can be removed from this PR if that one is merged first.