From 71ecc858fa91a686a050bee51804d43865ce1acc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 11 Apr 2012 12:56:51 +0200 Subject: main: drop container/initrd env vars from inherited set Leave the env vars used in the container/initrd logic set for PID1, but don't inherit them to any children. --- src/shared/strv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/shared/strv.c') diff --git a/src/shared/strv.c b/src/shared/strv.c index bb309d9f92..f61680d476 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -386,6 +386,31 @@ char **strv_remove(char **l, const char *s) { return l; } +char **strv_remove_prefix(char **l, const char *s) { + char **f, **t; + + if (!l) + return NULL; + + assert(s); + + /* Drops every occurrence of a string prefixed with s in the + * string list, edits in-place. */ + + for (f = t = l; *f; f++) { + + if (startswith(*f, s)) { + free(*f); + continue; + } + + *(t++) = *f; + } + + *t = NULL; + return l; +} + static int env_append(char **r, char ***k, char **a) { assert(r); assert(k); -- cgit v1.2.3-54-g00ecf