Blame SOURCES/0039-Systemd-parse-environment-variables-where-only-value.patch

ab36df
From ae413b03a9c05374ace146d2876d9bc11ad5648f Mon Sep 17 00:00:00 2001
ab36df
From: Dominic Cleal <dcleal@redhat.com>
ab36df
Date: Fri, 5 Sep 2014 08:39:31 +0100
ab36df
Subject: [PATCH] Systemd: parse environment variables where only value is
ab36df
 quoted
ab36df
ab36df
Fixes regression introduced in 5226ae7, which added support to parse fully
ab36df
quoted "NAME=value" environment vars.  To support both, this commit stores
ab36df
the quotes in the value if it's only the value quoted.
ab36df
ab36df
Fixes RHBZ#1138508
ab36df
ab36df
(cherry picked from commit f64d8bc7a7670f3af2549fdcefb64c2b5f22cd0d)
ab36df
---
ab36df
 lenses/systemd.aug            | 4 +++-
ab36df
 lenses/tests/test_systemd.aug | 8 ++++++++
ab36df
 2 files changed, 11 insertions(+), 1 deletion(-)
ab36df
ab36df
diff --git a/lenses/systemd.aug b/lenses/systemd.aug
ab36df
index e1d9e5a..ade70d5 100644
ab36df
--- a/lenses/systemd.aug
ab36df
+++ b/lenses/systemd.aug
ab36df
@@ -132,9 +132,11 @@ let entry_env =
ab36df
      let envkv (env_val:lens) = key env_key . Util.del_str "=" . env_val
ab36df
      (* bare has no spaces, and is optionally quoted *)
ab36df
   in let bare = Quote.do_quote_opt (envkv (store /[^#'" \t\n]*[^#'" \t\n\\]/)?)
ab36df
+  in let bare_dqval = envkv (store /"[^#" \t\n]*[^#" \t\n\\]"/)
ab36df
+  in let bare_sqval = envkv (store /'[^#' \t\n]*[^#' \t\n\\]'/)
ab36df
      (* quoted has at least one space, and must be quoted *)
ab36df
   in let quoted = Quote.do_quote (envkv (store /[^#"'\n]*[ \t]+[^#"'\n]*/))
ab36df
-  in let envkv_quoted = [ bare ] | [ quoted ]
ab36df
+  in let envkv_quoted = [ bare ] | [ bare_dqval ] | [ bare_sqval ] | [ quoted ]
ab36df
   in entry_fn entry_env_kw ( Build.opt_list envkv_quoted value_sep )
ab36df
 
ab36df
 
ab36df
diff --git a/lenses/tests/test_systemd.aug b/lenses/tests/test_systemd.aug
ab36df
index 82516b3..3397456 100644
ab36df
--- a/lenses/tests/test_systemd.aug
ab36df
+++ b/lenses/tests/test_systemd.aug
ab36df
@@ -204,6 +204,8 @@ Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETA
ab36df
 Environment=LANG=C\
ab36df
 FOO=BAR
ab36df
 Environment=\"LANG=foo bar\" FOO=BAR
ab36df
+Environment=OPTIONS=\"-LS0-6d\"
ab36df
+Environment=OPTIONS='-LS0-6d'
ab36df
 "
ab36df
 (* Test: Systemd.lns *)
ab36df
 test Systemd.lns get env =
ab36df
@@ -239,6 +241,12 @@ test Systemd.lns get env =
ab36df
       { "LANG" = "foo bar" }
ab36df
       { "FOO" = "BAR" }
ab36df
     }
ab36df
+    { "Environment"
ab36df
+      { "OPTIONS" = "\"-LS0-6d\"" }
ab36df
+    }
ab36df
+    { "Environment"
ab36df
+      { "OPTIONS" = "'-LS0-6d'" }
ab36df
+    }
ab36df
   }
ab36df
 
ab36df
 (* Variable: unit *)