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

Reply via email to