mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
core: use strdup_to()
Those are all pretty straightforward.
This commit is contained in:
parent
b8486f2592
commit
045d94248d
@ -5007,14 +5007,9 @@ int service_determine_exec_selinux_label(Service *s, char **ret) {
|
||||
|
||||
/* Returns the SELinux label used for execution of the main service binary */
|
||||
|
||||
if (s->exec_context.selinux_context) { /* Prefer the explicitly configured label if there is one */
|
||||
char *con = strdup(s->exec_context.selinux_context);
|
||||
if (!con)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = con;
|
||||
return 0;
|
||||
}
|
||||
if (s->exec_context.selinux_context)
|
||||
/* Prefer the explicitly configured label if there is one */
|
||||
return strdup_to(ret, s->exec_context.selinux_context);
|
||||
|
||||
if (s->exec_context.root_image ||
|
||||
s->exec_context.n_extension_images > 0 ||
|
||||
|
@ -91,37 +91,22 @@ static int specifier_cgroup(char specifier, const void *data, const char *root,
|
||||
|
||||
bad_specifier(u, specifier);
|
||||
|
||||
if (crt && crt->cgroup_path) {
|
||||
char *n;
|
||||
|
||||
n = strdup(crt->cgroup_path);
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = n;
|
||||
return 0;
|
||||
}
|
||||
if (crt && crt->cgroup_path)
|
||||
return strdup_to(ret, crt->cgroup_path);
|
||||
|
||||
return unit_default_cgroup_path(u, ret);
|
||||
}
|
||||
|
||||
static int specifier_cgroup_root(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
const Unit *u = ASSERT_PTR(userdata);
|
||||
char *n;
|
||||
|
||||
bad_specifier(u, specifier);
|
||||
|
||||
n = strdup(u->manager->cgroup_root);
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = n;
|
||||
return 0;
|
||||
return strdup_to(ret, u->manager->cgroup_root);
|
||||
}
|
||||
|
||||
static int specifier_cgroup_slice(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
const Unit *u = ASSERT_PTR(userdata), *slice;
|
||||
char *n;
|
||||
|
||||
bad_specifier(u, specifier);
|
||||
|
||||
@ -130,28 +115,18 @@ static int specifier_cgroup_slice(char specifier, const void *data, const char *
|
||||
CGroupRuntime *crt = unit_get_cgroup_runtime(slice);
|
||||
|
||||
if (crt && crt->cgroup_path)
|
||||
n = strdup(crt->cgroup_path);
|
||||
else
|
||||
return unit_default_cgroup_path(slice, ret);
|
||||
} else
|
||||
n = strdup(u->manager->cgroup_root);
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
return strdup_to(ret, crt->cgroup_path);
|
||||
|
||||
*ret = n;
|
||||
return 0;
|
||||
return unit_default_cgroup_path(slice, ret);
|
||||
}
|
||||
|
||||
return strdup_to(ret, u->manager->cgroup_root);
|
||||
}
|
||||
|
||||
static int specifier_special_directory(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
const Unit *u = ASSERT_PTR(userdata);
|
||||
char *n;
|
||||
|
||||
n = strdup(u->manager->prefix[PTR_TO_UINT(data)]);
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = n;
|
||||
return 0;
|
||||
return strdup_to(ret, u->manager->prefix[PTR_TO_UINT(data)]);
|
||||
}
|
||||
|
||||
static int specifier_credentials_dir(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
|
Loading…
Reference in New Issue
Block a user