-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor early checks to a separate module
This is in preparation for a bigger change that will come next. Signed-off-by: Leandro Motta Barros <[email protected]> Change-type: patch
- Loading branch information
Showing
2 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use log::error; | ||
|
||
use crate::common::{is_admin, Error, Options, Result}; | ||
|
||
/// Performs checks to ensure that the program can run properly with the | ||
/// provided command-line options. Returns an error if the program cannot run | ||
/// for some reason. | ||
pub(crate) fn do_early_checks(_opts: &Options) -> Result<()> { | ||
if !is_admin()? { | ||
error!("please run this program as root"); | ||
return Err(Error::displayed()); | ||
} | ||
|
||
Ok(()) | ||
} |