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

Can’t use --help as non-root user #2

Closed
luziferius opened this issue Oct 3, 2019 · 2 comments
Closed

Can’t use --help as non-root user #2

luziferius opened this issue Oct 3, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@luziferius
Copy link

As far as I can see, the first thing main() does is to check if it runs as root, even before the argument parser is built:

def main():
if os.geteuid() != 0:
print('''You need to have root privileges to run this script.
Please try again, this time using 'sudo'.
Exiting.''', file=sys.stderr)
sys.exit(1)
parser = argparse.ArgumentParser(

I think this is a bit restrictive. If you move the check below

args = parser.parse_args()

both --help and --version can be used as non-root, while the system-altering functions are still protected.

@ulrick65
Copy link

This is not a bad idea...not a major issue mind you, but might be cleaner for some folks. The other thing I thought of was if you do run it as non-root, you could say so (like it does) but then also display the help info as if --help was specified. Just an idea.

Great tool here, it works perfectly for me.

@shokinn shokinn self-assigned this Oct 30, 2019
@shokinn shokinn added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Oct 30, 2019
@shokinn
Copy link
Owner

shokinn commented Oct 30, 2019

Fixed in d59bdd0

Sorry @luziferius, I've totally overlooked your issue -.-

@shokinn shokinn closed this as completed Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants