]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/env-util: drop the validation when deserializing environment
authorLubomir Rintel <lkundrak@v3.sk>
Wed, 11 Oct 2017 07:29:30 +0000 (09:29 +0200)
committerLubomir Rintel <lkundrak@v3.sk>
Wed, 11 Oct 2017 13:01:32 +0000 (15:01 +0200)
The environment variables we've serialized can quite possibly contain
characters outside the set allowed by env_assignment_is_valid(). In
fact, my environment seems to contain a couple of these:

  * TERMCAP set by screen contains a '\x7f' character
  * BASH_FUNC_module%% variable has a '%' character in name

Strict check of environment variables name and value certainly makes sense for
unit files, but not so much for deserialization of values we already had
in our environment.

src/basic/env-util.c
src/test/test-env-util.c

index fa42edfa96101abe18703769c158034b2fe4c9bf..a8b51e719f21727f933c2dd7347765c8022329bb 100644 (file)
@@ -809,10 +809,5 @@ int deserialize_environment(char ***environment, const char *line) {
         if (r < 0)
                 return r;
 
-        if (!env_assignment_is_valid(uce)) {
-                free(uce);
-                return -EINVAL;
-        }
-
         return strv_env_replace(environment, uce);
 }
index 3a2492dc6fd569374952185fe6c8d6f3ffc54be8..b14d62760f609a77042f096ea1513dbaec5e6670 100644 (file)
@@ -319,10 +319,10 @@ static void test_env_assignment_is_valid(void) {
 static void test_deserialize_environment(void) {
         _cleanup_strv_free_ char **env = strv_new("A=1", NULL);
 
-        assert_se(deserialize_environment(&env, "env=test") < 0);
         assert_se(deserialize_environment(&env, "env=B=2") >= 0);
+        assert_se(deserialize_environment(&env, "env=FOO%%=a\\177b\\nc\\td e") >= 0);
 
-        assert_se(strv_equal(env, STRV_MAKE("A=1", "B=2")));
+        assert_se(strv_equal(env, STRV_MAKE("A=1", "B=2", "FOO%%=a\177b\nc\td e")));
 }
 
 static void test_serialize_environment(void) {
@@ -334,6 +334,7 @@ static void test_serialize_environment(void) {
                                                   "B=2",
                                                   "C=ąęółń",
                                                   "D=D=a\\x0Ab",
+                                                  "FOO%%=a\177b\nc\td e",
                                                   NULL);
         _cleanup_strv_free_ char **env2 = NULL;