Bug 1300686 - Environment variable not passed into mock chroot
Environment variable not passed into mock chroot
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
x86_64 Linux
unspecified Severity low
: ---
: ---
Assigned To: Miroslav Suchý
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2016-01-21 08:11 EST by Jeroen Koekkoek
Modified: 2016-02-26 06:17 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-02-26 06:17:54 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jeroen Koekkoek 2016-01-21 08:11:43 EST
Description of problem:
Environment variables exported by user are not imported into mock chroot even though the variable is assigned the same value as the current environment variable. Like so:

config_opts['environment']['VAR'] = os.environ['VAR']

This does work when running mock through sudo.

Version-Release number of selected component (if applicable):

How reproducible:
export FOO=bar
mock --shell
echo $FOO (in shell)

export FOO=bar
sudo mock --shell
echo $FOO (in shell)

Steps to Reproduce:
See above.
Comment 1 Jan Kurik 2016-02-24 10:44:39 EST
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
Comment 2 Miroslav Suchý 2016-02-26 06:17:54 EST
This is because /usr/bin/mock is in fact consolehelper which clean up environment and gain root right and execute /usr/sbin/mock.

As root you probably directly executed /usr/sbin/mock which is first in your path.
Note that there is already plan to change those paths in bug 1246810.

So if you want to preserve some variable, you can alter /etc/security/console.apps/mock and add to KEEP_ENV_VARS variables the list of variables you want to preserve.

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