diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-02-11 23:41:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-02-11 23:54:30 +0100 |
commit | 123b964a537c21e9ebaf849acefb23f0f13db785 (patch) | |
tree | 09738b2edf39e704cf8ef44d1287a26667978cb4 /src/shared | |
parent | abb381b3b3a169a0cd6015c02f21f6032a78a873 (diff) |
manager: validate environment parameters for SetEnvironment(), UnsetEnvironment() bus calls
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/env-util.c | 15 | ||||
-rw-r--r-- | src/shared/env-util.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/shared/env-util.c b/src/shared/env-util.c index 7a213a77c0..9a833d22e4 100644 --- a/src/shared/env-util.c +++ b/src/shared/env-util.c @@ -135,6 +135,21 @@ bool strv_env_is_valid(char **e) { return true; } +bool strv_env_name_or_assignment_is_valid(char **l) { + char **p, **q; + + STRV_FOREACH(p, l) { + if (!env_assignment_is_valid(*p) && !env_name_is_valid(*p)) + return false; + + STRV_FOREACH(q, p + 1) + if (streq(*p, *q)) + return false; + } + + return true; +} + static int env_append(char **r, char ***k, char **a) { assert(r); assert(k); diff --git a/src/shared/env-util.h b/src/shared/env-util.h index 93bf596ca8..9449576b5c 100644 --- a/src/shared/env-util.h +++ b/src/shared/env-util.h @@ -31,6 +31,8 @@ bool env_assignment_is_valid(const char *e); bool strv_env_is_valid(char **e); char **strv_env_clean(char **l); +bool strv_env_name_or_assignment_is_valid(char **l); + char **strv_env_merge(unsigned n_lists, ...); char **strv_env_delete(char **x, unsigned n_lists, ...); /* New copy */ |