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

[enhancement] mcollective agent as non-root #135

Closed
GeoffWilliams opened this issue Feb 23, 2015 · 7 comments
Closed

[enhancement] mcollective agent as non-root #135

GeoffWilliams opened this issue Feb 23, 2015 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@GeoffWilliams
Copy link
Contributor

Summary

It would be a nice enhancement if the mcollective agent installed via:

include r10k::mcollective

Had an option to execute the r10k command as an unprivileged user. Running as non-root is a requirement for some deployments.

Approaches

  • Switch users in files/agent/r10k.rb
  • Make the mcollective listener run as non-root from the start of execution
@elyscape
Copy link
Contributor

Approach 2 is nonworkable because it involves changing infrastructure that isn't actually related to this project.

@acidprime
Copy link
Collaborator

Sounds like a good feature request. I assume you have multiple masters right? i.e. you have to/want to use the mcollective agent rather then just run the webhook as the respective user i.e. https://github.com/acidprime/r10k#running-without-mcollective for your specific case.

If you want to submit a PR , then I would be glad to review it, issue is that it appears the shell class in mcollective does not let you pass a user.

https://github.com/puppetlabs/marionette-collective/blob/master/lib/mcollective/shell.rb#L28-L35

This likely means we would need to have it sudo -u or something similar and pass through the username like we do the branch.

We could also not use that class and start using spawn simliar to the shell agent but thats a little more then a patch https://github.com/puppetlabs/mcollective-shell-agent/blob/master/lib/mcollective/agent/shell.ddl#L20-L27

@acidprime acidprime added this to the Version 3.0 milestone Feb 23, 2015
@acidprime acidprime added the enhancement New feature or request label Feb 23, 2015
@elyscape
Copy link
Contributor

The shell agent doesn't appear to actually use the user parameter.

I would highly recommend against sudo. It requires certain settings in the /etc/sudoers file, such as Defaults !requiretty. Instead, you should use su - username -c COMMAND. This will work so long as the mcollective user has superuser privileges, which is generally going to be the case.

@GeoffWilliams
Copy link
Contributor Author

That's great feedback Eli - I'm going to start putting together a PR to add this functionality shortly, I'm planning to go down the route of using su to execute the R10K command

@elyscape
Copy link
Contributor

Be advised that you'll need to quote the command if it contains spaces, otherwise all the arguments will get lost. Furthermore, we want file redirection to happen on the outside of the su command so that the files are owned by the mcollective user, so you'll want to do something like su - username -c "COMMAND" >/path/to/outfile.

Edit: Actually, since redirection can be done from the run() function, that'd be better in general.

@GeoffWilliams
Copy link
Contributor Author

Thats really helpful, thanks so much!

I've finished for the day now but I should be able to get onto this in the next couple of days

On 24 February 2015 6:56:24 PM AEDT, Eli Young notifications@github.com wrote:

Be advised that you'll need to quote the command if it contains spaces,
otherwise all the arguments will get lost. Furthermore, we want file
redirection to happen on the outside of the su command so that the
files are owned by the mcollective user, so you'll want to do something
like su - username -c "COMMAND" >/path/to/outfile.


Reply to this email directly or view it on GitHub:
https://github.com/acidprime/r10k/issues/135#issuecomment-75713604

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@GeoffWilliams
Copy link
Contributor Author

Created https://github.com/acidprime/r10k/pull/141 to address this - let me know what you think. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants