[systemd-commits] 8 commits - src/shared src/test src/tmpfiles

Lennart Poettering lennart at kemper.freedesktop.org
Fri Apr 10 07:24:27 PDT 2015


 src/shared/conf-parser.c    |   35 ++++--------
 src/shared/device-nodes.c   |   21 +++++--
 src/shared/util.c           |   51 +++++++----------
 src/shared/util.h           |    4 -
 src/test/test-env-replace.c |   26 ---------
 src/test/test-util.c        |   15 +++++
 src/tmpfiles/tmpfiles.c     |  127 +++++++++++++++++++++++++++++---------------
 7 files changed, 151 insertions(+), 128 deletions(-)

New commits:
commit 17493fa5d17cadce3b773692d3eeab137de7d323
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 16:22:22 2015 +0200

    tmpfiles: enforce ordering when executing lines
    
    Always create files first, and then adjust their ACLs, xattrs, file
    attributes, never the opposite. Previously the order was not
    deterministic, thus possibly first adjusting ACLs/xattrs/file
    attributes before actually creating the items.

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index dc8254c..1603ab2 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -76,20 +76,20 @@ typedef enum ItemType {
         COPY_FILES = 'C',
 
         /* These ones take globs */
+        WRITE_FILE = 'w',
         SET_XATTR = 't',
         RECURSIVE_SET_XATTR = 'T',
         SET_ACL = 'a',
         RECURSIVE_SET_ACL = 'A',
-        WRITE_FILE = 'w',
+        SET_ATTRIBUTE = 'h',
+        RECURSIVE_SET_ATTRIBUTE = 'H',
         IGNORE_PATH = 'x',
         IGNORE_DIRECTORY_PATH = 'X',
         REMOVE_PATH = 'r',
         RECURSIVE_REMOVE_PATH = 'R',
-        ADJUST_MODE = 'm', /* legacy, 'z' is identical to this */
         RELABEL_PATH = 'z',
         RECURSIVE_RELABEL_PATH = 'Z',
-        SET_ATTRIBUTE = 'h',
-        RECURSIVE_SET_ATTRIBUTE = 'H',
+        ADJUST_MODE = 'm', /* legacy, 'z' is identical to this */
 } ItemType;
 
 typedef struct Item {
@@ -1610,6 +1610,31 @@ static void item_array_free(ItemArray *a) {
         free(a);
 }
 
+static int item_compare(const void *a, const void *b) {
+        const Item *x = a, *y = b;
+
+        /* Make sure that the ownership taking item is put first, so
+         * that we first create the node, and then can adjust it */
+
+        if (takes_ownership(x->type) && !takes_ownership(y->type))
+                return -1;
+        if (!takes_ownership(x->type) && takes_ownership(y->type))
+                return 1;
+
+        return (int) x->type - (int) y->type;
+}
+
+static void item_array_sort(ItemArray *a) {
+
+        /* Sort an item array, to enforce stable ordering in which we
+         * apply things. */
+
+        if (a->count <= 1)
+                return;
+
+        qsort(a->items, a->count, sizeof(Item), item_compare);
+}
+
 static bool item_compatible(Item *a, Item *b) {
         assert(a);
         assert(b);
@@ -1944,6 +1969,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 return log_oom();
 
         memcpy(existing->items + existing->count++, &i, sizeof(i));
+        item_array_sort(existing);
+
         zero(i);
         return 0;
 }
@@ -2183,13 +2210,17 @@ int main(int argc, char *argv[]) {
                 }
         }
 
-        HASHMAP_FOREACH(a, globs, iterator) {
+        /* The non-globbing ones usually create things, hence we apply
+         * them first */
+        HASHMAP_FOREACH(a, items, iterator) {
                 k = process_item_array(a);
                 if (k < 0 && r == 0)
                         r = k;
         }
 
-        HASHMAP_FOREACH(a, items, iterator) {
+        /* The globbing ones usually alter things, hence we apply them
+         * second. */
+        HASHMAP_FOREACH(a, globs, iterator) {
                 k = process_item_array(a);
                 if (k < 0 && r == 0)
                         r = k;

commit 90937fe3d31b433a1794d181a4e028d3817c258d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 16:04:16 2015 +0200

    tmpfiles: eat up empty columns

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 7b649fe..dc8254c 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1860,7 +1860,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 i.path = p;
         }
 
-        if (user && !streq(user, "-")) {
+        if (!isempty(user) && !streq(user, "-")) {
                 const char *u = user;
 
                 r = get_user_creds(&u, &i.uid, NULL, NULL, NULL);
@@ -1872,7 +1872,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 i.uid_set = true;
         }
 
-        if (group && !streq(group, "-")) {
+        if (!isempty(group) && !streq(group, "-")) {
                 const char *g = group;
 
                 r = get_group_creds(&g, &i.gid);
@@ -1884,7 +1884,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 i.gid_set = true;
         }
 
-        if (mode && !streq(mode, "-")) {
+        if (!isempty(mode) && !streq(mode, "-")) {
                 const char *mm = mode;
                 unsigned m;
 
@@ -1904,7 +1904,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 i.mode = IN_SET(i.type, CREATE_DIRECTORY, CREATE_SUBVOLUME, TRUNCATE_DIRECTORY)
                         ? 0755 : 0644;
 
-        if (age && !streq(age, "-")) {
+        if (!isempty(age) && !streq(age, "-")) {
                 const char *a = age;
 
                 if (*a == '~') {

commit bd550f78eb261c757cbff85acdb55563c56521f2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 16:03:24 2015 +0200

    tmpfiles: substitute % specifiers in arguments for writing files and xattrs

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 6b95c4d..7b649fe 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -147,6 +147,14 @@ static const char conf_file_dirs[] = CONF_DIRS_NULSTR("tmpfiles");
 static Hashmap *items = NULL, *globs = NULL;
 static Set *unix_sockets = NULL;
 
+static const Specifier specifier_table[] = {
+        { 'm', specifier_machine_id, NULL },
+        { 'b', specifier_boot_id, NULL },
+        { 'H', specifier_host_name, NULL },
+        { 'v', specifier_kernel_release, NULL },
+        {}
+};
+
 static bool needs_glob(ItemType t) {
         return IN_SET(t,
                       WRITE_FILE,
@@ -622,7 +630,7 @@ static int path_set_perms(Item *i, const char *path) {
         return label_fix(path, false, false);
 }
 
-static int get_xattrs_from_arg(Item *i) {
+static int parse_xattrs_from_arg(Item *i) {
         const char *p;
         int r;
 
@@ -632,22 +640,26 @@ static int get_xattrs_from_arg(Item *i) {
         p = i->argument;
 
         for (;;) {
-                _cleanup_free_ char *name = NULL, *value = NULL, *xattr = NULL;
+                _cleanup_free_ char *name = NULL, *value = NULL, *xattr = NULL, *xattr_replaced = NULL;
 
                 r = unquote_first_word(&p, &xattr, UNQUOTE_CUNESCAPE);
                 if (r < 0)
-                        log_warning_errno(r, "Failed to parse extended attribute, ignoring: %s", p);
+                        log_warning_errno(r, "Failed to parse extended attribute '%s', ignoring: %m", p);
                 if (r <= 0)
                         break;
 
-                r = split_pair(xattr, "=", &name, &value);
+                r = specifier_printf(xattr, specifier_table, NULL, &xattr_replaced);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to replace specifiers in extended attribute '%s': %m", xattr);
+
+                r = split_pair(xattr_replaced, "=", &name, &value);
                 if (r < 0) {
                         log_warning_errno(r, "Failed to parse extended attribute, ignoring: %s", xattr);
                         continue;
                 }
 
                 if (isempty(name) || isempty(value)) {
-                        log_warning("Malformed xattr found, ignoring: %s", xattr);
+                        log_warning("Malformed extended attribute found, ignoring: %s", xattr);
                         continue;
                 }
 
@@ -670,17 +682,16 @@ static int path_set_xattrs(Item *i, const char *path) {
                 int n;
 
                 n = strlen(*value);
-                log_debug("\"%s\": setting xattr \"%s=%s\"", path, *name, *value);
+                log_debug("Setting extended attribute '%s=%s' on %s.", *name, *value, path);
                 if (lsetxattr(path, *name, *value, n, 0) < 0) {
-                        log_error("Setting extended attribute %s=%s on %s failed: %m",
-                                  *name, *value, path);
+                        log_error("Setting extended attribute %s=%s on %s failed: %m", *name, *value, path);
                         return -errno;
                 }
         }
         return 0;
 }
 
-static int get_acls_from_arg(Item *item) {
+static int parse_acls_from_arg(Item *item) {
 #ifdef HAVE_ACL
         int r;
 
@@ -688,6 +699,7 @@ static int get_acls_from_arg(Item *item) {
 
         /* If force (= modify) is set, we will not modify the acl
          * afterwards, so the mask can be added now if necessary. */
+
         r = parse_acl(item->argument, &item->acl_access, &item->acl_default, !item->force);
         if (r < 0)
                 log_warning_errno(r, "Failed to parse ACL \"%s\": %m. Ignoring", item->argument);
@@ -783,7 +795,7 @@ static int path_set_acls(Item *item, const char *path) {
          FS_TOPDIR_FL       |                   \
          FS_NOCOW_FL)
 
-static int get_attribute_from_arg(Item *item) {
+static int parse_attribute_from_arg(Item *item) {
 
         static const struct {
                 char character;
@@ -936,7 +948,7 @@ static int write_one_file(Item *i, const char *path) {
         }
 
         if (i->argument) {
-                _cleanup_free_ char *unescaped = NULL;
+                _cleanup_free_ char *unescaped = NULL, *replaced = NULL;
 
                 log_debug("%s to \"%s\".", i->type == CREATE_FILE ? "Appending" : "Writing", path);
 
@@ -944,7 +956,11 @@ static int write_one_file(Item *i, const char *path) {
                 if (r < 0)
                         return log_error_errno(r, "Failed to unescape parameter to write: %s", i->argument);
 
-                r = loop_write(fd, unescaped, strlen(unescaped), false);
+                r = specifier_printf(unescaped, specifier_table, NULL, &replaced);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to replace specifiers in parameter to write '%s': %m", unescaped);
+
+                r = loop_write(fd, replaced, strlen(replaced), false);
                 if (r < 0)
                         return log_error_errno(r, "Failed to write file \"%s\": %m", path);
         } else
@@ -1651,14 +1667,6 @@ static bool should_include_path(const char *path) {
 
 static int parse_line(const char *fname, unsigned line, const char *buffer) {
 
-        static const Specifier specifier_table[] = {
-                { 'm', specifier_machine_id, NULL },
-                { 'b', specifier_boot_id, NULL },
-                { 'H', specifier_host_name, NULL },
-                { 'v', specifier_kernel_release, NULL },
-                {}
-        };
-
         _cleanup_free_ char *action = NULL, *mode = NULL, *user = NULL, *group = NULL, *age = NULL, *path = NULL;
         _cleanup_(item_free_contents) Item i = {};
         ItemArray *existing;
@@ -1739,7 +1747,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
         case RELABEL_PATH:
         case RECURSIVE_RELABEL_PATH:
                 if (i.argument)
-                        log_warning("[%s:%u] %c lines don't take argument field, ignoring.", fname, line, i.type);
+                        log_warning("[%s:%u] %c lines don't take argument fields, ignoring.", fname, line, i.type);
 
                 break;
 
@@ -1799,7 +1807,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                         log_error("[%s:%u] Set extended attribute requires argument.", fname, line);
                         return -EBADMSG;
                 }
-                r = get_xattrs_from_arg(&i);
+                r = parse_xattrs_from_arg(&i);
                 if (r < 0)
                         return r;
                 break;
@@ -1810,7 +1818,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                         log_error("[%s:%u] Set ACLs requires argument.", fname, line);
                         return -EBADMSG;
                 }
-                r = get_acls_from_arg(&i);
+                r = parse_acls_from_arg(&i);
                 if (r < 0)
                         return r;
                 break;
@@ -1821,7 +1829,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                         log_error("[%s:%u] Set file attribute requires argument.", fname, line);
                         return -EBADMSG;
                 }
-                r = get_attribute_from_arg(&i);
+                r = parse_attribute_from_arg(&i);
                 if (r < 0)
                         return r;
                 break;

commit c82500c6fb37a25bc3c4b1e0be11a90a395619d9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 14:46:05 2015 +0200

    tmpfiles: warn if we get an argument on lines that don't take any

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 24a0d36..6b95c4d 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1727,8 +1727,6 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
 
         switch (i.type) {
 
-        case CREATE_FILE:
-        case TRUNCATE_FILE:
         case CREATE_DIRECTORY:
         case CREATE_SUBVOLUME:
         case TRUNCATE_DIRECTORY:
@@ -1740,6 +1738,13 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
         case ADJUST_MODE:
         case RELABEL_PATH:
         case RECURSIVE_RELABEL_PATH:
+                if (i.argument)
+                        log_warning("[%s:%u] %c lines don't take argument field, ignoring.", fname, line, i.type);
+
+                break;
+
+        case CREATE_FILE:
+        case TRUNCATE_FILE:
                 break;
 
         case CREATE_SYMLINK:

commit 3ea40b781060f4fa429f77356f8baef4bdf3d4b5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 14:44:52 2015 +0200

    tmpfiles: mostly revert 71044f609b829d802e0eb81270e13b4f55d76476
    
    Add a comment why returning a positive error is OK and intended in this
    case.
    
    (It's still a nasty hack to do this though!)

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index ce4a10a..24a0d36 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -734,10 +734,11 @@ static int path_set_acl(const char *path, acl_type_t type, acl_t acl, bool modif
 
         r = acl_set_file(path, type, dup);
         if (r < 0)
-                return log_error_errno(errno,
-                                       "Setting %s ACL \"%s\" on %s failed: %m",
-                                       type == ACL_TYPE_ACCESS ? "access" : "default",
-                                       strna(t), path);
+                /* Return positive to indicate we already warned */
+                return -log_error_errno(errno,
+                                        "Setting %s ACL \"%s\" on %s failed: %m",
+                                        type == ACL_TYPE_ACCESS ? "access" : "default",
+                                        strna(t), path);
 
         return 0;
 }

commit f0bc504794275ca0d326961f895bdd521b15dc6d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 14:43:37 2015 +0200

    device-nodes: minor simplifications

diff --git a/src/shared/device-nodes.c b/src/shared/device-nodes.c
index 8751797..9d5af72 100644
--- a/src/shared/device-nodes.c
+++ b/src/shared/device-nodes.c
@@ -25,12 +25,14 @@
 #include "utf8.h"
 
 int whitelisted_char_for_devnode(char c, const char *white) {
+
         if ((c >= '0' && c <= '9') ||
             (c >= 'A' && c <= 'Z') ||
             (c >= 'a' && c <= 'z') ||
             strchr("#+-.:=@_", c) != NULL ||
             (white != NULL && strchr(white, c) != NULL))
                 return 1;
+
         return 0;
 }
 
@@ -45,27 +47,34 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len) {
 
                 seqlen = utf8_encoded_valid_unichar(&str[i]);
                 if (seqlen > 1) {
+
                         if (len-j < (size_t)seqlen)
-                                goto err;
+                                return -EINVAL;
+
                         memcpy(&str_enc[j], &str[i], seqlen);
                         j += seqlen;
                         i += (seqlen-1);
+
                 } else if (str[i] == '\\' || !whitelisted_char_for_devnode(str[i], NULL)) {
+
                         if (len-j < 4)
-                                goto err;
+                                return -EINVAL;
+
                         sprintf(&str_enc[j], "\\x%02x", (unsigned char) str[i]);
                         j += 4;
+
                 } else {
                         if (len-j < 1)
-                                goto err;
+                                return -EINVAL;
+
                         str_enc[j] = str[i];
                         j++;
                 }
         }
+
         if (len-j < 1)
-                goto err;
+                return -EINVAL;
+
         str_enc[j] = '\0';
         return 0;
-err:
-        return -EINVAL;
 }

commit 2ff7b0a54271c8480024d6d68edff4a92e781052
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 14:43:06 2015 +0200

    util: unify how we parse mode_t strings

diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 2148a30..aa6a4a6 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -759,41 +759,30 @@ int config_parse_strv(const char *unit,
         return 0;
 }
 
-int config_parse_mode(const char *unit,
-                      const char *filename,
-                      unsigned line,
-                      const char *section,
+int config_parse_mode(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
                       unsigned section_line,
-                      const char *lvalue,
-                      int ltype,
-                      const char *rvalue,
-                      void *data,
-                      void *userdata) {
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
         mode_t *m = data;
-        long l;
-        char *x = NULL;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        errno = 0;
-        l = strtol(rvalue, &x, 8);
-        if (!x || x == rvalue || *x || errno) {
-                log_syntax(unit, LOG_ERR, filename, line, errno,
-                           "Failed to parse mode value, ignoring: %s", rvalue);
-                return 0;
-        }
-
-        if (l < 0000 || l > 07777) {
-                log_syntax(unit, LOG_ERR, filename, line, ERANGE,
-                           "Mode value out of range, ignoring: %s", rvalue);
+        if (parse_mode(rvalue, m) < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, errno, "Failed to parse mode value, ignoring: %s", rvalue);
                 return 0;
         }
 
-        *m = (mode_t) l;
         return 0;
 }
 
diff --git a/src/shared/util.c b/src/shared/util.c
index 8372038..df5f8d1 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -8159,3 +8159,24 @@ char *shell_maybe_quote(const char *s) {
 
         return r;
 }
+
+int parse_mode(const char *s, mode_t *ret) {
+        char *x;
+        long l;
+
+        assert(s);
+        assert(ret);
+
+        errno = 0;
+        l = strtol(s, &x, 8);
+        if (errno != 0)
+                return -errno;
+
+        if (!x || x == s || *x)
+                return -EINVAL;
+        if (l < 0 || l  > 07777)
+                return -ERANGE;
+
+        *ret = (mode_t) l;
+        return 0;
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 527867c..56e11c7 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -1089,3 +1089,5 @@ void cmsg_close_all(struct msghdr *mh);
 int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
 
 char *shell_maybe_quote(const char *s);
+
+int parse_mode(const char *s, mode_t *ret);
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 77e7400..4d36eb2 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1576,6 +1576,20 @@ static void test_shell_maybe_quote(void) {
         test_shell_maybe_quote_one("foo$bar", "\"foo\\$bar\"");
 }
 
+static void test_parse_mode(void) {
+        mode_t m;
+
+        assert_se(parse_mode("-1", &m) < 0);
+        assert_se(parse_mode("", &m) < 0);
+        assert_se(parse_mode("888", &m) < 0);
+        assert_se(parse_mode("77777", &m) < 0);
+
+        assert_se(parse_mode("544", &m) >= 0 && m == 0544);
+        assert_se(parse_mode("777", &m) >= 0 && m == 0777);
+        assert_se(parse_mode("7777", &m) >= 0 && m == 07777);
+        assert_se(parse_mode("0", &m) >= 0 && m == 0);
+}
+
 int main(int argc, char *argv[]) {
         log_parse_environment();
         log_open();
@@ -1654,6 +1668,7 @@ int main(int argc, char *argv[]) {
         test_uid_ptr();
         test_sparse_write();
         test_shell_maybe_quote();
+        test_parse_mode();
 
         return 0;
 }
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index d34de70..ce4a10a 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1879,9 +1879,9 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                         mm++;
                 }
 
-                if (sscanf(mm, "%o", &m) != 1) {
+                if (parse_mode(mm, &m) < 0) {
                         log_error("[%s:%u] Invalid mode '%s'.", fname, line, mode);
-                        return -ENOENT;
+                        return -EBADMSG;
                 }
 
                 i.mode = m;

commit 6dd67163b8f173649e7dc73740f35274714caafc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 10 12:21:44 2015 +0200

    util: remove normalize_env_assignment(), it's unused

diff --git a/src/shared/util.c b/src/shared/util.c
index 6e5c5ca..8372038 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3675,36 +3675,6 @@ static char *unquote(const char *s, const char* quotes) {
         return strdup(s);
 }
 
-char *normalize_env_assignment(const char *s) {
-        _cleanup_free_ char *value = NULL;
-        const char *eq;
-        char *p, *name;
-
-        eq = strchr(s, '=');
-        if (!eq) {
-                char *r, *t;
-
-                r = strdup(s);
-                if (!r)
-                        return NULL;
-
-                t = strstrip(r);
-                if (t != r)
-                        memmove(r, t, strlen(t) + 1);
-
-                return r;
-        }
-
-        name = strndupa(s, eq - s);
-        p = strdupa(eq + 1);
-
-        value = unquote(strstrip(p), QUOTES);
-        if (!value)
-                return NULL;
-
-        return strjoin(strstrip(name), "=", value, NULL);
-}
-
 int wait_for_terminate(pid_t pid, siginfo_t *status) {
         siginfo_t dummy;
 
diff --git a/src/shared/util.h b/src/shared/util.h
index 4a7f0da..527867c 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -522,8 +522,6 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
 int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
 int touch(const char *path);
 
-char *normalize_env_assignment(const char *s);
-
 int wait_for_terminate(pid_t pid, siginfo_t *status);
 int wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_code);
 
diff --git a/src/test/test-env-replace.c b/src/test/test-env-replace.c
index 8f1fcd9..2e28c0c 100644
--- a/src/test/test-env-replace.c
+++ b/src/test/test-env-replace.c
@@ -136,31 +136,6 @@ static void test_replace_env_arg(void) {
         assert_se(strv_length(r) == 9);
 }
 
-static void test_one_normalize(const char *input, const char *output) {
-        _cleanup_free_ char *t;
-
-        t = normalize_env_assignment(input);
-        assert_se(t);
-        assert_se(streq(t, output));
-}
-
-static void test_normalize_env_assignment(void) {
-        test_one_normalize("foo=bar", "foo=bar");
-        test_one_normalize("=bar", "=bar");
-        test_one_normalize("foo=", "foo=");
-        test_one_normalize("=", "=");
-        test_one_normalize("", "");
-        test_one_normalize("a=\"waldo\"", "a=waldo");
-        test_one_normalize("a=\"waldo", "a=\"waldo");
-        test_one_normalize("a=waldo\"", "a=waldo\"");
-        test_one_normalize("a=\'", "a='");
-        test_one_normalize("a=\'\'", "a=");
-        test_one_normalize(" xyz  ", "xyz");
-        test_one_normalize(" xyz = bar  ", "xyz=bar");
-        test_one_normalize(" xyz = 'bar ' ", "xyz=bar ");
-        test_one_normalize(" ' xyz' = 'bar ' ", "' xyz'=bar ");
-}
-
 static void test_env_clean(void) {
         _cleanup_strv_free_ char **e;
 
@@ -209,7 +184,6 @@ int main(int argc, char *argv[]) {
         test_strv_env_set();
         test_strv_env_merge();
         test_replace_env_arg();
-        test_normalize_env_assignment();
         test_env_clean();
         test_env_name_is_valid();
 



More information about the systemd-commits mailing list