namespace: make MountFlags=shared work again
authorFranck Bui <fbui@suse.com>
Wed, 13 Feb 2019 17:45:36 +0000 (18:45 +0100)
committerAdrian Bunk <bunk@debian.org>
Thu, 30 Mar 2023 19:32:31 +0000 (20:32 +0100)
commitca0c6f3fe7f47d1c2e92dc662052982f490094f0
treefe15f675eaeafeb7f9c2348a5b46341dbbf842d1
parent477abb3a1c9a4d99ace7ec1b825a80e222224e2a
namespace: make MountFlags=shared work again

Since commit 0722b359342d2a9f9e0d453875624387a0ba1be2, the root mountpoint is
unconditionnally turned to slave which breaks units that are using explicitly
MountFlags=shared (and no other options that would implicitly require a slave
root mountpoint).

Here is a test case:

  $ systemctl cat test-shared-mount-flag.service
  # /etc/systemd/system/test-shared-mount-flag.service
  [Service]
  Type=simple
  ExecStartPre=/usr/bin/mkdir -p /mnt/tmp
  ExecStart=/bin/sh -c "/usr/bin/mount -t tmpfs -o size=10M none /mnt/tmp && sleep infinity"
  ExecStop=-/bin/sh -c "/usr/bin/umount /mnt/tmp"
  MountFlags=shared

  $ systemctl start test-shared-mount-flag.service
  $ findmnt /mnt/tmp
  $

Mount on /mnt/tmp is not visible from the host although MountFlags=shared was
used.

This patch fixes that and turns the root mountpoint to slave when it's really
required.

(cherry picked from commit 37ed15d7edaf59a1fc7c9e3552cd93a83f3814ef)

Gbp-Pq: Name namespace-make-MountFlags-shared-work-again.patch
src/core/execute.c