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

sudo ohai reports root as current_user instead of the value of SUDO_USER #451

Closed
hiremaga opened this issue Dec 20, 2014 · 5 comments
Closed

Comments

@hiremaga
Copy link

This behavior appears to have changed in fec9467. Unfortunately the change breaks nearly all the recipes in Pivotal Sprout, which is normally run with sudo on OS X.

Was this change intentional?

Previously:

ruby 2.0.0p481 (system) ~
○ → ohai --version
Ohai: 7.4.0

ruby 2.0.0p481 (system) ~
○ → sudo ohai | grep current_user
  "current_user": "hiremaga",

Now:

ruby 2.0.0p481 (system) ~
○ → ohai --version
Ohai: 8.0.1

ruby 2.0.0p481 (system) ~
○ → sudo ohai | grep current_user
  "current_user": "root",

@lamont-granquist
Copy link
Contributor

Yes that was the intent of the PR.

@hiremaga
Copy link
Author

Thanks @lamont-granquist

Is there a recommended way to determine the SUDO_USER within a chef recipe? We used to rely on node['current_user'] for this. Should we use `ENV['SUDO_USER'] or is there an attribute exposed for this?

The convenient thing about the old behavior is that it permitted a run list with a mix of recipes that require sudo and recipes that don't.

@hiremaga
Copy link
Author

Commented on #386 as well, fwiw.

@lamont-granquist
Copy link
Contributor

ENV['SUDO_USER'] is most likely what you want, i think that's better than the old code for current_user for your use case.

@hiremaga
Copy link
Author

ENV['SUDO_USER'] appears to work well for Sprout, closing this issue.

Thanks!

@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants