X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmount-setup.c;h=f30adabbf07137ddb49d4f1f4a1fa4b8e25fcd1e;hb=da4b83e77bc603745cf4a365d7f013301ef7fa89;hp=5919f770c743386d5086bedb734898d352497103;hpb=b4d5b78374e093ffb280fbfbbcfedbe68d60b956;p=elogind.git diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index 5919f770c..f30adabbf 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -19,31 +19,32 @@ along with systemd; If not, see . ***/ -#include #include -#include +#include #include -#include -#include +#include #include -#include -#include "mount-setup.h" -#include "dev-setup.h" -#include "log.h" -#include "macro.h" -#include "util.h" +#include "alloc-util.h" +//#include "bus-util.h" +#include "cgroup-util.h" +//#include "dev-setup.h" +//#include "efivars.h" #include "label.h" -#include "set.h" -#include "strv.h" +//#include "log.h" +#include "macro.h" +//#include "missing.h" #include "mkdir.h" +#include "mount-setup.h" +#include "mount-util.h" #include "path-util.h" -#include "missing.h" +//#include "set.h" +//#include "smack-util.h" +//#include "strv.h" +#include "string-util.h" +#include "user-util.h" +//#include "util.h" #include "virt.h" -#include "efivars.h" -#include "smack-util.h" -#include "def.h" -#include "cgroup-util.h" typedef enum MountMode { MNT_NONE = 0, @@ -72,6 +73,8 @@ typedef struct MountPoint { #endif static const MountPoint mount_table[] = { +/// UNNEEDED by elogind +#if 0 { "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_FATAL|MNT_IN_CONTAINER }, { "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, @@ -96,32 +99,44 @@ static const MountPoint mount_table[] = { #endif { "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME, NULL, MNT_FATAL|MNT_IN_CONTAINER }, + { "cgroup", "/sys/fs/cgroup", "cgroup", "__DEVEL__sane_behavior", MS_NOSUID|MS_NOEXEC|MS_NODEV, + cg_is_unified_wanted, MNT_FATAL|MNT_IN_CONTAINER }, +#endif // 0 { "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, - NULL, MNT_FATAL|MNT_IN_CONTAINER }, + cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER }, +/// UNNEEDED by elogind +#if 0 { "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd,xattr", MS_NOSUID|MS_NOEXEC|MS_NODEV, - NULL, MNT_IN_CONTAINER }, + cg_is_legacy_wanted, MNT_IN_CONTAINER }, { "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV, - NULL, MNT_FATAL|MNT_IN_CONTAINER }, + cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER }, +#else + { "cgroup", "/sys/fs/cgroup/elogind", "cgroup", "none,name=elogind,xattr", MS_NOSUID|MS_NOEXEC|MS_NODEV, + cg_is_legacy_wanted, MNT_IN_CONTAINER }, + { "cgroup", "/sys/fs/cgroup/elogind", "cgroup", "none,name=elogind", MS_NOSUID|MS_NOEXEC|MS_NODEV, + cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER }, +#endif // 0 +/// UNNEEDED by elogind +#if 0 { "pstore", "/sys/fs/pstore", "pstore", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_NONE }, #ifdef ENABLE_EFI { "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, is_efi_boot, MNT_NONE }, #endif -#ifdef ENABLE_KDBUS { "kdbusfs", "/sys/fs/kdbus", "kdbusfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, - NULL, MNT_IN_CONTAINER }, -#endif + is_kdbus_wanted, MNT_IN_CONTAINER }, +#endif // 0 }; +/// UNNEEDED by elogind +#if 0 /* These are API file systems that might be mounted by other software, * we just list them here so that we know that we should ignore them */ static const char ignore_paths[] = /* SELinux file systems */ "/sys/fs/selinux\0" - /* Legacy kernel file system */ - "/proc/bus/usb\0" /* Container bind mounts */ "/proc/sys\0" "/dev/console\0" @@ -149,6 +164,7 @@ bool mount_point_ignore(const char *path) { return false; } +#endif // 0 static int mount_one(const MountPoint *p, bool relabel) { int r; @@ -162,15 +178,14 @@ static int mount_one(const MountPoint *p, bool relabel) { if (relabel) label_fix(p->where, true, true); - r = path_is_mount_point(p->where, true); - if (r < 0) + r = path_is_mount_point(p->where, AT_SYMLINK_FOLLOW); + if (r < 0 && r != -ENOENT) return r; - if (r > 0) return 0; /* Skip securityfs in a container */ - if (!(p->mode & MNT_IN_CONTAINER) && detect_container(NULL) > 0) + if (!(p->mode & MNT_IN_CONTAINER) && detect_container() > 0) return 0; /* The access mode here doesn't really matter too much, since @@ -202,6 +217,8 @@ static int mount_one(const MountPoint *p, bool relabel) { return 1; } +/// UNNEEDED by elogind +#if 0 int mount_setup_early(void) { unsigned i; int r = 0; @@ -214,7 +231,7 @@ int mount_setup_early(void) { int j; j = mount_one(mount_table + i, false); - if (r == 0) + if (j != 0 && r >= 0) r = j; } @@ -225,6 +242,9 @@ int mount_cgroup_controllers(char ***join_controllers) { _cleanup_set_free_free_ Set *controllers = NULL; int r; + if (!cg_is_legacy_wanted()) + return 0; + /* Mount all available cgroup controllers that are built into the kernel. */ controllers = set_new(&string_hash_ops); @@ -306,6 +326,11 @@ int mount_cgroup_controllers(char ***join_controllers) { r = symlink(options, t); if (r < 0 && errno != EEXIST) return log_error_errno(errno, "Failed to create symlink %s: %m", t); +#ifdef SMACK_RUN_LABEL + r = mac_smack_copy(t, options); + if (r < 0 && r != -EOPNOTSUPP) + return log_error_errno(r, "Failed to copy smack label from %s to %s: %m", options, t); +#endif } } } @@ -340,6 +365,7 @@ static int nftw_cb( return FTW_CONTINUE; }; #endif +#endif // 0 int mount_setup(bool loaded_policy) { unsigned i; @@ -349,13 +375,15 @@ int mount_setup(bool loaded_policy) { int j; j = mount_one(mount_table + i, loaded_policy); - if (r == 0) + if (j != 0 && r >= 0) r = j; } if (r < 0) return r; +/// elogind does not control /, /dev, /run and /run/systemd/* are setup elsewhere. +#if 0 #if defined(HAVE_SELINUX) || defined(HAVE_SMACK) /* Nodes in devtmpfs and /run need to be manually updated for * the appropriate labels, after mounting. The other virtual @@ -380,7 +408,7 @@ int mount_setup(bool loaded_policy) { /* Create a few default symlinks, which are normally created * by udevd, but some scripts might need them before we start * udevd. */ - dev_setup(NULL); + dev_setup(NULL, UID_INVALID, GID_INVALID); /* Mark the root directory as shared in regards to mount * propagation. The kernel defaults to "private", but we think @@ -388,7 +416,7 @@ int mount_setup(bool loaded_policy) { * nspawn and the container tools work out of the box. If * specific setups need other settings they can reset the * propagation mode to private if needed. */ - if (detect_container(NULL) <= 0) + if (detect_container() <= 0) if (mount(NULL, "/", NULL, MS_REC|MS_SHARED, NULL) < 0) log_warning_errno(errno, "Failed to set up the root directory for shared mount propagation: %m"); @@ -400,6 +428,7 @@ int mount_setup(bool loaded_policy) { mkdir_label("/run/systemd", 0755); mkdir_label("/run/systemd/system", 0755); mkdir_label("/run/systemd/inaccessible", 0000); +#endif // 0 return 0; }