Your message dated Fri, 6 Jan 2023 18:37:15 +0100
with message-id <[email protected]>
and subject line Re: Bug#910770: dash: systemd-detect-virt fails to detect 
virtualized environment when run under dash
has caused the Debian Bug report #910770,
regarding dash: systemd-detect-virt fails to detect virtualized environment 
when run under dash
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
910770: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910770
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: dash
Version: 0.5.7-4+b1
Severity: important

Dear Maintainer,

When run under dash, systemd-detect-virt returns "none" in a systemd-nspawn
chroot'd environment when it should not; same command under bash works
as expected.

Because /bin/sh is linked to /bin/dash, this causes the MAKEDEV post-inst
script not to realize it's in a virtual environment (despite tests added
in 2.3.1-93 and 2.3.1-94 versions of makedev package to detect precisely
this situation).

it will, therefore, attempt to inappropriately create devices in the
chroot. Which fails horribly, resulting in an uninstalled/unconfigured
package. (actually many, in a debootstrap run)

Which makes it more awkward than it should be to build an OS image via
debootstrap in a systemd-nspawn container without hackery or workarounds.


$ systemd-nspawn -D jessie-18-10-10/ /bin/bash -c "systemd-detect-virt"
Spawning container jessie-18-10-10 on /data/PXE/squashbuilder/jessie-18-10-10.
Press ^] three times within 1s to kill container.
systemd-nspawn
Container jessie-18-10-10 exited successfully.

$ systemd-nspawn -D jessie-18-10-10/ /bin/dash -c "systemd-detect-virt"
Spawning container jessie-18-10-10 on /data/PXE/squashbuilder/jessie-18-10-10.
Press ^] three times within 1s to kill container.
none
Container jessie-18-10-10 failed with error code 1.


-- System Information:
Debian Release: 8.11
  APT prefers oldstable
  APT policy: (500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.10-arch1-1-ARCH (SMP w/8 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Init: unable to detect

Versions of packages dash depends on:
ii  debianutils  4.4+b1
ii  dpkg         1.17.27
ii  libc6        2.19-18+deb8u10

dash recommends no packages.

dash suggests no packages.

-- debconf information:
* dash/sh: true

--- End Message ---
--- Begin Message ---
Control: retitle -1 systemd-detect-virt only detects systemd-nspawn container 
if run as PID1
Control: reassign -1 systemd 215-17+deb8u7
Control: fixed -1 218-1

I can repro this on bullseye (with apologies to the snapshot.d.o maintainers):
-- >8 --
# debootstrap --variant=minbase --no-check-gpg jessie jessie-18-10-10  
http://snapshot.debian.org/archive/debian/20181010T111800Z/
# systemd-nspawn -D jessie-18-10-10/ /bin/bash -c "systemd-detect-virt"
Spawning container jessie-18-10-10 on /home/nabijaczleweli/uwu/jessie-18-10-10.
Press ^] three times within 1s to kill container.
systemd-nspawn
Container jessie-18-10-10 exited successfully.
# systemd-nspawn -D jessie-18-10-10/ /bin/dash -c "systemd-detect-virt"
Spawning container jessie-18-10-10 on /home/nabijaczleweli/uwu/jessie-18-10-10.
Press ^] three times within 1s to kill container.
none
Container jessie-18-10-10 failed with error code 1.
-- >8 --

By excluding the environment &a., I arrived at:
-- >8 --
# systemd-nspawn -D jessie-18-10-10/ /bin/bash -c 'cat /proc/$$/cmdline'
Spawning container jessie-18-10-10 on /home/nabijaczleweli/uwu/jessie-18-10-10.
Press ^] three times within 1s to kill container.
cat^@-A^@/proc/1/cmdline^@
Container jessie-18-10-10 exited successfully.
# systemd-nspawn -D jessie-18-10-10/ /bin/dash -c 'cat /proc/$$/cmdline'
Spawning container jessie-18-10-10 on /home/nabijaczleweli/uwu/jessie-18-10-10.
Press ^] three times within 1s to kill container.
/bin/dash^@-c^@cat -A /proc/$$/cmdline^@
Container jessie-18-10-10 exited successfully.
-- >8 --
and its natural extension:
-- >8 --
# systemd-nspawn -D jessie-18-10-10/ /bin/bash -c "(systemd-detect-virt)"
Spawning container jessie-18-10-10 on /home/nabijaczleweli/uwu/jessie-18-10-10.
Press ^] three times within 1s to kill container.
none
# systemd-nspawn -D jessie-18-10-10/ /bin/dash -c "exec systemd-detect-virt"
Spawning container jessie-18-10-10 on /home/nabijaczleweli/uwu/jessie-18-10-10.
Press ^] three times within 1s to kill container.
systemd-nspawn
Container jessie-18-10-10 exited successfully.
Container jessie-18-10-10 failed with error code 1.
-- >8 --

This is a systemd bug,
insofar as the container detection code only works if the caller is PID 1.

By further bisecting through systemd versions available on s.d.o, I got to:
-- >8 --
root@jessie-18-10-10:~# 217-4/usr/bin/systemd-detect-virt
none
root@jessie-18-10-10:~# 218-1/usr/bin/systemd-detect-virt
systemd-nspawn
-- >8 --

Best,
наб

Attachment: signature.asc
Description: PGP signature


--- End Message ---

Reply via email to