arch: migrate to uucore for true uutils drop-in compatibility

Fixes #8

- Added uucore 0.7 as workspace dependency
- main.rs now uses uucore::bin!(uu_passwd) one-liner (SIGPIPE,
  localization, signal handling all handled by uucore)
- uumain decorated with #[uucore::main], returns UResult<()>
- Created PasswdError enum implementing UError trait with correct
  exit code mapping (1=permission, 2=options, 3=failure, 4=missing,
  5=busy, 6=invalid, 10=PAM)
- Internal helpers return Result<T, PasswdError> instead of raw i32
- Informational messages use uucore::show_error! macro (auto-prefixes
  with utility name)
- Error propagation via ? operator instead of early return with codes

The tool now follows the exact uucore API contract:
  pub fn uumain(args: impl uucore::Args) -> UResult<()>
  pub fn uu_app() -> Command

95 tests passing on Debian/Alpine/Fedora, zero clippy warnings.
This commit is contained in:
Pierre Warnier
2026-03-23 13:56:51 +01:00
parent 08eb1bd911
commit b3cfa8dc61
4 changed files with 194 additions and 128 deletions
+3
View File
@@ -31,6 +31,9 @@ shadow-core = { path = "src/shadow-core" }
# CLI
clap = { version = "4", features = ["derive", "wrap_help"] }
# uutils integration
uucore = "0.7"
# Error handling
thiserror = "2"
+1
View File
@@ -20,6 +20,7 @@ libc = { workspace = true }
nix = { workspace = true }
shadow-core = { workspace = true, features = ["shadow", "login-defs"] }
thiserror = { workspace = true }
uucore = { workspace = true }
[features]
default = []
+1 -4
View File
@@ -3,7 +3,4 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
fn main() {
let code = uu_passwd::uumain(std::env::args_os());
std::process::exit(code);
}
uucore::bin!(uu_passwd);
File diff suppressed because it is too large Load Diff