← Back to team overview

curtin-dev team mailing list archive

[Merge] ~ogayot/curtin:systemd-offline into curtin:master

 

The proposal to merge ~ogayot/curtin:systemd-offline into curtin:master has been updated.

Commit message changed to:

apt: ensure systemd knows it runs in a chroot, when executing postinst

Since we added the --mount-proc option to unshare, the postinst script
for openssh-server (and most likely other packages) started failing with
the following error when `systemctl daemon-reload` was invoked:

  > Failed to connect to bus: No data available

Before the option was added, it would simply do nothing because systemd
rightly understood it was running in a chroot.

To determine if we are running in a chroot, systemd checks if
/proc/1/root (corresponding to the init process) and / are the same
inode. If they are different, systemd assumes we are in a chroot.

However, we are running apt-get in a new PID namespace which means that
in the new namespace, apt-get gets assigned PID 1 and is therefore the
"init" process.

Now that /proc is properly mounted in the chroot, when systemd compares
/proc/1/root and /, it sees they are identical because the init process
(which is apt-get) is actually running inside the chroot.

Without the --mount-proc option, /proc/1 in the chroot would still refer
to the systemd init process (running outside the chroot), so it would
work properly.

With the SYSTEMD_OFFLINE variable, one can "force" systemd to assume
it is running in a chroot. Let's use it.

LP: #2056570

Signed-off-by: Olivier Gayot <olivier.gayot@xxxxxxxxxxxxx>

For more details, see:
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/462140
-- 
Your team curtin developers is requested to review the proposed merge of ~ogayot/curtin:systemd-offline into curtin:master.



References