Bug#890436: systemd-sysv-install uses ROOT variable from environment for chrooting

2018-02-14 Thread Martin Pitt
Control: tag -1 pending

Hello Lars,

Lars Michelsen [2018-02-14 17:32 +]:
> systemd-sysv-install uses `ROOT` variable from environment when not set
> via `-r` and tries to execute update-rc.d chrooted to the content of
> this variable.

Thanks for the report! Fixed:

  https://salsa.debian.org/systemd-team/systemd/commit/47b7d3278d7f

Martin



Bug#890436: systemd-sysv-install uses ROOT variable from environment for chrooting

2018-02-14 Thread Michael Biebl
Am 14.02.2018 um 18:32 schrieb Lars Michelsen:
> Package: systemd
> Version: 232-25+deb9u1
> Severity: normal
> 
> systemd-sysv-install uses `ROOT` variable from environment when not set
> via `-r` and tries to execute update-rc.d chrooted to the content of
> this variable.

Both CHROOT and ROOT are set conditionally, but CHROOT is used
uncoditionally later on.

We should unset both CHROOT and ROOT at the beginning of the script (or
set it to an empty string).

Michael


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#890436: systemd-sysv-install uses ROOT variable from environment for chrooting

2018-02-14 Thread Lars Michelsen
Package: systemd
Version: 232-25+deb9u1
Severity: normal

systemd-sysv-install uses `ROOT` variable from environment when not set
via `-r` and tries to execute update-rc.d chrooted to the content of
this variable.

I'm am a bit unsure whether or not this really is a bug, but since it
was a total surprise for me when I found the cause of the issue and I
did not find any documentation about this behaviour, I think this is a
bug.

*Expected behaviour I didn't see*

root@Klappspaten:/# systemctl enable ssh
Synchronizing state of ssh.service with SysV service script with
/lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable ssh
Created symlink /etc/systemd/system/sshd.service →
/lib/systemd/system/ssh.service.

*Unexpected behaviour I saw*

When ROOT is e.g. set to /dev/sda1, this issue occurs:

root@Klappspaten:/# systemctl enable ssh
Synchronizing state of ssh.service with SysV service script with
/lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable ssh
chroot: cannot change root directory to "'/dev/sda1'": No such file or
directory

*Steps to reproduce the problem*

Simply set the environment variable and try to enable a service that is
also available as SysV-Init-Script

root@Klappspaten:/# export ROOT=/dev/sda1
root@Klappspaten:/# systemctl enable ssh
Synchronizing state of ssh.service with SysV service script with
/lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable ssh
chroot: cannot change root directory to "'/dev/sda1'": No such file or
directory

*Possible solution*

ROOT should be initialized with an empty value before reading command
line options.

*References*

https://github.com/systemd/systemd/issues/8180
https://salsa.debian.org/systemd-team/systemd/blob/master/debian/extra/systemd-sysv-install

-- Package-specific info:

-- System Information:
Debian Release: 9.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages systemd depends on:
ii  adduser 3.115
ii  libacl1 2.2.52-3+b1
ii  libapparmor12.11.0-3
ii  libaudit1   1:2.6.7-2
ii  libblkid1   2.29.2-1
ii  libc6   2.24-11+deb9u1
ii  libcap2 1:2.25-1
ii  libcryptsetup4  2:1.7.3-4
ii  libgcrypt20 1.7.6-2+deb9u2
ii  libgpg-error0   1.26-2
ii  libidn111.33-1
ii  libip4tc0   1.6.0+snapshot20161117-6
ii  libkmod223-2
ii  liblz4-10.0~r131-2+b1
ii  liblzma55.2.2-1.2+b1
ii  libmount1   2.29.2-1
ii  libpam0g1.1.8-3.6
ii  libseccomp2 2.3.1-2.1
ii  libselinux1 2.6-3+b3
ii  libsystemd0 232-25+deb9u1
ii  mount   2.29.2-1
ii  procps  2:3.3.12-3
ii  util-linux  2.29.2-1

Versions of packages systemd recommends:
ii  dbus1.10.24-0+deb9u1
ii  libpam-systemd  232-25+deb9u1

Versions of packages systemd suggests:
pn  policykit-1
pn  systemd-container  
pn  systemd-ui 

Versions of packages systemd is related to:
pn  dracut   
ii  initramfs-tools  0.130
ii  udev 232-25+deb9u1

-- Configuration Files:
/etc/systemd/logind.conf changed [not included]

-- no debconf information