Bug 1204395 - mock-scm not using SSH_AUTH_SOCK environment variable
Summary: mock-scm not using SSH_AUTH_SOCK environment variable
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-21 15:57 UTC by Roy Bonser
Modified: 2015-06-20 21:13 UTC (History)
7 users (show)

Fixed In Version: mock-1.2.10-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-05-12 20:46:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to allow SSH_AUTH_SOCK to be propagated to the SCM processing (926 bytes, text/plain)
2015-03-26 21:03 UTC, Eric Schnoebelen
no flags Details

Description Roy Bonser 2015-03-21 15:57:16 UTC
Description of problem:
I'm new to trying out the scm integration for mock but if I'm reading the code right my SSH_AUTH_SOCK env var should be passed along to the git command within mock and it should also set my HOME env var as well during the scm operations. What I see in the debug output however is that the vars are getting set to values for root causing my clones to fail.

DEBUG: Executing command: ['git', 'clone', 'git', '----'] with env {'LANG': 'en_US.UTF-8', 'USERHELPER_UID': '1000', 'TERM': 'xterm-256color', 'SHELL': '/bin/bash', 'SSH_AUTH_SOCK': '/root/.ssh/auth_sock', 'CVS_RSH': 'ssh', 'LOGNAME': 'root', 'USER': 'root', 'PATH': '/usr/sbin:/usr/bin:/sbin:/bin:/root/bin', 'HOME': '/root', 'DISPLAY': ':0'} and shell False

My var is set:
$ echo $SSH_AUTH_SOCK
/run/user/1000/keyring/ssh

Version-Release number of selected component (if applicable):
I have tried this on f21 and epel7
mock-1.2.7-1.el7.noarch
mock-scm-1.2.7-1.el7.noarch
mock-1.2.7-1.fc21.noarch
mock-scm-1.2.7-1.fc21.noarch

How reproducible:
always

Steps to Reproduce:
1. configure mock to clone a git repo
2. run a mock build
3.

Actual results:
The env vars are set for root

Expected results:
The env vars should be passed in from my environment

Additional info:

Comment 1 Eric Schnoebelen 2015-03-26 20:36:29 UTC
A bit of background for developers.

In the 1.1.41 sources, where this worked, all the SCM actions were taken before SSH_AUTH_SOCK was purged from the environment.  Now it is purged from the environment, and then *all* actions are handled, including SCM.  The SCM code has always tried to accommodate this possibility by setting  SSH_AUTH_SOCK to a default value (~/.ssh/auth_sock), but that is not the value used by most desktop environments, or even ssh-agent.

Comment 2 Eric Schnoebelen 2015-03-26 21:03:02 UTC
A proposed solution for problem is the attached patch. 

It moves the purging of SSH_AUTH_SOCK into run_commands, following the scm processing.  This  mimics the flow that was used in 1.1.41 and earlier.

In following the code  paths between where SSH_AUTH_SOCK was previously purged and where it is now purged, I saw no indications that the environment variable being available would cause problems.

Comment 3 Eric Schnoebelen 2015-03-26 21:03:55 UTC
Created attachment 1006981 [details]
Patch to allow SSH_AUTH_SOCK to be propagated to the SCM processing

Comment 4 Miroslav Suchý 2015-04-20 23:06:00 UTC
Patch looks good. Thanks for the initial work.
However it is just another hack. I recently stumbled upon another issue with environment. So I enhanced uidManager and it now (re)store environment when dropping and restoring Privs. So it preserve all variables, not just SSH_AUTH_SOCK.

This way you have untouched enviroment in get_sources(), because of:
        buildroot.uid_manager.dropPrivsTemp()
        scmWorker.get_sources()
        buildroot.uid_manager.restorePrivs()

Commited as:
* 5bfbd5d save/restore os.environ when dropping/restoring Privs [RHBZ#1204395]

Comment 5 Fedora Update System 2015-04-29 13:16:42 UTC
mock-1.2.8-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/mock-1.2.8-1.fc22

Comment 6 Fedora Update System 2015-04-29 13:17:06 UTC
mock-1.2.8-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/mock-1.2.8-1.fc21

Comment 7 Fedora Update System 2015-04-29 13:18:15 UTC
mock-1.2.8-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.2.8-1.fc20

Comment 8 Fedora Update System 2015-04-29 13:19:10 UTC
mock-1.2.8-1.el7 has been submitted as an update for Fedora EPEL 7.
https://admin.fedoraproject.org/updates/mock-1.2.8-1.el7

Comment 9 Fedora Update System 2015-04-29 13:25:53 UTC
mock-1.2.8-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.2.8-1.el6

Comment 10 Fedora Update System 2015-04-29 19:18:52 UTC
Package mock-1.2.8-1.el7:
* should fix your issue,
* was pushed to the Fedora EPEL 7 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=epel-testing mock-1.2.8-1.el7'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2015-6057/mock-1.2.8-1.el7
then log in and leave karma (feedback).

Comment 11 Roy Bonser 2015-04-30 13:24:28 UTC
I just installed mock-1.2.8 from testing and this issue is not resolved. It looks like it is now pulling in the environment of the mockuser from within the chroot as the SSH_AUTH_SOCK var is missing and the HOME is set to /builddir:

DEBUG: Executing command: ['git', 'clone', 'git', '----'] with env {'LANG': 'en_US.utf8', 'USERHELPER_UID': '1000', 'TERM': 'xterm-256color', 'SHELL': '/bin/bash', 'LOGNAME': 'root', 'USER': 'root', 'PATH': '/usr/sbin:/usr/bin:/sbin:/bin:/root/bin', 'HOME': '/builddir', 'DISPLAY': ':0'} and shell False

The git clone failed to find the ssh key and mock errored out. I tried this on rhel7.

  --Roy

Comment 12 Roy Bonser 2015-04-30 17:24:22 UTC
It actually looks like the environment is getting set in scmWorker before the droppriv happens. As a test I grabbed the environment again inside scmWorker.get_sources() and that has what it needs.

  --Roy

Comment 13 Fedora Update System 2015-05-01 16:50:57 UTC
mock-1.2.8-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Roy Bonser 2015-05-01 17:01:27 UTC
This bug just closed when it moved out of testing but the issue still exists as noted in comment 12.

  --Roy

Comment 15 Fedora Update System 2015-05-02 18:08:36 UTC
mock-1.2.8-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Miroslav Suchý 2015-05-06 11:04:35 UTC
Should be fixed by commit:
* f0fa116  scm: do not keep copy of environ, this is now handled by uidmanager [RHBZ#1204395]

Comment 17 Fedora Update System 2015-05-12 20:46:45 UTC
mock-1.2.8-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Fedora Update System 2015-05-14 06:04:51 UTC
mock-1.2.9-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/mock-1.2.9-1.fc21

Comment 19 Fedora Update System 2015-05-14 06:05:47 UTC
mock-1.2.9-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.2.9-1.fc20

Comment 20 Fedora Update System 2015-05-25 06:48:47 UTC
mock-1.2.9-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/mock-1.2.9-1.fc22

Comment 21 Fedora Update System 2015-05-27 16:26:24 UTC
mock-1.2.9-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 22 Fedora Update System 2015-05-27 16:28:12 UTC
mock-1.2.9-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 23 Fedora Update System 2015-06-04 11:41:47 UTC
mock-1.2.10-1.el7 has been submitted as an update for Fedora EPEL 7.
https://admin.fedoraproject.org/updates/mock-1.2.10-1.el7

Comment 24 Fedora Update System 2015-06-04 11:42:59 UTC
mock-1.2.10-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.2.10-1.el6

Comment 25 Fedora Update System 2015-06-04 20:15:35 UTC
mock-1.2.9-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 26 Fedora Update System 2015-06-20 21:10:40 UTC
mock-1.2.10-1.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 27 Fedora Update System 2015-06-20 21:13:11 UTC
mock-1.2.10-1.el7 has been pushed to the Fedora EPEL 7 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.