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

Fix inspec detect on SLES #515

Merged
merged 9 commits into from
Nov 18, 2019
Merged

Fix inspec detect on SLES #515

merged 9 commits into from
Nov 18, 2019

Conversation

christian-wtd
Copy link
Contributor

@christian-wtd christian-wtd commented Sep 6, 2019

This is a fix for the broken remote execution of Inspec on SUSE SLES 12.

Description

More details can be found in inspec/inspec#4384

Basically the problem appears for non-root users with sudosh blocking OS detection without sudo and blocks any inspec run for remote operations. Neither the /etc/os-release file is readable nor the uname command is executable without sudo in such an environment.

This has been verified working with Inspec CLI and also Inspec Library Runner Class.

Related Issue

inspec/inspec#4384

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New content (non-breaking change)
  • Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • I have read the CONTRIBUTING document.

@chef-expeditor
Copy link
Contributor

chef-expeditor bot commented Sep 6, 2019

Hello christian-wtd! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. Possible Outcomes
    a. If everything looks good, one of them will approve it, and your PR will be merged.
    b. The maintainer may request follow-on work (e.g. code fix, linting, etc). We would encourage you to address this work in 2-3 business days to keep the conversation going and to get your contribution in sooner.
    c. Cases exist where a PR is neither aligned to Chef InSpec's product roadmap, or something the team can own or maintain long-term. In these cases, the maintainer will provide justification and close out the PR.

Thank you for contributing!

This is a fix for the broken remote execution of Inspec on SUSE SLES 12.

More details can be found in inspec/inspec#4384

Basically the problem appears for non-root users with sudosh blocking OS detection without sudo and blocks any inspec run for remote operations. Neither the /etc/os-release file is readable nor the uname command is executable without sudo in such an environment.

This has been verified working with Inspec CLI and also Inspec Library Runner Class.

Signed-off-by: christian-wtd <[email protected]>
@christian-wtd
Copy link
Contributor Author

Hello,

did anyone already had a chance to look at this?

Best regards
Christian

@clintoncwolfe clintoncwolfe self-requested a review September 23, 2019 16:11
@clintoncwolfe clintoncwolfe self-assigned this Sep 23, 2019
@clintoncwolfe clintoncwolfe changed the title Fix for: https://github.com/inspec/inspec/issues/4384 Fix inspec detect on SLES Sep 23, 2019
Copy link
Contributor

@clintoncwolfe clintoncwolfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @christian-wtd - Thanks for the contribution! You traced a problem across two software projects and found where to fix it, which is not easy - good work! Here's what I'd like to see to get this merged in:

  1. A refactor to move the conditional logic into one place
  2. If possible, try to read the sudo option from the @backend connection object rather than straight from @ARGV. That's safer - for example, --sudo might be abbreviated on the command line, or passed differently on the Runner API.

A great start!

lib/train/platforms/detect/helpers/os_common.rb Outdated Show resolved Hide resolved
lib/train/platforms/detect/helpers/os_common.rb Outdated Show resolved Hide resolved
christian-wtd and others added 4 commits September 23, 2019 22:49
This should be the real fix for the sudo detect issue.
Reverted changes on this file.
This should be the real fix for the sudo detect issue.

Signed-off-by: christian-wtd <[email protected]>
@christian-wtd
Copy link
Contributor Author

christian-wtd commented Sep 23, 2019

Ok. now I have fucked up GIT somehow :-(
there should be only one commit left for the
lib/train/transports/ssh_connection.rb
but I mixed it up.

christian-wtd added 4 commits September 24, 2019 05:22
@codeclimate
Copy link

codeclimate bot commented Sep 24, 2019

Code Climate has analyzed commit 27187a5 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2

View more on Code Climate.

@christian-wtd
Copy link
Contributor Author

So having the different approach now in the correct file we should be good to go and also we no longer use ARGV.
Single place, less code and more appropriate place.

@christian-wtd
Copy link
Contributor Author

the reference I made was wrong, should have pointed to my other pull request.

@clintoncwolfe clintoncwolfe requested a review from miah September 30, 2019 18:50
Copy link
Contributor

@clintoncwolfe clintoncwolfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me - thanks!

lib/train/transports/ssh_connection.rb Show resolved Hide resolved
@christian-wtd
Copy link
Contributor Author

Any ETA when this gets merged and released?

@christian-wtd
Copy link
Contributor Author

@miah & @clintoncwolfe :
It's nearly 2 months after approval, when this will be merged and released?

@miah miah merged commit 1eb18d4 into inspec:master Nov 18, 2019
@christian-wtd christian-wtd deleted the patch-1 branch November 19, 2019 05:03
@christian-wtd
Copy link
Contributor Author

Thank you very much!

@zenspider
Copy link
Contributor

This PR might need to be rolled back as it is causing severe problems in other areas (eg #538) and it is too hard to debug. It should probably also have had a test added before it was merged.

Further, I'm running sles 12 in a docker container and both uname and /etc/os-release are fine without sudo, so I'm really not sure what this is solving yet.

Finally, given the 9 commits vs the final diff, this should have been squashed or interactive rebased and cleaned up.

zenspider added a commit that referenced this pull request Nov 26, 2019
Causes regressions shown in #538 which I think is a bigger affected
set of users.

Until we can get this under test and reproducible, it needs to wait.

Signed-off-by: Ryan Davis <[email protected]>
@zenspider zenspider mentioned this pull request Nov 26, 2019
zenspider pushed a commit that referenced this pull request Nov 26, 2019
@zenspider
Copy link
Contributor

This has been addressed via #544.

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.

4 participants