summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri John Ledkov <dimitri.j.ledkov@intel.com>2015-06-01 12:46:52 +0100
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:01:41 +0100
commitbbdb338a860d20c637a6445d458f341e87c1df05 (patch)
tree0ee3a417c4214f2e3ee2f5217656f999c1183e87 /src
parent1c0f0483c0afbdde3eaf220eb4e0015533dba3b5 (diff)
shared: Drop 'name=' prefix from SYSTEMD_CGROUP_CONTROLLER define.
In cgtop,mount-setup,nspawn the name= prefix is hard-coded in the mount options, and the define is not used. Everywhere else, we explicitly white-list allow 'name=' prefix to be used with all controllers, and strip it out to 'normalise' the controller name. That work is mostly inflicted on us due to 'name=' prefix in the define. Dropping this prefix makes everything more sane overall.
Diffstat (limited to 'src')
-rw-r--r--src/shared/cgroup-util.c24
-rw-r--r--src/shared/cgroup-util.h2
-rw-r--r--src/shared/def.h4
3 files changed, 15 insertions, 15 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index a48b31201..b286243c3 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -440,9 +440,7 @@ static const char *normalize_controller(const char *controller) {
assert(controller);
- if (streq(controller, SYSTEMD_CGROUP_CONTROLLER))
- return "systemd";
- else if (startswith(controller, "name="))
+ if (startswith(controller, "name="))
return controller + 5;
else
return controller;
@@ -482,7 +480,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
assert(fs);
- if (controller && !cg_controller_is_valid(controller, true))
+ if (controller && !cg_controller_is_valid(controller))
return -EINVAL;
if (_unlikely_(!good)) {
@@ -525,7 +523,7 @@ int cg_get_path_and_check(const char *controller, const char *path, const char *
assert(fs);
- if (!cg_controller_is_valid(controller, true))
+ if (!cg_controller_is_valid(controller))
return -EINVAL;
/* Normalize the controller syntax */
@@ -741,7 +739,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
assert(pid >= 0);
if (controller) {
- if (!cg_controller_is_valid(controller, true))
+ if (!cg_controller_is_valid(controller))
return -EINVAL;
controller = normalize_controller(controller);
@@ -970,7 +968,7 @@ int cg_split_spec(const char *spec, char **controller, char **path) {
e = strchr(spec, ':');
if (!e) {
- if (!cg_controller_is_valid(spec, true))
+ if (!cg_controller_is_valid(spec))
return -EINVAL;
if (controller) {
@@ -993,7 +991,7 @@ int cg_split_spec(const char *spec, char **controller, char **path) {
t = strdup(normalize_controller(v));
if (!t)
return -ENOMEM;
- if (!cg_controller_is_valid(t, true)) {
+ if (!cg_controller_is_valid(t)) {
free(t);
return -EINVAL;
}
@@ -1609,17 +1607,15 @@ char *cg_unescape(const char *p) {
DIGITS LETTERS \
"_"
-bool cg_controller_is_valid(const char *p, bool allow_named) {
+bool cg_controller_is_valid(const char *p) {
const char *t, *s;
if (!p)
return false;
- if (allow_named) {
- s = startswith(p, "name=");
- if (s)
- p = s;
- }
+ s = startswith(p, "name=");
+ if (s)
+ p = s;
if (*p == 0 || *p == '_')
return false;
diff --git a/src/shared/cgroup-util.h b/src/shared/cgroup-util.h
index 20900d0c5..bc8caa5c1 100644
--- a/src/shared/cgroup-util.h
+++ b/src/shared/cgroup-util.h
@@ -110,7 +110,7 @@ int cg_pid_get_user_slice(pid_t pid, char **slice);
char *cg_escape(const char *p);
char *cg_unescape(const char *p) _pure_;
-bool cg_controller_is_valid(const char *p, bool allow_named);
+bool cg_controller_is_valid(const char *p);
typedef const char* (*cg_migrate_callback_t)(CGroupControllerMask mask, void *userdata);
diff --git a/src/shared/def.h b/src/shared/def.h
index 7958f18c1..9665347a8 100644
--- a/src/shared/def.h
+++ b/src/shared/def.h
@@ -78,5 +78,9 @@
.un.sun_path = "\0/org/freedesktop/plymouthd", \
}
+#ifndef TTY_GID
+#define TTY_GID 5
+#endif
+
#define NOTIFY_FD_MAX 768
#define NOTIFY_BUFFER_MAX PIPE_BUF