summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-10-04 17:54:35 +0200
committerGitHub <noreply@github.com>2017-10-04 17:54:35 +0200
commit5ad90fe376398052c8ca1267b5cef43cec857df1 (patch)
tree2c5bebdd6d1acf86c279a4e377ef6d282fdb1059 /src
parenttree-wide: use IN_SET macro (#6977) (diff)
parentcore: use strv_isempty to check if supplementary_groups is empty (diff)
downloadsystemd-5ad90fe376398052c8ca1267b5cef43cec857df1.tar.xz
systemd-5ad90fe376398052c8ca1267b5cef43cec857df1.zip
Merge pull request #6985 from yuwata/empty
load-fragment: do not create empty array
Diffstat (limited to 'src')
-rw-r--r--src/core/execute.c6
-rw-r--r--src/core/load-fragment.c24
2 files changed, 5 insertions, 25 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 3e264d1dd4..5265391f5a 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -895,7 +895,7 @@ static int get_supplementary_groups(const ExecContext *c, const char *user,
keep_groups = true;
}
- if (!c->supplementary_groups)
+ if (strv_isempty(c->supplementary_groups))
return 0;
/*
@@ -969,7 +969,7 @@ static int enforce_groups(const ExecContext *context, gid_t gid,
assert(context);
/* Handle SupplementaryGroups= even if it is empty */
- if (context->supplementary_groups) {
+ if (!strv_isempty(context->supplementary_groups)) {
r = maybe_setgroups(ngids, supplementary_gids);
if (r < 0)
return r;
@@ -4052,7 +4052,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
fprintf(f, "%sDynamicUser: %s\n", prefix, yes_no(c->dynamic_user));
- if (strv_length(c->supplementary_groups) > 0) {
+ if (!strv_isempty(c->supplementary_groups)) {
fprintf(f, "%sSupplementaryGroups:", prefix);
strv_fprintf(f, c->supplementary_groups);
fputs("\n", f);
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 2c3783a9f0..5dd1787098 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -284,19 +284,7 @@ int config_parse_unit_path_strv_printf(
assert(u);
if (isempty(rvalue)) {
- char **empty;
-
- /* Empty assignment resets the list. As a special rule
- * we actually fill in a real empty array here rather
- * than NULL, since some code wants to know if
- * something was set at all... */
- empty = new0(char*, 1);
- if (!empty)
- return log_oom();
-
- strv_free(*x);
- *x = empty;
-
+ *x = strv_free(*x);
return 0;
}
@@ -1968,15 +1956,7 @@ int config_parse_user_group_strv(
assert(u);
if (isempty(rvalue)) {
- char **empty;
-
- empty = new0(char*, 1);
- if (!empty)
- return log_oom();
-
- strv_free(*users);
- *users = empty;
-
+ *users = strv_free(*users);
return 0;
}