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

getlogin() often lies, especially when run under "su" #386

Merged
merged 1 commit into from Aug 15, 2014

Conversation

juliandunn
Copy link
Contributor

Run under "su", Ohai incorrectly returns the calling user as node['current_user'] because getlogin() lies to us.
According to the Ruby documentation, it's safer to use getpwuid().

…urns the

calling user, so node['current_user'] is set incorrectly in this case.
According to the Ruby documentation, it's safer to use getpwuid().
@sersut
Copy link

sersut commented Aug 14, 2014

Would this be a potential backwards compat issue?

@juliandunn
Copy link
Contributor Author

I guess it's technically a breaking change, though the old behavior is a bug. We should call it out in release notes or something.

@lamont-granquist
Copy link
Contributor

So, technically its not really a lie, its just that getlogin uses the 'real' uid while you've changed it to report the 'effective' uid -- but 'effective' uid is really what you're trying to get at... When running 'su ohai' you want it to be 'root' and not the caller of su.

Seems to fix behavior that nobody wants, so I wouldn't really consider it 'breaking'.

👍

juliandunn added a commit that referenced this pull request Aug 15, 2014
getlogin() often lies, especially when run under "su"
@juliandunn juliandunn merged commit 28dcc46 into chef:master Aug 15, 2014
@juliandunn juliandunn deleted the getlogin-lies branch August 15, 2014 19:12
@hiremaga
Copy link

Sorry for joining this conversation so late, I've only just noticed this change with ohai 8.0.1.

Unfortunately Pivotal Sprout's cookbooks rely pretty heavily on the old behavior and in fact have relied on it for quite a few years now.

Did folks run into real world recipes/situations where the new behavior was needed?

@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

Successfully merging this pull request may close these issues.

None yet

5 participants