Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sudo crate functionality #5

Open
wants to merge 123 commits into
base: master
Choose a base branch
from

Conversation

gsuyemoto
Copy link

  • Added sudo crate to Cargo.toml => sudo = "0.6"
  • Modified main.rs to add sudo call at the very beginning of main()
  • Removed call to function that checks for sudo privileges in main()
  • Removed function for checking sudo privileges in utils.rs
  • Removed use::std::env in utils.rs as the sudo function seemed to be the only code needing it

src/main.rs Outdated
// ----------------------------------------
// Providing a prompt for the user when
// the app is run and user is not root
sudo::escalate_if_needed().expect("You need root permissions to run this app. Unable to escalate to sudo");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great @gsuyemoto ! A small change : the escalate_if_needed() call can be moved after the scan_options.request_protocol_print() condition (L48) in order to allow non-root users to view the protocol ASCII print and list the interfaces.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll move the escalate, makes total sense!

src/utils.rs Outdated
* Based on the current UNIX environment, find if the process is run as root
* user. This approach only supports Linux-like systems (Ubuntu, Fedore, ...).
*/
pub fn is_root_user() -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks for keeping the code base clean 👍

…rint() to allow users to use app for duties that do not require root access (e.g. view protocol ASCII print and list available interfaces).
@gsuyemoto
Copy link
Author

Moved escalate. Added a short comment for network configuration line below it to help delineate from different logic.

@Saluki
Copy link
Collaborator

Saluki commented Aug 16, 2023

Hi @gsuyemoto 👋 Sorry for the delay - I want to merge your changes in the codebase but it looks like the Git history is not 100% clean (all files seems "changed"). Could you check in the "Files changed" tab what went wrong ?

@gsuyemoto
Copy link
Author

gsuyemoto commented Aug 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants