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 warning if tljh-config is called as non-root user #209

Merged
merged 4 commits into from Oct 25, 2018

Conversation

anyushevai
Copy link
Contributor

@anyushevai anyushevai commented Oct 21, 2018

There used to be two separate errors that occurred if we run the command without sudo:

[Errno 13] Permission denied: '/opt/tljh/installer.log'
at line 226

And
[Errno 13] Permission denied: '/opt/tljh/config/config.yaml'
at lines 294-305

Now we print an error and print a message about using 'sudo -E'.

I thought about putting the whole main function into one try-except block, but it seems more appropriate to use two different try-except blocks.

jupyterhub/outreachy#5

closes #120

tljh/config.py Outdated
reload_component(args.component)
else:
argparser.print_help()
except Exception as e:
Copy link
Member

Choose a reason for hiding this comment

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

Rather than catching all errors here, let's try proactively checking if os.geteuid() != 0, which is the condition when it is run as a non-root user. Maybe show an early warning in this case, indicating that it may fail with permission errors?

tljh/config.py Outdated Show resolved Hide resolved
Co-Authored-By: anyushevai <irina.anyusheva@gmail.com>
tljh/config.py Outdated Show resolved Hide resolved
Co-Authored-By: anyushevai <irina.anyusheva@gmail.com>
@choldgraf
Copy link
Member

This LGTM! If @minrk is +1 on the way to check for root then I'm +1 on merge! Thanks @anyushevai 🎉

@minrk minrk changed the title add warning & abort if tljh-config is called as non-root user add warning if tljh-config is called as non-root user Oct 25, 2018
@minrk minrk merged commit 6cc2cfd into jupyterhub:master Oct 25, 2018
@minrk
Copy link
Member

minrk commented Oct 25, 2018

Thanks, @anyushevai!

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.

Warn & abort if tljh-config is called as non-root user
3 participants