Skip to content

Unset GIT_SSH_COMMAND before exec'ing git command #435

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Dec 13, 2019

Conversation

mzagrabe
Copy link

@mzagrabe mzagrabe commented Dec 5, 2019

Per: "man git", GIT_SSH_COMMAND will take precedence over GIT_SSH. Thus,
if GIT_SSH_COMMAND is set and leaks into the environment, then this
module's use of the GIT_SSH environment variable will not work.

Unset GIT_SSH_COMMAND for the environment in which the git command
execs.

Per: "man git", GIT_SSH_COMMAND will take precedence over GIT_SSH. Thus,
if GIT_SSH_COMMAND is set and leaks into the environment, then this
module's use of the GIT_SSH environment variable will not work.

Unset GIT_SSH_COMMAND for the environment in which the git command
execs.
@mzagrabe mzagrabe requested a review from a team as a code owner December 5, 2019 18:13
@jcbollinger
Copy link

jcbollinger commented Dec 6, 2019

Are you sure that this PR fixes the right problem? I would be inclined to say that the problem is more general: not that this particular variable is leaking in, but that environment variables are leaking in from the agent's environment at all. The solution to that would be to take complete control of the environment of the git command (and to keep it as sparse as possible), not to exclude unwanted variables on a one-off basis every time a problem is discovered.

@mzagrabe
Copy link
Author

mzagrabe commented Dec 6, 2019 via email

@jcbollinger
Copy link

I believe the problem is only manifesting itself when I run "puppet agent
-t" via an interactive shell. I don't think the puppet daemon running is
suffering environment contamination.

I'm inclined to suspect that Puppet experiences exactly the same environment contamination whether run with --onetime (or with -t or --test, which imply --onetime) as it does when run without any of those options, as a daemon. If you haven't observed that then it is probably because the daemon is being started without the troublesome variable in its environment in the first place.

But that's beside the point, which is that the specific problem observed appears to be a symptom of a broader issue, and it would be better to solve that broader issue than to solve only this one special case. Otherwise, it is likely that some time in the future, substantially the same problem is going to need to be solved again.

The patch does fix the issue I was experiencing.

I don't doubt that it does, and that is an excellent way of establishing that you have characterized the problem correctly. Good work identifying the issue.

I understand that a better solution might be to fully sanitize the environment.

Then I really haven't anything more to say on the topic. I have no say in whether the PR is accepted -- I'm merely offering commentary. To be perfectly clear, however, my opinion is that the PR should be rejected in favor of a solution (not yet offered, to my knowledge) that resolves the issue by whitelisting environment variables or by exercising full control of the git environment.

On a separate topic, however, this is a Puppet-maintained module, so have you filed an issue against it in Puppet, Inc.'s bug tracker? Doing so will more effectively draw the attention of the right people.

@mzagrabe
Copy link
Author

mzagrabe commented Dec 6, 2019 via email

Copy link

@DavidS DavidS left a comment

Choose a reason for hiding this comment

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

While @jcbollinger is right that other environment variables might also impact git's functioning, this is fixing an active problem, and there is nobody volunteering to fix the hypothetical bigger problem. I'll merge this for now.

@DavidS DavidS merged commit 7cf5954 into puppetlabs:master Dec 13, 2019
@DavidS DavidS added the bugfix label Feb 17, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants