diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-11 20:42:58 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-01-19 17:50:10 +0000 |
commit | 8ef5fd21107625d7480346318cb858759e61ee66 (patch) | |
tree | 75c1ac0dcb14d87c6f6e544bda791899e4622622 /meta-phosphor/common/recipes-core/systemd/systemd/0004-basic-Use-path-escaping-when-mangling-path-instances.patch | |
parent | eb2a4324f8a3b29a25d7e2c0ac02f9c1f10c15de (diff) | |
download | talos-openbmc-8ef5fd21107625d7480346318cb858759e61ee66.tar.gz talos-openbmc-8ef5fd21107625d7480346318cb858759e61ee66.zip |
Cherry-pick systemd mangle-escape patch
systemd/systemd#5073
Change-Id: Ie0c5736e5ad5a9fff8c0d191852ffb62e0441109
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com?
Diffstat (limited to 'meta-phosphor/common/recipes-core/systemd/systemd/0004-basic-Use-path-escaping-when-mangling-path-instances.patch')
-rw-r--r-- | meta-phosphor/common/recipes-core/systemd/systemd/0004-basic-Use-path-escaping-when-mangling-path-instances.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-core/systemd/systemd/0004-basic-Use-path-escaping-when-mangling-path-instances.patch b/meta-phosphor/common/recipes-core/systemd/systemd/0004-basic-Use-path-escaping-when-mangling-path-instances.patch new file mode 100644 index 000000000..fca28de59 --- /dev/null +++ b/meta-phosphor/common/recipes-core/systemd/systemd/0004-basic-Use-path-escaping-when-mangling-path-instances.patch @@ -0,0 +1,69 @@ +From b7565b3f2d3b13c4ae5734407a2c3f27658c7b4b Mon Sep 17 00:00:00 2001 +From: Brad Bishop <bradleyb@fuzziesquirrel.com> +Date: Thu, 12 Jan 2017 08:52:42 -0500 +Subject: [PATCH 2/2] basic: Use path escaping when mangling path instances + +Allow path instances with dashes in them to be unescaped +properly. + +Fixes systemd/systemd#5072 + +Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> +--- + src/basic/unit-name.c | 18 ++++++++++++++++++ + src/test/test-unit-name.c | 3 +++ + 2 files changed, 21 insertions(+) + +diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c +index 93c4838..c91b0e7 100644 +--- a/src/basic/unit-name.c ++++ b/src/basic/unit-name.c +@@ -684,6 +684,8 @@ static char *do_escape_mangle(const char *f, UnitNameMangle allow_globs, char *t + * If @allow_globs, globs characters are preserved. Otherwise, they are escaped. + */ + int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, const char *suffix, char **ret) { ++ _cleanup_free_ char *instance = NULL; ++ _cleanup_free_ char *prefix = NULL; + char *s, *t; + int r; + +@@ -723,6 +725,22 @@ int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, c + return r; + } + ++ r = string_to_instance(name, &instance); ++ if(r < 0 && r != -EINVAL) ++ return r; ++ ++ if(instance && path_is_absolute(instance)) { ++ r = string_to_prefix(name, &prefix); ++ if(r < 0 && r != -EINVAL) ++ return r; ++ ++ r = unit_name_from_path_instance(prefix, instance, suffix, ret); ++ if (r >= 0) ++ return 1; ++ if (r != -EINVAL) ++ return r; ++ } ++ + s = new(char, strlen(name) * 4 + strlen(suffix) + 1); + if (!s) + return -ENOMEM; +diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c +index 2fd83f3..f2cb047 100644 +--- a/src/test/test-unit-name.c ++++ b/src/test/test-unit-name.c +@@ -192,6 +192,9 @@ static void test_unit_name_mangle(void) { + test_unit_name_mangle_one(UNIT_NAME_GLOB, "foo", "foo.service", 1); + test_unit_name_mangle_one(UNIT_NAME_GLOB, "foo*", "foo*", 0); + test_unit_name_mangle_one(UNIT_NAME_GLOB, "ü*", "\\xc3\\xbc*", 1); ++ test_unit_name_mangle_one(UNIT_NAME_GLOB, "foo@/bar.service", "foo@bar.service", 1); ++ test_unit_name_mangle_one(UNIT_NAME_GLOB, "foo@/bar/baz-boo.service", "foo@bar-baz\\x2dboo.service", 1); ++ test_unit_name_mangle_one(UNIT_NAME_GLOB, "foo@bar/baz-boo.service", "foo@bar-baz-boo.service", 1); + } + + static int test_unit_printf(void) { +-- +1.8.3.1 + |