Remove Arg parsing from sudo, (maybe in prep to deprecate in favor of
rudo)
Port login to clap-rs
Remove ArgParser dep
Remove whoami in favor of a link to id, and implemented linking in id.
I did a number of things here:
the *add, *mod, and *del utilities, as well as id recieved substantial
changes, probably what you'd call a rewrite. This was of course using
clap-rs. These should all be very stable at this point (except
unimplemented features in usermod, grr)
getty, passwd, and su are simply ported, using clap for arg parsing. I
didn't change any of the logic, just swapped ArgParser for clap.
Fixed a bug with passwd and unset passwords
I'll open issues about the ones I didn't mention.
Here I've implemented the remainder of the core user utilities present
on most unix systems. They aren't particularly pretty, but they do work
for the most part.
Note that for some reason attempting to move the home directory of a
user via usermod -m does not work.
Also removing user's that have been deleted from groups is not yet
implemented, nor is updating /etc/passwd when a group id is changed.
Note that redox_users as used by Cargo.lock as of this commit is broken,
and may not work properly. If redox-os/users#11 is merged, cargo update
should fix.
All the utilities use the new API I defined in mu recent PR to
redox_users. `su`'s behavior was also fixed.
I also updated Cargo.toml (removing unused deps). This may require
another commit after my first PR is merged in order to appropriately
update Cargo.lock and make sure everything builds.
Details
- Updated dependencies with `redox_users`.
- Migrated all user/group dependent functionality to calls to `redox_users`.
- Added top level documentation to the crate.
- Added a `spawn_shell` function to reuse a bit of code.
- `login`: Handled the case of an invalid login with "Login incorrect" (as in BSD).
- `passwd`: Refactored a bit and used `eprintln!` where possible.
- `su`: Refactored a bit and used `eprintln!` where possible.
- `sudo`: Refactored a bit to simplify logic also used `eprintln!` where possible.
- `whoami`: Refactored a bit and used `eprintln!/println!` where possible.
- Also added myself on the AUTHORS section :).
- Added constants for standard file paths.
- Improved error reporting when opening the files.
- Used `Passwd::parse_file` instead of doing it manually.
- Removed all the calls to unwrap().
- Used `fail` to report errors and exit when possible.
- Replaced all `unwrap()` calls by `try()`.
- Replaced all `panic()` calls by `fail()`.
- Argument parsing is now all done by `ArgParser`.
- Used `Passwd::parse_file` where possible.
- This actually does not change the password, will be the next job.
Details
- Moved cmd line args parsing to `ArgParser`.
- All the calls to `panic!` were replaced by calls to `fail`.
- Revisited synopsis in the docs.
- Using `try` where possible.
- Using `Passwd::parse_file` instead of doing it manually.
- Handled errors while parsing passwd file.
- Added some constants.