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

Always inform user when sudo is required #164

Closed
acburdine opened this issue Feb 28, 2017 · 6 comments · Fixed by #213
Closed

Always inform user when sudo is required #164

acburdine opened this issue Feb 28, 2017 · 6 comments · Fixed by #213

Comments

@acburdine
Copy link
Member

Because of the nature of some of the setups (systemd, nginx configuration), sometimes a sudo-level command must be run by the CLI. To be as transparent and clear (e.g. not confusing) as possible, any CLI action that requires sudo access should first log and inform the user as to what is being done.

If verbose output is not turned on, just a basic description should be logged, e.g. "Systemd configuration is being moved into place, you may be prompted for your password". However, if verbose logging is enabled, the actual command should be logged as well.

@cjsheets
Copy link

cjsheets commented Mar 31, 2017

I'm glad to see this issue raised. I was trying out CLI (awesome tool btw) on a staging server and was a bit surprised by sudo (+ the lack of information relating to what it was doing).

In addition to the considerations you mentioned, would it also be possible to document the likely commands that require elevated privileges elsewhere (like developer docs)?

Typically, I'd run ghost-cli with a user that has no sudo access. If sudo is required for basic cli functions it would be nice to at least lock it to a set of available commands (ex. sudo mv someFilename /lib/systemd/system) even if the docs aren't exact and require some reasoning by the admin.

@PaszaVonPomiot
Copy link

@acburdine if you list all the sudo commands that ghost user needs to use I will create a sudo profile fit for that purpose.

@PaszaVonPomiot
Copy link

I have tested the sudo requirements for a little bit and it appears that following sudoers commands will be sufficient for ghost user (this is on Centos 7):

ghost   ALL=(root)      NOPASSWD: /bin/systemctl start ghost*, \
                                  /bin/systemctl stop ghost*, \
                                  /bin/mv ghost_*.service /lib/systemd/system, \
                                  /bin/rm /lib/systemd/system/ghost*

Please bear in mind that above sudoers setup is not considered safe due to wildcards.
I see two solutions to have safe persmissions for ghost-cli - one is to take above sudoers and add all the exceptios for wildcards (eg. !/bin/systemctl stop ghost* *) which is a bit messy. Second is to have a script owned by root that will be used by ghost user via sudo. This way single line would be enough in /etc/sudoers file. Example file could be /usr/local/bin/ghost/ghost_cli.sh which would be used by Ghost-CLI with sudo.
So for example you would type ghost start and ghost-cli would do sudo /usr/local/bin/ghost/ghost_cli.sh start.
I'm not sure if that's the most elegant solution but that's certainly a possibility.

@acburdine
Copy link
Member Author

@PaszaVonPomiot thanks for that list! One of the things that we've planned to do before releasing Ghost-CLI 1.0 is the creation of a user account specifically for Ghost itself during setup (similar to what MySQL does). The idea is that you'll run ghost-cli commands as root/a full sudo user, and the Ghost process itself will be run as a specific (non-sudo, possibly rooted) user.

@PaszaVonPomiot
Copy link

@acburdine yes I've seen the plan for ghost-cli 1.0. I fully agree with ghost-cli creating system user and database user with permissions fit for purpose. The sysytem user account would need to perform systemctl start/stop ghost_*.service command. Can we achieve that without sudo?

@acburdine
Copy link
Member Author

Yup, actually we did figure out a solution to work around the need for sudo in the ghost user 😄. The only thing it would need it for is auto/1-click-updates, which (at the moment), won't happen until sometime after ghost 1.0. However, one of the things that goes in the systemd configuration is a auto-restart directive, which means that on auto or 1-click updates, Ghost can just kill itself once all of the new stuff has been downloaded, and rely on systemd to restart the process, which will then pick up the new updates.

acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
refs TryGhost#164
- add sudo ui method that shows the sudo command before it is run
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
refs TryGhost#164
- add sudo ui method that shows the sudo command before it is run
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
refs TryGhost#164
- add sudo ui method that shows the sudo command before it is run
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
refs TryGhost#164
- add sudo ui method that shows the sudo command before it is run
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
closes TryGhost#164
- add sudo ui method that shows the sudo command before it is run
- make log method synchronous again
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
closes TryGhost#164
- add sudo ui method that shows the sudo command before it is run
- make log method synchronous again
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jun 18, 2017
closes TryGhost#164
- add sudo ui method that shows the sudo command before it is run
- make log method synchronous again
acburdine added a commit that referenced this issue Jun 18, 2017
closes #164
- add sudo ui method that shows the sudo command before it is run
- make log method synchronous again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants