summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-03-13 19:12:26 +0100
committerSven Eden <yamakuzure@gmx.net>2018-03-26 18:25:53 +0200
commit7a7db2b7e7fb7e79c14212346aa84c78d22e86a7 (patch)
treef8ef47cac67b2e9279b816220c083f1960cb1972 /src
parent5a1765290e87f45b970657cfc8ac1e7ca5c50d6a (diff)
Prep v236 : Add missing SPDX-License-Identifier (3/9) src/core
Diffstat (limited to 'src')
-rw-r--r--src/cgroups-agent/cgroups-agent.c1
-rw-r--r--src/core/cgroup.c11
-rw-r--r--src/core/cgroup.h1
-rw-r--r--src/core/mount-setup.c32
-rw-r--r--src/core/mount-setup.h1
5 files changed, 29 insertions, 17 deletions
diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c
index 9fb7e34dd..50d6e5e18 100644
--- a/src/cgroups-agent/cgroups-agent.c
+++ b/src/cgroups-agent/cgroups-agent.c
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index dd63fda23..da0624e6f 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
@@ -1974,7 +1975,9 @@ int manager_setup_cgroup(Manager *m) {
const char *scope_path;
CGroupController c;
int r, all_unified;
+#if 0 /// UNNEEDED by elogind
char *e;
+#endif // 0
assert(m);
@@ -2005,13 +2008,11 @@ int manager_setup_cgroup(Manager *m) {
*e = 0;
#endif // 0
- /* And make sure to store away the root value without trailing
- * slash, even for the root dir, so that we can easily prepend
- * it everywhere. */
- while ((e = endswith(m->cgroup_root, "/")))
- *e = 0;
log_debug_elogind("Cgroup Controller \"%s\" -> root \"%s\"",
SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root);
+ /* And make sure to store away the root value without trailing slash, even for the root dir, so that we can
+ * easily prepend it everywhere. */
+ delete_trailing_chars(m->cgroup_root, "/");
/* 2. Show data */
r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, NULL, &path);
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index ab32a4919..159fac4a4 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 011950cb3..1e2849801 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
@@ -28,6 +29,7 @@
#include "cgroup-util.h"
//#include "dev-setup.h"
//#include "efivars.h"
+//#include "fileio.h"
#include "fs-util.h"
#include "label.h"
//#include "log.h"
@@ -48,9 +50,10 @@
#include "string-util.h"
typedef enum MountMode {
- MNT_NONE = 0,
- MNT_FATAL = 1 << 0,
- MNT_IN_CONTAINER = 1 << 1,
+ MNT_NONE = 0,
+ MNT_FATAL = 1 << 0,
+ MNT_IN_CONTAINER = 1 << 1,
+ MNT_CHECK_WRITABLE = 1 << 2,
} MountMode;
typedef struct MountPoint {
@@ -100,16 +103,16 @@ static const MountPoint mount_table[] = {
{ "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME,
NULL, MNT_FATAL|MNT_IN_CONTAINER },
{ "cgroup", "/sys/fs/cgroup", "cgroup2", "nsdelegate", MS_NOSUID|MS_NOEXEC|MS_NODEV,
- cg_is_unified_wanted, MNT_IN_CONTAINER },
+ cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE },
{ "cgroup", "/sys/fs/cgroup", "cgroup2", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
- cg_is_unified_wanted, MNT_IN_CONTAINER },
+ cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE },
#endif // 0
{ "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER },
{ "cgroup", "/sys/fs/cgroup/unified", "cgroup2", "nsdelegate", MS_NOSUID|MS_NOEXEC|MS_NODEV,
- cg_is_hybrid_wanted, MNT_IN_CONTAINER },
+ cg_is_hybrid_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE },
{ "cgroup", "/sys/fs/cgroup/unified", "cgroup2", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
- cg_is_hybrid_wanted, MNT_IN_CONTAINER },
+ cg_is_hybrid_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE },
#if 0 /// UNNEEDED by elogind
{ "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd,xattr", MS_NOSUID|MS_NOEXEC|MS_NODEV,
cg_is_legacy_wanted, MNT_IN_CONTAINER },
@@ -215,6 +218,15 @@ static int mount_one(const MountPoint *p, bool relabel) {
if (relabel)
(void) label_fix(p->where, false, false);
+ if (p->mode & MNT_CHECK_WRITABLE) {
+ r = access(p->where, W_OK);
+ if (r < 0) {
+ (void) umount(p->where);
+ (void) rmdir(p->where);
+ return (p->mode & MNT_FATAL) ? r : 0;
+ }
+ }
+
return 1;
}
@@ -251,11 +263,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
/* Mount all available cgroup controllers that are built into the kernel. */
- controllers = set_new(&string_hash_ops);
- if (!controllers)
- return log_oom();
-
- r = cg_kernel_controllers(controllers);
+ r = cg_kernel_controllers(&controllers);
if (r < 0)
return log_error_errno(r, "Failed to enumerate cgroup controllers: %m");
diff --git a/src/core/mount-setup.h b/src/core/mount-setup.h
index b6c2d7cb8..1fc5da28b 100644
--- a/src/core/mount-setup.h
+++ b/src/core/mount-setup.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***