Bug 667243 - user with zsh as shell can't easily run chroot
user with zsh as shell can't easily run chroot
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
13
Unspecified Unspecified
low Severity medium
: ---
: ---
Assigned To: David Cantrell
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-04 17:14 EST by James Antill
Modified: 2013-01-10 01:24 EST (History)
7 users (show)

See Also:
Fixed In Version: mock-1.1.10-1.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-01-17 03:43:53 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description James Antill 2011-01-04 17:14:58 EST
Description of problem:
 mock documentation says it runs /bin/sh with "mock shell" but it actually appears to run the users $SHELL ... which is the same if the user has bash, not so much if the user has zsh.
 Changing it to always use /bin/sh is probably the simplest thing. I guess the "best" thing might be using $SHELL iff that file exists in the chroot?

Version-Release number of selected component (if applicable):
mock.noarch                      1.1.6-1.fc13                       @updates
Comment 1 Clark Williams 2011-01-04 17:50:37 EST
James,

mock just runs /usr/sbin/chroot; it's chroot that's picking up the value of $SHELL. 

As a work around you can specify what to run like this:

$ mock -r fedora-14-x86_64 --shell /bin/sh

which should do the "right" thing. I'll see if there's an easy way to deal with things like /bin/zsh; maybe just nuke the SHELL environment variable before we run the shell, which would force chroot to default to /bin/sh
Comment 2 James Antill 2011-01-04 18:08:58 EST
Yeh, I eventually worked out to add /bin/sh to the end (I think previously I'd usually just done an "install zsh", which also works :) it was just annoying and took me a while.

I didn't realize this was a chroot feature though, and given that chroot also fails:

% sudo chroot /var/lib/mock/fedora-14-i386/root
chroot: failed to run command `/bin/zsh': No such file or directory

...I'm going to reassign to coreutils.
Comment 3 Clark Williams 2011-01-04 18:14:17 EST
well, I can modify the shell invocation inside mock to include "SHELL='/bin/sh'" and that would default everyone to sh. Like so:

status = os.system("SHELL='/bin/sh' PS1='mock-chroot> ' /usr/sbin/chroot %s %s %s" % (arg, chroot.makeChrootPath(), cmd))

Would this work for you?
Comment 4 Ondrej Vasik 2011-01-10 06:38:08 EST
James, could you please explain what exactly is the bug here? chroot expects valid shell in SHELL envvar and this is perfectly documented - see info documentation - info chroot invocation. I see no bug in chroot and I think the proper solution in mock is the one proposed by Clark in comment #3.
Comment 5 James Antill 2011-01-10 10:43:43 EST
Ondrej, this is the bug:

% echo $SHELL
/bin/zsh
% ls -l $SHELL
-rwxr-xr-x. 1 root root 689944 Mar 22  2010 /bin/zsh
% sudo chroot /var/lib/mock/fedora-14-i386/root          
chroot: failed to run command `/bin/zsh': No such file or directory

...here $SHELL is valid for the main system, it just isn't valid for every chroot on the system. Saying that $SHELL must be valid for every possible chroot seems of dubious value (and I assume the only reason you haven't got 666 BZs already is because most people have bash, which is in almost all chroots).
Comment 6 Clark Williams 2011-01-10 11:11:19 EST
mock-1.1.8 has added the 'SHELL=/bin/sh' to the chroot invocation, so everyone should be using /bin/sh in the chroot now.
Comment 7 Kamil Dudka 2011-01-10 12:04:32 EST
(In reply to comment #5)
> Ondrej, this is the bug:
> 
> % echo $SHELL
> /bin/zsh
> % ls -l $SHELL
> -rwxr-xr-x. 1 root root 689944 Mar 22  2010 /bin/zsh
> % sudo chroot /var/lib/mock/fedora-14-i386/root          
> chroot: failed to run command `/bin/zsh': No such file or directory

I agree with Ondrej.  There is nothing to fix in chroot.
Comment 8 Ondrej Vasik 2011-01-17 03:43:53 EST
Info documentation states:
"`chroot' changes the root to the
directory NEWROOT (which must exist) and then runs COMMAND with
optional ARGS.  If COMMAND is not specified, the default is the value
of the `SHELL' environment variable or `/bin/sh' if not set, invoked
with the `-i' option."

chroot utility has nothing to do with "no zsh in every chroot on the system" - this has to be covered by user. You can't use the shell binary from old chroot, as the binary could be (and many times is) dynamically linked and the .so files probably will be missing in chroot as well.

Closing NOTABUG, as this is not a bug in chroot command and current behaviour is documented.
Comment 9 Fedora Update System 2011-01-18 14:57:52 EST
mock-1.1.8-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.8-1.fc14
Comment 10 Fedora Update System 2011-01-18 14:58:32 EST
mock-1.1.8-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.8-1.fc13
Comment 11 Fedora Update System 2011-01-18 15:03:25 EST
mock-1.0.15-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.15-1.el5
Comment 12 Fedora Update System 2011-01-21 18:03:20 EST
mock-1.1.8-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 13 Kamil Dudka 2011-01-21 18:17:17 EST
There has been nothing changed in coreutils.  I am reassigning back to mock in order to avoid unnecessary confusion...
Comment 14 Fedora Update System 2011-02-19 21:25:34 EST
mock-1.1.9-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.fc13
Comment 15 Fedora Update System 2011-02-19 21:28:46 EST
mock-1.0.16-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.16-1.el5
Comment 16 Fedora Update System 2011-02-19 21:31:43 EST
mock-1.1.9-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.el6
Comment 17 Fedora Update System 2011-02-19 21:34:34 EST
mock-1.1.9-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.fc14
Comment 18 Fedora Update System 2011-03-03 03:24:03 EST
mock-1.1.9-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 19 Fedora Update System 2011-03-03 03:33:05 EST
mock-1.1.9-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 20 Fedora Update System 2011-05-13 16:33:14 EDT
mock-1.1.10-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc15
Comment 21 Fedora Update System 2011-05-13 16:38:07 EDT
mock-1.1.10-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc14
Comment 22 Fedora Update System 2011-05-13 16:42:25 EDT
mock-1.0.17-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.17-1.el5
Comment 23 Fedora Update System 2011-05-13 16:46:39 EDT
mock-1.1.10-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc13
Comment 24 Fedora Update System 2011-05-13 16:50:56 EDT
mock-1.1.10-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.el6
Comment 25 Fedora Update System 2011-05-19 00:34:42 EDT
mock-1.1.10-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 26 Fedora Update System 2011-05-24 22:42:06 EDT
mock-1.1.10-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 27 Fedora Update System 2011-05-24 23:16:26 EDT
mock-1.1.10-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 28 Fedora Update System 2011-06-02 15:06:16 EDT
mock-1.0.17-1.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 29 Fedora Update System 2011-06-02 15:16:18 EDT
mock-1.1.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.

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