From: Christian Göttsche Date: Fri, 10 Jul 2020 20:08:50 +0000 (+0200) Subject: namespace: fix MAC labels of TemporaryFileSystem= X-Git-Tag: v246-rc2~92^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16426%2Fhead;p=thirdparty%2Fsystemd.git namespace: fix MAC labels of TemporaryFileSystem= Reproducible with: systemd-run -p TemporaryFileSystem=/root -t /bin/bash ls -dZ /root Prior: root:object_r:tmpfs_t:s0 /root Past: root:object_r:user_home_dir_t:s0 /root --- diff --git a/src/core/namespace.c b/src/core/namespace.c index b2bbcf58f2d..ebdbb7545b0 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -860,15 +860,23 @@ static int mount_procfs(const MountEntry *m) { } static int mount_tmpfs(const MountEntry *m) { + int r; + const char *entry_path = mount_entry_path(m); + const char *source_path = m->path_const; + assert(m); /* First, get rid of everything that is below if there is anything. Then, overmount with our new tmpfs */ - (void) mkdir_p_label(mount_entry_path(m), 0755); - (void) umount_recursive(mount_entry_path(m), 0); + (void) mkdir_p_label(entry_path, 0755); + (void) umount_recursive(entry_path, 0); - if (mount("tmpfs", mount_entry_path(m), "tmpfs", m->flags, mount_entry_options(m)) < 0) - return log_debug_errno(errno, "Failed to mount %s: %m", mount_entry_path(m)); + if (mount("tmpfs", entry_path, "tmpfs", m->flags, mount_entry_options(m)) < 0) + return log_debug_errno(errno, "Failed to mount %s: %m", entry_path); + + r = label_fix_container(entry_path, source_path, 0); + if (r < 0) + return log_error_errno(r, "Failed to fix label of '%s' as '%s': %m", entry_path, source_path); return 1; }