#1345 PR merged: Initramfs need $PATH when running in chroot on sles11

Labels: enhancement, bug, cleanup, fixed / solved / done

schabrolles opened issue at 2017-05-06 15:21:

I just notice that initrd were not correctly created in sles11 since we change chroot usage (stop using loggin).

mkinitramfs call other tools (dirname, getent, perl ...) without a correctly configured $PATH, this operation failed.

Here is the way to reproduce it :

RESCUE sles11sap-144:~ # TARGET_FS_ROOT=/mnt/local
RESCUE sles11sap-144:~ # mount -t proc none $TARGET_FS_ROOT/proc
RESCUE sles11sap-144:~ # mount -t sysfs none $TARGET_FS_ROOT/sys
RESCUE sles11sap-144:~ # mkinitrd_binary=$( chroot $TARGET_FS_ROOT /bin/bash -c 'PATH=/sbin:/usr/sbin:/usr/bi
n:/bin type -P mkinitrd' )
RESCUE sles11sap-144:~ # chroot $TARGET_FS_ROOT $mkinitrd_binary

Kernel image:   /boot/vmlinux-3.0.101-63-ppc64
Initrd image:   /boot/initrd-3.0.101-63-ppc64
/lib/mkinitrd/setup/01-prepare.sh: line 183: getent: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 17: perl: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 18: [: too many arguments
/lib/mkinitrd/setup/01-splashy.sh: line 24: file: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 67: directfb-config: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot stat `/usr/lib/libdirect-1.2.so.0': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot stat `/usr/lib/libdirectfb-1.2.so.0': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot stat `/usr/lib/libfusion-1.2.so.0': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot create regular file `/dev/shm/.wsptH6/mnt//usr/lib/libpng12.so.0': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot create regular file `/dev/shm/.wsptH6/mnt//usr/lib/libglib-2.0.so.0': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot stat `/usr/lib/libsplashy.so.1': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
cp: cannot stat `/usr/lib/libsplashycnf.so.1': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 55: dirname: command not found
/lib/mkinitrd/setup/01-splashy.sh: line 60: dirname: command not found
cp: cannot create regular file `/dev/shm/.wsptH6/mnt//etc/splashy/config.xml': No such file or directory
/lib/mkinitrd/setup/01-splashy.sh: line 60: dirname: command not found
cp: omitting directory `/usr/share/splashy/themes//default'
ln: target `/dev/shm/.wsptH6/mnt/etc/splashy/' is not a directory: No such file or directory
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/02-start.sh: line 63: wc: command not found
/lib/mkinitrd/setup/02-start.sh: line 63: [: -gt: unary operator expected
/lib/mkinitrd/setup/03-kms.sh: line 71: tr: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: find: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: xargs: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: find: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: xargs: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: find: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: xargs: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: find: command not found
/lib/mkinitrd/setup/01-prepare.sh: line 41: xargs: command not found

jsmeix commented at 2017-05-08 07:54:

ReaR does no longer use a login shell in chroot
since I did https://github.com/rear/rear/pull/1171
but the root cause of that was to avoid issues
with basically broken setups of the 'root' user so that

chroot /mnt/local /bin/bash --login

fails, see https://github.com/rear/rear/issues/862

This issue here shows that my attempt to avoid possible
issues with https://github.com/rear/rear/pull/1171
may in practice cause more issues that it solves.

Therefore I am now thinking about if I should perhaps
better revert https://github.com/rear/rear/pull/117
and use a login shell by default for all 'chroot' calls
and add appropriate documentatiuon in ReaR that

chroot /mnt/local /bin/bash --login

is a required precondition for ReaR and I could also
implement a check in ReaR that tests whether or not
that actually works (during "rear mkbackup/mkrescue")
that errors out if it does not work, see
build/default/980_verify_rootfs.sh

@gdha @gozora @schlomo
I added you as reviewers here mainly because I like
to know your opinion about whether or not ReaR
should use a login shell by default for all 'chroot' calls,
see also my "Reason" in
https://github.com/rear/rear/issues/862#issuecomment-274068914

jsmeix commented at 2017-05-09 07:33:

By sleeping over it my mind produced a better idea:
First things first:
Accordingly I will merge this one soon because it fixes a bug.
Then we have all time we need to find out what the best way is
how 'chroot' commands should be done by default in ReaR.

jsmeix commented at 2017-05-09 07:37:

If there are no objections I will mege it in a few hours.

jsmeix commented at 2017-05-09 12:55:

Strange, at least for me the [Merge pull request] button
here at GitHub does no lnger work.
Nothing happens when I click it.
I tried two different Firefox browsers on two different machines
(one on SLES11 and another one on openSUSE Leap 42.1).

gozora commented at 2017-05-09 12:58:

@jsmeix
image

For me it looks to be working fine ...

Maybe try to clear cache ?

V.

jsmeix commented at 2017-05-09 13:47:

@gozora
it also worked for me on a third machine (my SLES12 test system)
where I use Firefox with its out-of-the-box default settings.
On my workstations where it does not work for me
I have somewhat more restricted Firefox settings.
Now I have fun with finding out what exact restriction makes
GitHub buttons and other interactive stuff like that
no longer work for me ;-)


[Export of Github issue for rear/rear.]