-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move
login
and su
to the common executable
- Loading branch information
Showing
10 changed files
with
68 additions
and
77 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
//! Main of all commands that **require** the SUID flag. | ||
#![feature(never_type)] | ||
#![feature(os_str_display)] | ||
|
||
mod login; | ||
mod su; | ||
|
||
use std::env; | ||
use utils::error; | ||
|
||
fn main() { | ||
// TODO | ||
let mut args = env::args_os(); | ||
let bin = args | ||
.next() | ||
.and_then(|s| s.into_string().ok()) | ||
.unwrap_or_else(|| { | ||
error("mutils", "missing binary name"); | ||
}); | ||
match bin.as_str() { | ||
"login" => login::main(args), | ||
"su" => su::main(args), | ||
_ => error("mutils", "invalid binary name"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
//! Features utils to several commands. | ||
use std::fmt; | ||
use std::process::exit; | ||
|
||
pub mod disk; | ||
pub mod prompt; | ||
pub mod user; | ||
pub mod util; | ||
|
||
/// Writes an error to stderr, then exits. | ||
pub fn error<M: fmt::Display>(bin: &str, msg: M) -> ! { | ||
eprintln!("{bin}: error: {msg}"); | ||
exit(1); | ||
} |
This file was deleted.
Oops, something went wrong.