-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: master
Are you sure you want to change the base?
Conversation
gsuyemoto
commented
May 3, 2023
- 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
Use Rust starter workflow
…ing them an opportunity to escalate their privileges to root when running the app. This is in contrast to having the app exit and the user having the run the app again as sudo.
…d with sudo crate which automatically upgrades user privileges on app startup.
…est of the Cargo dependencies.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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).
Moved escalate. Added a short comment for network configuration line below it to help delineate from different logic. |
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 ? |
Hey Corentin!
Oh man, I haven't messed with this code in a while. I had actually added
Rust benchmarking and converted the ieee file to bincode and hashmap (for
my own use) for faster scanning (although slower loading). I should have
created a separate branch for the benchmarking/bincode/hashmap. I can take
a look at the admin rights upgrade to pull it out separately for a simpler
merge next week if that's cool.
…-Gary
On Wed, Aug 16, 2023 at 4:54 AM Corentin B. ***@***.***> wrote:
Hi @gsuyemoto <https://github.com/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 ?
—
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE5S55YV6J3OPHNSSZM7PILXVSYHTANCNFSM6AAAAAAXVB3HVM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|