Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1311796 - --new-chroot causes incorrect $PATH
Summary: --new-chroot causes incorrect $PATH
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:
: 1299494 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-25 02:06 UTC by Colin Walters
Modified: 2016-06-02 14:31 UTC (History)
8 users (show)

Fixed In Version: mock-1.2.17-1.fc22 mock-1.2.17-1.fc24 mock-1.2.17-1.el6 mock-1.2.17-1.el7 mock-1.2.17-1.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-03-31 01:53:51 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
0001-backend-Ensure-our-environment-is-set-for-rpmbuild-a.patch (3.46 KB, patch)
2016-02-25 03:00 UTC, Colin Walters
no flags Details | Diff

Description Colin Walters 2016-02-25 02:06:41 UTC
$ rpm -q mock
mock-1.2.15-1.el7.noarch

I was trying to build an updated glib for centos7, which needed an updated gtk-doc, and got a strange error in the chain (rpmdistro-gitoverlay) that /bin/python couldn't be resolved.

I tracked this down to --new-chroot causing /bin to be earlier in $PATH:

<walters> if i add an echo in %build I get: PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/builddir/.local/bin:/builddir/bin  yet mock --shell echo $PATH has /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin as i'd expect

$ mock --new-chroot -r epel-7-x86_64 /mnt/Nomad/gtk-doc-1.19-3.el7.src.rpm
...
Requires: /bin/perl /bin/python /bin/sh /usr/bin/pkg-config perl(Cwd) 
...

$ mock --old-chroot -r epel-7-x86_64 /mnt/Nomad/gtk-doc-1.19-3.el7.src.rpm
...
Requires: /bin/sh /usr/bin/perl /usr/bin/pkg-config /usr/bin/python perl(Cwd) perl(Getopt::Long) perl(bytes) perl(strict)
...

Comment 1 Colin Walters 2016-02-25 02:59:27 UTC
I am really mystified at what is munging the path that way...tentatively thinking it's something involving systemd-nspawn running through PAM in the new root?

Really...we should just kill /bin and /sbin from $PATH.

Comment 2 Colin Walters 2016-02-25 03:00:00 UTC
Created attachment 1130420 [details]
0001-backend-Ensure-our-environment-is-set-for-rpmbuild-a.patch

Anyways, this patch fixes it for me.

Comment 3 Miroslav Suchý 2016-02-26 11:08:23 UTC
This comes from default config. See /etc/mock/site-defaults.cfg
  config_opts['environment']['PATH'] = '/usr/bin:/bin:/usr/sbin:/sbin'

> Really...we should just kill /bin and /sbin from $PATH.

Not possible because EL5 and EL6 still have it.

> /bin/python couldn't be resolved.

This is not because of $PATH because /bin/ is in $PATH after /usr/bin.
I suspect that this is because some package either
1) requires /bin/python or
2) have in some script #!/bin/python so rpmbuild take it as automatic requires which is equivalent of 1)
And epel7 (and fedoras) no longer provides /bin/* automatic provides generated from filelist (I recall some discussion about it on devel mailing list).

To sum it up. This is likely packaging issue. If you really need to alter env, then you can use config to change it.

Comment 4 Colin Walters 2016-02-26 13:29:54 UTC
(In reply to Miroslav Suchý from comment #3)
> This comes from default config. See /etc/mock/site-defaults.cfg
>   config_opts['environment']['PATH'] = '/usr/bin:/bin:/usr/sbin:/sbin'

I did not change the mock config between the two runs.

> > Really...we should just kill /bin and /sbin from $PATH.
> 
> Not possible because EL5 and EL6 still have it.

Sure, though we could conditionalize on distribution major likely.

> > /bin/python couldn't be resolved.
> 
> This is not because of $PATH because /bin/ is in $PATH after /usr/bin.

Did you even read my patch?  It *is* because of $PATH, I added an "echo PATH=$PATH" in gtk-doc's %build and saw it was wrong.  

Again, I think what's happening here is that for non-nspawn, we inherit the environment from doChroot().  But nspawn cleans the environment, so we need to inject it into our command.

> 2) have in some script #!/bin/python so rpmbuild take it as automatic
> requires which is equivalent of 1)

Yes, and that happens because it's found first in $PATH when using nspawn.

> To sum it up. This is likely packaging issue.

No, this is using unmodified CentOS 7 packages.  Just try it!

Comment 5 Miroslav Suchý 2016-02-26 14:41:18 UTC
Ah, you are right. I tried to alter it and it is indeed not passed to nspawn container.

However I do not think your approach is correct as it just fix rebuilds. If you use e.g. --shell then you do not have those variables defined.

I think correct way is to alter util._prepare_nspawn_command() to get environment and pass it to systemd-nspawn as --set-env=KEY=VALUE.

Comment 6 Colin Walters 2016-02-26 15:11:35 UTC
It's definitely something in the PAM stack which is breaking $PATH:

```
$ sudo systemd-nspawn -D /var/lib/mock/epel-7-x86_64/root
Spawning container root on /var/lib/mock/epel-7-x86_64/root.
Press ^] three times within 1s to kill container.
-bash-4.2# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-bash-4.2# su -l mockbuild
Last login: Fri Feb 26 10:10:27 EST 2016 on console
[mockbuild@root ~]$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/builddir/.local/bin:/builddir/bin
[mockbuild@root ~]$ 
```

Comment 7 Colin Walters 2016-02-26 15:27:14 UTC
Which means using --set-env for nspawn won't work, we need to do it after su.  I'm not sure I have the stomach this morning to read the PAM code and figure out what's doing it, but even if we fixed PAM, we'd still need to support older distros...so we need to call `env` after `su` inside _prepare_nspawn_command(), agreed?

Comment 8 Miroslav Suchý 2016-02-26 16:19:38 UTC
Fixed in commit:
* 057c51d (HEAD -> devel, origin/devel) tell nspawn which variables it should set [RHBZ#1311796]

I modified:
  config_opts['environment']['PATH'] = '/usr/bin:/usr/sbin'
and put in my spec:
  %build
  echo PATH is: $PATH
and run:
  $ mock -r epel-7-x86_64 --new-chroot /home/msuchy/rpmbuild/SRPMS/copr-ping-1-1.fc23.src.rpm
....
Provádění(%build): /bin/sh -e /var/tmp/rpm-tmp.7kbQOk
PATH is: /usr/bin:/usr/sbin

Can you test if it pass your tests, please?

Comment 9 Colin Walters 2016-02-26 16:35:58 UTC
Ah, I see you changed more code to avoid shell strings.  That is definitely better.  I had a patch in progress for similar changes like -u mockbuild instead of su.

Works for me.

Comment 10 Colin Walters 2016-02-26 16:53:18 UTC
I take that back, there's some other regression:

With devel tip @ 057c51d6a0e47377a45f811ec7c0c013c4c31e00:

$ mock -r fedora-23-i386 packaging/ostree-2016.2.9.g5345573-3.el7.src.rpm
...
INFO: Installed packages:
Start: build phase for ostree-2016.2.9.g5345573-3.el7.src.rpm
Start: build setup for ostree-2016.2.9.g5345573-3.el7.src.rpm
ERROR: Exception(packaging/ostree-2016.2.9.g5345573-3.el7.src.rpm) Config(fedora-23-i386) 0 minutes 56 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-23-i386/result
ERROR: Expected to find single rebuilt srpm, found 0.
WARNING: unable to delete selinux filesystems (/tmp/mock-selinux-plugin.3xSybj): [Errno 1] Operation not permitted: '/tmp/mock-selinux-plugin.3xSybj'

With the previous devel @ a9a957dbe23aa0c9ac1245897bf94ed70b78c951 it works.

Comment 11 Miroslav Suchý 2016-03-07 12:51:26 UTC
(In reply to Colin Walters from comment #10)
> WARNING: unable to delete selinux filesystems
> (/tmp/mock-selinux-plugin.3xSybj): [Errno 1] Operation not permitted:
> '/tmp/mock-selinux-plugin.3xSybj'
> 
> With the previous devel @ a9a957dbe23aa0c9ac1245897bf94ed70b78c951 it works.

That is bug 1312820

Comment 12 Fedora Update System 2016-03-08 20:53:22 UTC
mock-1.2.16-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-66229b4649

Comment 13 Fedora Update System 2016-03-08 20:53:48 UTC
mock-1.2.16-1.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-3405d4e45b

Comment 14 Fedora Update System 2016-03-08 20:54:22 UTC
mock-1.2.16-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-a9958aa8eb

Comment 15 Fedora Update System 2016-03-08 20:54:39 UTC
mock-1.2.16-1.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-bbb4bfc16f

Comment 16 Fedora Update System 2016-03-08 20:54:58 UTC
mock-1.2.16-1.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-25ff2f1000

Comment 17 Fedora Update System 2016-03-09 21:23:32 UTC
mock-1.2.16-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-66229b4649

Comment 18 Fedora Update System 2016-03-09 22:55:31 UTC
mock-1.2.16-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-a9958aa8eb

Comment 19 Fedora Update System 2016-03-09 23:18:30 UTC
mock-1.2.16-1.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-25ff2f1000

Comment 20 Fedora Update System 2016-03-09 23:21:01 UTC
mock-1.2.16-1.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-3405d4e45b

Comment 21 Fedora Update System 2016-03-10 01:56:50 UTC
mock-1.2.16-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-bbb4bfc16f

Comment 22 Fedora Update System 2016-03-11 09:08:18 UTC
mock-1.2.17-1.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-bbb4bfc16f

Comment 23 Fedora Update System 2016-03-11 09:17:21 UTC
mock-1.2.17-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-66229b4649

Comment 24 Fedora Update System 2016-03-11 19:27:53 UTC
mock-1.2.17-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-bbb4bfc16f

Comment 25 Fedora Update System 2016-03-12 16:54:26 UTC
mock-1.2.17-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-66229b4649

Comment 26 Fedora Update System 2016-03-15 19:06:20 UTC
mock-1.2.17-1.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-23c93722c3

Comment 27 Fedora Update System 2016-03-15 19:06:47 UTC
mock-1.2.17-1.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-d4770f601d

Comment 28 Fedora Update System 2016-03-16 02:20:42 UTC
mock-1.2.17-1.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-d4770f601d

Comment 29 Fedora Update System 2016-03-16 02:50:58 UTC
mock-1.2.17-1.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-23c93722c3

Comment 30 Fedora Update System 2016-03-20 20:21:16 UTC
mock-1.2.17-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 31 Fedora Update System 2016-03-26 18:18:00 UTC
mock-1.2.17-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 32 Fedora Update System 2016-03-28 14:54:30 UTC
mock-1.2.16-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-a9958aa8eb

Comment 33 Fedora Update System 2016-03-28 20:49:49 UTC
mock-1.2.17-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-a9958aa8eb

Comment 34 Fedora Update System 2016-03-31 01:53:32 UTC
mock-1.2.17-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 35 Fedora Update System 2016-03-31 05:28:54 UTC
mock-1.2.17-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.

Comment 36 Fedora Update System 2016-04-02 04:21:01 UTC
mock-1.2.17-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 37 Miroslav Suchý 2016-06-02 14:31:31 UTC
*** Bug 1299494 has been marked as a duplicate of this bug. ***


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