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 support for Sudo. #11

Merged
merged 8 commits into from
Sep 12, 2018
Merged

Add support for Sudo. #11

merged 8 commits into from
Sep 12, 2018

Conversation

skx
Copy link
Owner

@skx skx commented Sep 12, 2018

This pull-request is work-in-progress, but currently allows the use of the Sudo token to mark a following statement as requiring the use of sudo.

For example this is a normal script:

   DeployTo user@host.example.com
   Run "/usr/bin/id"

Expected output will be "user ..".

This would require the use of Sudo:

   DeployTo user@host.example.com
   Sudo Run "/usr/bin/id"

Expected output will be "root .."

This will close #8, when merged.

Steve Kemp and others added 8 commits September 12, 2018 12:32
This will let us detect the need for sudo.
This will be set to true if the statement needs to be operated
under the use of sudo.
With this commit the `Run` and `IfChanged` tokens will honour
the sudo-flag, if the appropriate token is seen.

For example this is "normal":

        Run "/usr/bin/id"

But this will run as root:

        Sudo Run "/usr/bin/id"

(Of course we need support in the evaluator before this actually
works; this is just the setup.)
We scan the statements to be executed before we run them, and
prompt for a sudo-password if the use of Sudo is in-place.

We then execute our command(s) with sudo as appropriate.

This makes our code functional.

TODO:

* More tests.
@skx skx merged commit 6ce4de3 into master Sep 12, 2018
@skx skx deleted the 8-support-sudo branch September 12, 2018 15:25
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.

No support for sudo
1 participant