summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-30 04:10:40 +0900
committerGitHub <noreply@github.com>2019-06-30 04:10:40 +0900
commit539bcc831b67a047e4e19469eb4471fc4ea024b6 (patch)
treebe56cbc4b9ce4c1d07e4c3f1de0aac44b984cf0d /src
parente0e334d0e42fa6d27a3d6ab5e593cb40e19d6f5a (diff)
parent9c02391088558427152014b2b8a87c36a129f675 (diff)
downloadsystemd-539bcc831b67a047e4e19469eb4471fc4ea024b6.tar.gz
Merge pull request #12903 from keszybz/condition-quoting
Condition quoting
Diffstat (limited to 'src')
-rw-r--r--src/basic/cap-list.c2
-rw-r--r--src/basic/env-util.c2
-rw-r--r--src/basic/extract-word.c2
-rw-r--r--src/basic/extract-word.h2
-rw-r--r--src/basic/proc-cmdline.c2
-rw-r--r--src/core/device.c4
-rw-r--r--src/core/load-fragment.c49
-rw-r--r--src/journal-remote/journal-remote-main.c2
-rw-r--r--src/locale/keymap-util.c6
-rw-r--r--src/resolve/resolvconf-compat.c2
-rw-r--r--src/resolve/resolved-conf.c4
-rw-r--r--src/resolve/resolved-dns-trust-anchor.c4
-rw-r--r--src/shared/bus-unit-util.c28
-rw-r--r--src/shared/condition.c97
-rw-r--r--src/shared/conf-parser.c2
-rw-r--r--src/shared/cpu-set-util.c2
-rw-r--r--src/shared/mount-util.c2
-rw-r--r--src/shared/securebits-util.c2
-rw-r--r--src/sysusers/sysusers.c2
-rw-r--r--src/sysv-generator/sysv-generator.c4
-rw-r--r--src/test/test-condition.c126
-rw-r--r--src/test/test-extract-word.c54
-rw-r--r--src/test/test-string-util.c2
-rw-r--r--src/test/test-strv.c4
-rw-r--r--src/tmpfiles/tmpfiles.c4
25 files changed, 235 insertions, 175 deletions
diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c
index 2c0b7416a4..79d6a40aa9 100644
--- a/src/basic/cap-list.c
+++ b/src/basic/cap-list.c
@@ -100,7 +100,7 @@ int capability_set_from_string(const char *s, uint64_t *set) {
_cleanup_free_ char *word = NULL;
int r;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return r;
if (r <= 0)
diff --git a/src/basic/env-util.c b/src/basic/env-util.c
index 896eec5835..b39b1ed0f8 100644
--- a/src/basic/env-util.c
+++ b/src/basic/env-util.c
@@ -688,7 +688,7 @@ char **replace_env_argv(char **argv, char **env) {
if (e) {
int r;
- r = strv_split_extract(&m, e, WHITESPACE, EXTRACT_RELAX|EXTRACT_QUOTES);
+ r = strv_split_extract(&m, e, WHITESPACE, EXTRACT_RELAX|EXTRACT_UNQUOTE);
if (r < 0) {
ret[k] = NULL;
strv_free(ret);
diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c
index a861b56653..34cfb36a4a 100644
--- a/src/basic/extract-word.c
+++ b/src/basic/extract-word.c
@@ -135,7 +135,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
for (;; (*p)++, c = **p) {
if (c == 0)
goto finish_force_terminate;
- else if (IN_SET(c, '\'', '"') && (flags & EXTRACT_QUOTES)) {
+ else if (IN_SET(c, '\'', '"') && (flags & EXTRACT_UNQUOTE)) {
quote = c;
break;
} else if (c == '\\' && !(flags & EXTRACT_RETAIN_ESCAPE)) {
diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h
index 705ebbe95b..e2d433893a 100644
--- a/src/basic/extract-word.h
+++ b/src/basic/extract-word.h
@@ -7,7 +7,7 @@ typedef enum ExtractFlags {
EXTRACT_RELAX = 1 << 0,
EXTRACT_CUNESCAPE = 1 << 1,
EXTRACT_CUNESCAPE_RELAX = 1 << 2,
- EXTRACT_QUOTES = 1 << 3,
+ EXTRACT_UNQUOTE = 1 << 3,
EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 4,
EXTRACT_RETAIN_ESCAPE = 1 << 5,
} ExtractFlags;
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c
index b82ca4b21b..09169cf963 100644
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -47,7 +47,7 @@ static int proc_cmdline_extract_first(const char **p, char **ret_word, ProcCmdli
_cleanup_free_ char *word = NULL;
const char *c;
- r = extract_first_word(&q, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
+ r = extract_first_word(&q, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
if (r < 0)
return r;
if (r == 0)
diff --git a/src/core/device.c b/src/core/device.c
index f478393f1a..e2abca469a 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -374,7 +374,7 @@ static int device_add_udev_wants(Unit *u, sd_device *dev) {
for (;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&wants, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&wants, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -626,7 +626,7 @@ static int device_process_new(Manager *m, sd_device *dev) {
for (;;) {
_cleanup_free_ char *word = NULL;
- r = extract_first_word(&alias, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&alias, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index d88b9317e9..3288b0b838 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -334,7 +334,7 @@ int config_parse_unit_path_strv_printf(
for (p = rvalue;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -638,7 +638,7 @@ int config_parse_exec(
semicolon = false;
- r = extract_first_word_and_warn(&p, &firstword, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE, unit, filename, line, rvalue);
+ r = extract_first_word_and_warn(&p, &firstword, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE, unit, filename, line, rvalue);
if (r <= 0)
return 0;
@@ -784,7 +784,7 @@ int config_parse_exec(
continue;
}
- r = extract_first_word_and_warn(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE, unit, filename, line, rvalue);
+ r = extract_first_word_and_warn(&p, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE, unit, filename, line, rvalue);
if (r == 0)
break;
if (r < 0)
@@ -2244,7 +2244,7 @@ int config_parse_environ(
for (p = rvalue;; ) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -2312,7 +2312,7 @@ int config_parse_pass_environ(
for (;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -2388,7 +2388,7 @@ int config_parse_unset_environ(
for (;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -2463,7 +2463,7 @@ int config_parse_log_extra_fields(
struct iovec *t;
const char *eq;
- r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -2597,7 +2597,8 @@ int config_parse_unit_condition_string(
r = unit_full_printf(u, rvalue, &s);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, r,
+ "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue);
return 0;
}
@@ -2687,7 +2688,7 @@ int config_parse_unit_requires_mounts_for(
for (;;) {
_cleanup_free_ char *word = NULL, *resolved = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -2882,7 +2883,7 @@ int config_parse_syscall_archs(
_cleanup_free_ char *word = NULL;
uint32_t a;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -2986,7 +2987,7 @@ int config_parse_address_families(
_cleanup_free_ char *word = NULL;
int af;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -3305,7 +3306,7 @@ int config_parse_delegate(
_cleanup_free_ char *word = NULL;
CGroupController cc;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -3362,7 +3363,7 @@ int config_parse_device_allow(
return 0;
}
- r = extract_first_word(&p, &path, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -3433,7 +3434,7 @@ int config_parse_io_device_weight(
return 0;
}
- r = extract_first_word(&p, &path, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -3507,7 +3508,7 @@ int config_parse_io_device_latency(
return 0;
}
- r = extract_first_word(&p, &path, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -3581,7 +3582,7 @@ int config_parse_io_limit(
return 0;
}
- r = extract_first_word(&p, &path, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -3672,7 +3673,7 @@ int config_parse_blockio_device_weight(
return 0;
}
- r = extract_first_word(&p, &path, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -3750,7 +3751,7 @@ int config_parse_blockio_bandwidth(
return 0;
}
- r = extract_first_word(&p, &path, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -3870,7 +3871,7 @@ int config_parse_exec_directories(
for (p = rvalue;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -4006,7 +4007,7 @@ int config_parse_namespace_path_strv(
const char *w;
bool ignore_enoent = false, shall_prefix = false;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -4084,7 +4085,7 @@ int config_parse_temporary_filesystems(
_cleanup_free_ char *word = NULL, *path = NULL, *resolved = NULL;
const char *w;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -4160,7 +4161,7 @@ int config_parse_bind_paths(
char *s = NULL, *d = NULL;
bool rbind = true, ignore_enoent = false;
- r = extract_first_word(&p, &source, ":" WHITESPACE, EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS);
+ r = extract_first_word(&p, &source, ":" WHITESPACE, EXTRACT_UNQUOTE|EXTRACT_DONT_COALESCE_SEPARATORS);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -4189,7 +4190,7 @@ int config_parse_bind_paths(
/* Optionally, the destination is specified. */
if (p && p[-1] == ':') {
- r = extract_first_word(&p, &destination, ":" WHITESPACE, EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS);
+ r = extract_first_word(&p, &destination, ":" WHITESPACE, EXTRACT_UNQUOTE|EXTRACT_DONT_COALESCE_SEPARATORS);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
@@ -4218,7 +4219,7 @@ int config_parse_bind_paths(
if (p && p[-1] == ':') {
_cleanup_free_ char *options = NULL;
- r = extract_first_word(&p, &options, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &options, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index d32c51c3ce..329505cd2c 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -123,7 +123,7 @@ static int spawn_getter(const char *getter) {
_cleanup_strv_free_ char **words = NULL;
assert(getter);
- r = strv_split_extract(&words, getter, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&words, getter, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return log_error_errno(r, "Failed to split getter option: %m");
diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c
index c7dcd8ad38..1394514839 100644
--- a/src/locale/keymap-util.c
+++ b/src/locale/keymap-util.c
@@ -252,7 +252,7 @@ int x11_read_data(Context *c, sd_bus_message *m) {
if (in_section && first_word(l, "Option")) {
_cleanup_strv_free_ char **a = NULL;
- r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return r;
@@ -276,7 +276,7 @@ int x11_read_data(Context *c, sd_bus_message *m) {
} else if (!in_section && first_word(l, "Section")) {
_cleanup_strv_free_ char **a = NULL;
- r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return -ENOMEM;
@@ -491,7 +491,7 @@ static int read_next_mapping(const char* filename,
if (IN_SET(l[0], 0, '#'))
continue;
- r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return r;
diff --git a/src/resolve/resolvconf-compat.c b/src/resolve/resolvconf-compat.c
index d1f65056d0..8cd14711df 100644
--- a/src/resolve/resolvconf-compat.c
+++ b/src/resolve/resolvconf-compat.c
@@ -82,7 +82,7 @@ static int parse_search_domain(const char *string) {
for (;;) {
_cleanup_free_ char *word = NULL;
- r = extract_first_word(&string, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&string, &word, NULL, EXTRACT_UNQUOTE);
if (r < 0)
return r;
if (r == 0)
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c
index 7b2938fea3..0c8d2a679c 100644
--- a/src/resolve/resolved-conf.c
+++ b/src/resolve/resolved-conf.c
@@ -119,7 +119,7 @@ int manager_parse_search_domains_and_warn(Manager *m, const char *string) {
for (;;) {
_cleanup_free_ char *word = NULL;
- r = extract_first_word(&string, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&string, &word, NULL, EXTRACT_UNQUOTE);
if (r < 0)
return r;
if (r == 0)
@@ -308,7 +308,7 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
int r;
r = extract_first_word(&rvalue, &word, NULL,
- EXTRACT_QUOTES|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX);
+ EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX);
if (r == 0)
break;
if (r == -ENOMEM)
diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c
index 3e4cc331d9..89e48403f0 100644
--- a/src/resolve/resolved-dns-trust-anchor.c
+++ b/src/resolve/resolved-dns-trust-anchor.c
@@ -216,7 +216,7 @@ static int dns_trust_anchor_load_positive(DnsTrustAnchor *d, const char *path, u
assert(d);
assert(line);
- r = extract_first_word(&p, &domain, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &domain, NULL, EXTRACT_UNQUOTE);
if (r < 0)
return log_warning_errno(r, "Unable to parse domain in line %s:%u: %m", path, line);
@@ -386,7 +386,7 @@ static int dns_trust_anchor_load_negative(DnsTrustAnchor *d, const char *path, u
assert(d);
assert(line);
- r = extract_first_word(&p, &domain, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &domain, NULL, EXTRACT_UNQUOTE);
if (r < 0)
return log_warning_errno(r, "Unable to parse line %s:%u: %m", path, line);
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 2ea25d830a..6a7358e301 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -325,12 +325,12 @@ static int bus_append_exec_command(sd_bus_message *m, const char *field, const c
}
if (explicit_path) {
- r = extract_first_word(&eq, &path, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE);
+ r = extract_first_word(&eq, &path, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE);
if (r < 0)
return log_error_errno(r, "Failed to parse path: %m");
}
- r = strv_split_extract(&l, eq, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE);
+ r = strv_split_extract(&l, eq, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE);
if (r < 0)
return log_error_errno(r, "Failed to parse command line: %m");
@@ -440,13 +440,13 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
if (streq(field, "DisableControllers"))
- return bus_append_strv(m, "DisableControllers", eq, EXTRACT_QUOTES);
+ return bus_append_strv(m, "DisableControllers", eq, EXTRACT_UNQUOTE);
if (streq(field, "Delegate")) {
r = parse_boolean(eq);
if (r < 0)
- return bus_append_strv(m, "DelegateControllers", eq, EXTRACT_QUOTES);
+ return bus_append_strv(m, "DelegateControllers", eq, EXTRACT_UNQUOTE);
r = sd_bus_message_append(m, "(sv)", "Delegate", "b", r);
if (r < 0)
@@ -819,7 +819,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
"RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory",
"SupplementaryGroups", "SystemCallArchitectures"))
- return bus_append_strv(m, field, eq, EXTRACT_QUOTES);
+ return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
if (STR_IN_SET(field, "SyslogLevel", "LogLevelMax"))
@@ -881,7 +881,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (STR_IN_SET(field, "Environment", "UnsetEnvironment", "PassEnvironment"))
- return bus_append_strv(m, field, eq, EXTRACT_QUOTES|EXTRACT_CUNESCAPE);
+ return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE);
if (streq(field, "EnvironmentFile")) {
@@ -1125,7 +1125,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
for (;;) {
_cleanup_free_ char *word = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -1212,7 +1212,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
bool ignore_enoent = false;
uint64_t flags = MS_REC;
- r = extract_first_word(&p, &source, ":" WHITESPACE, EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS);
+ r = extract_first_word(&p, &source, ":" WHITESPACE, EXTRACT_UNQUOTE|EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
return log_error_errno(r, "Failed to parse argument: %m");
if (r == 0)
@@ -1225,7 +1225,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
}
if (p && p[-1] == ':') {
- r = extract_first_word(&p, &destination, ":" WHITESPACE, EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS);
+ r = extract_first_word(&p, &destination, ":" WHITESPACE, EXTRACT_UNQUOTE|EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
return log_error_errno(r, "Failed to parse argument: %m");
if (r == 0)
@@ -1238,7 +1238,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (p && p[-1] == ':') {
_cleanup_free_ char *options = NULL;
- r = extract_first_word(&p, &options, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &options, NULL, EXTRACT_UNQUOTE);
if (r < 0)
return log_error_errno(r, "Failed to parse argument: %m");
@@ -1297,7 +1297,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
_cleanup_free_ char *word = NULL, *path = NULL;
const char *w;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r < 0)
return log_error_errno(r, "Failed to parse argument: %m");
if (r == 0)
@@ -1446,7 +1446,7 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
_cleanup_free_ char *word = NULL;
int val;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM)
@@ -1566,7 +1566,7 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
if (streq(field, "Symlinks"))
- return bus_append_strv(m, field, eq, EXTRACT_QUOTES);
+ return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
if (streq(field, "SocketProtocol"))
@@ -1684,7 +1684,7 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
if (unit_dependency_from_string(field) >= 0 ||
STR_IN_SET(field, "Documentation", "RequiresMountsFor"))
- return bus_append_strv(m, field, eq, EXTRACT_QUOTES);
+ return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
t = condition_type_from_string(field);
if (t >= 0)
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 70ede533c0..8c613fcd5f 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -114,7 +114,7 @@ static int condition_test_kernel_command_line(Condition *c) {
_cleanup_free_ char *word = NULL;
bool found;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
if (r < 0)
return r;
if (r == 0)
@@ -207,6 +207,7 @@ static int condition_test_kernel_version(Condition *c) {
OrderOperator order;
struct utsname u;
const char *p;
+ bool first = true;
assert(c);
assert(c->parameter);
@@ -215,13 +216,49 @@ static int condition_test_kernel_version(Condition *c) {
assert_se(uname(&u) >= 0);
p = c->parameter;
- order = parse_order(&p);
- /* No prefix? Then treat as glob string */
- if (order < 0)
- return fnmatch(skip_leading_chars(c->parameter, NULL), u.release, 0) == 0;
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+ const char *s;
+ int r;
+
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to parse condition string \"%s\": %m", p);
+ if (r == 0)
+ break;
+
+ s = strstrip(word);
+ order = parse_order(&s);
+ if (order >= 0) {
+ s += strspn(s, WHITESPACE);
+ if (isempty(s)) {
+ if (first) {
+ /* For backwards compatibility, allow whitespace between the operator and
+ * value, without quoting, but only in the first expression. */
+ word = mfree(word);
+ r = extract_first_word(&p, &word, NULL, 0);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to parse condition string \"%s\": %m", p);
+ if (r == 0)
+ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Unexpected end of expression: %s", p);
+ s = word;
+ } else
+ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Unexpected end of expression: %s", p);
+ }
+
+ r = test_order(str_verscmp(u.release, s), order);
+ } else
+ /* No prefix? Then treat as glob string */
+ r = fnmatch(s, u.release, 0) == 0;
+
+ if (r == 0)
+ return false;
+
+ first = false;
+ }
- return test_order(str_verscmp(u.release, skip_leading_chars(p, NULL)), order);
+ return true;
}
static int condition_test_memory(Condition *c) {
@@ -684,31 +721,31 @@ static int condition_test_null(Condition *c) {
int condition_test(Condition *c) {
static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c) = {
- [CONDITION_PATH_EXISTS] = condition_test_path_exists,
- [CONDITION_PATH_EXISTS_GLOB] = condition_test_path_exists_glob,
- [CONDITION_PATH_IS_DIRECTORY] = condition_test_path_is_directory,
- [CONDITION_PATH_IS_SYMBOLIC_LINK] = condition_test_path_is_symbolic_link,
- [CONDITION_PATH_IS_MOUNT_POINT] = condition_test_path_is_mount_point,
- [CONDITION_PATH_IS_READ_WRITE] = condition_test_path_is_read_write,
- [CONDITION_DIRECTORY_NOT_EMPTY] = condition_test_directory_not_empty,
- [CONDITION_FILE_NOT_EMPTY] = condition_test_file_not_empty,
- [CONDITION_FILE_IS_EXECUTABLE] = condition_test_file_is_executable,
- [CONDITION_KERNEL_COMMAND_LINE] = condition_test_kernel_command_line,
- [CONDITION_KERNEL_VERSION] = condition_test_kernel_version,
- [CONDITION_VIRTUALIZATION] = condition_test_virtualization,
- [CONDITION_SECURITY] = condition_test_security,
- [CONDITION_CAPABILITY] = condition_test_capability,
- [CONDITION_HOST] = condition_test_host,
- [CONDITION_AC_POWER] = condition_test_ac_power,
- [CONDITION_ARCHITECTURE] = condition_test_architecture,
- [CONDITION_NEEDS_UPDATE] = condition_test_needs_update,
- [CONDITION_FIRST_BOOT] = condition_test_first_boot,
- [CONDITION_USER] = condition_test_user,
- [CONDITION_GROUP] = condition_test_group,
+ [CONDITION_PATH_EXISTS] = condition_test_path_exists,
+ [CONDITION_PATH_EXISTS_GLOB] = condition_test_path_exists_glob,
+ [CONDITION_PATH_IS_DIRECTORY] = condition_test_path_is_directory,
+ [CONDITION_PATH_IS_SYMBOLIC_LINK] = condition_test_path_is_symbolic_link,
+ [CONDITION_PATH_IS_MOUNT_POINT] = condition_test_path_is_mount_point,
+ [CONDITION_PATH_IS_READ_WRITE] = condition_test_path_is_read_write,
+ [CONDITION_DIRECTORY_NOT_EMPTY] = condition_test_directory_not_empty,
+ [CONDITION_FILE_NOT_EMPTY] = condition_test_file_not_empty,
+ [CONDITION_FILE_IS_EXECUTABLE] = condition_test_file_is_executable,
+ [CONDITION_KERNEL_COMMAND_LINE] = condition_test_kernel_command_line,
+ [CONDITION_KERNEL_VERSION] = condition_test_kernel_version,
+ [CONDITION_VIRTUALIZATION] = condition_test_virtualization,
+ [CONDITION_SECURITY] = condition_test_security,
+ [CONDITION_CAPABILITY] = condition_test_capability,
+ [CONDITION_HOST] = condition_test_host,
+ [CONDITION_AC_POWER] = condition_test_ac_power,
+ [CONDITION_ARCHITECTURE] = condition_test_architecture,
+ [CONDITION_NEEDS_UPDATE] = condition_test_needs_update,
+ [CONDITION_FIRST_BOOT] = condition_test_first_boot,
+ [CONDITION_USER] = condition_test_user,
+ [CONDITION_GROUP] = condition_test_group,
[CONDITION_CONTROL_GROUP_CONTROLLER] = condition_test_control_group_controller,
- [CONDITION_NULL] = condition_test_null,
- [CONDITION_CPUS] = condition_test_cpus,
- [CONDITION_MEMORY] = condition_test_memory,
+ [CONDITION_NULL] = condition_test_null,
+ [CONDITION_CPUS] = condition_test_cpus,
+ [CONDITION_MEMORY] = condition_test_memory,
};
int r, b;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index f45dd798b2..c27c499eda 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -758,7 +758,7 @@ int config_parse_strv(
for (;;) {
char *word = NULL;
- r = extract_first_word(&rvalue, &word, NULL, EXTRACT_QUOTES|EXTRACT_RETAIN_ESCAPE);
+ r = extract_first_word(&rvalue, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE);
if (r == 0)
break;
if (r == -ENOMEM)
diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c
index f27543dfe2..219314ef58 100644
--- a/src/shared/cpu-set-util.c
+++ b/src/shared/cpu-set-util.c
@@ -155,7 +155,7 @@ int parse_cpu_set_full(
unsigned cpu_lower, cpu_upper;
int r;
- r = extract_first_word(&p, &word, WHITESPACE ",", EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, WHITESPACE ",", EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return warn ? log_oom() : -ENOMEM;
if (r < 0)
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index 9129ad5f6b..de9e35b128 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -505,7 +505,7 @@ int mount_option_mangle(
_cleanup_free_ char *word = NULL;
const struct libmnt_optmap *ent;
- r = extract_first_word(&p, &word, ",", EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, ",", EXTRACT_UNQUOTE);
if (r < 0)
return r;
if (r == 0)
diff --git a/src/shared/securebits-util.c b/src/shared/securebits-util.c
index 6d31dfeff0..b2abaf4f52 100644
--- a/src/shared/securebits-util.c
+++ b/src/shared/securebits-util.c
@@ -42,7 +42,7 @@ int secure_bits_from_string(const char *s) {
for (p = s;;) {
_cleanup_free_ char *word = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM)
return r;
if (r <= 0)
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 843c3837d1..990a2f927b 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -1390,7 +1390,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
/* Parse columns */
p = buffer;
- r = extract_many_words(&p, NULL, EXTRACT_QUOTES,
+ r = extract_many_words(&p, NULL, EXTRACT_UNQUOTE,
&action, &name, &id, &description, &home, &shell, NULL);
if (r < 0)
return log_error_errno(r, "[%s:%u] Syntax error.", fname, line);
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 28f8ab301b..175e4a2393 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -322,7 +322,7 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co
for (;;) {
_cleanup_free_ char *word = NULL, *m = NULL;
- r = extract_first_word(&text, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
+ r = extract_first_word(&text, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
if (r < 0)
return log_error_errno(r, "[%s:%u] Failed to parse word from provides string: %m", s->path, line);
if (r == 0)
@@ -391,7 +391,7 @@ static int handle_dependencies(SysvStub *s, unsigned line, const char *full_text
_cleanup_free_ char *word = NULL, *m = NULL;
bool is_before;
- r = extract_first_word(&text, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
+ r = extract_first_word(&text, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
if (r < 0)
return log_error_errno(r, "[%s:%u] Failed to parse word from provides string: %m", s->path, line);
if (r == 0)
diff --git a/src/test/test-condition.c b/src/test/test-condition.c
index 4bbca2074f..a79263a50b 100644
--- a/src/test/test-condition.c
+++ b/src/test/test-condition.c
@@ -43,77 +43,77 @@ static void test_condition_test_path(void) {
condition = condition_new(CONDITION_PATH_EXISTS, "/bin/s?", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, true);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, true);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_IS_DIRECTORY, "/bin", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_DIRECTORY_NOT_EMPTY, "/bin", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_FILE_NOT_EMPTY, "/bin/sh", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/bin/sh", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/etc/passwd", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/proc", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/bin", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_IS_READ_WRITE, "/tmp", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_PATH_IS_SYMBOLIC_LINK, "/dev/stdout", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
}
@@ -133,12 +133,12 @@ static void test_condition_test_control_group_controller(void) {
/* Invalid controllers are ignored */
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, "thisisnotarealcontroller", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, "thisisnotarealcontroller", false, true);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
assert_se(cg_mask_supported(&system_mask) >= 0);
@@ -151,23 +151,23 @@ static void test_condition_test_control_group_controller(void) {
log_info("this controller is available");
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, true);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
} else {
log_info("this controller is unavailable");
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, local_controller_name, false, true);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
}
}
@@ -177,12 +177,12 @@ static void test_condition_test_control_group_controller(void) {
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, strempty(controller_name), false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, strempty(controller_name), false, true);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
}
@@ -218,17 +218,17 @@ static void test_condition_test_host(void) {
condition = condition_new(CONDITION_HOST, sid, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_HOST, "garbage value jjjjjjjjjjjjjj", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_HOST, sid, false, true);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
hostname = gethostname_malloc();
@@ -240,7 +240,7 @@ static void test_condition_test_host(void) {
else {
condition = condition_new(CONDITION_HOST, hostname, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
}
}
@@ -277,12 +277,12 @@ static void test_condition_test_kernel_command_line(void) {
condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "thisreallyshouldntbeonthekernelcommandline", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "andthis=neither", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
}
@@ -293,24 +293,26 @@ static void test_condition_test_kernel_version(void) {
condition = condition_new(CONDITION_KERNEL_VERSION, "*thisreallyshouldntbeinthekernelversion*", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "*", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
+ /* An artificially empty condition. It evaluates to true, but normally
+ * such condition cannot be created, because the condition list is reset instead. */
condition = condition_new(CONDITION_KERNEL_VERSION, "", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
assert_se(uname(&u) >= 0);
condition = condition_new(CONDITION_KERNEL_VERSION, u.release, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
strshorten(u.release, 4);
@@ -318,59 +320,79 @@ static void test_condition_test_kernel_version(void) {
condition = condition_new(CONDITION_KERNEL_VERSION, u.release, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
/* 0.1.2 would be a very very very old kernel */
condition = condition_new(CONDITION_KERNEL_VERSION, "> 0.1.2", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_KERNEL_VERSION, ">0.1.2", false, false);
+ assert_se(condition);
+ assert_se(condition_test(condition) > 0);
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_KERNEL_VERSION, "'>0.1.2' '<9.0.0'", false, false);
+ assert_se(condition);
+ assert_se(condition_test(condition) > 0);
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_KERNEL_VERSION, "> 0.1.2 < 9.0.0", false, false);
+ assert_se(condition);
+ assert_se(condition_test(condition) == -EINVAL);
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_KERNEL_VERSION, ">", false, false);
+ assert_se(condition);
+ assert_se(condition_test(condition) == -EINVAL);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, ">= 0.1.2", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "< 0.1.2", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "<= 0.1.2", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "= 0.1.2", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
/* 4711.8.15 is a very very very future kernel */
condition = condition_new(CONDITION_KERNEL_VERSION, "< 4711.8.15", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "<= 4711.8.15", false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "= 4711.8.15", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, "> 4711.8.15", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_VERSION, ">= 4711.8.15", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
assert_se(uname(&u) >= 0);
@@ -378,31 +400,31 @@ static void test_condition_test_kernel_version(void) {
v = strjoina(">=", u.release);
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
v = strjoina("= ", u.release);
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
v = strjoina("<=", u.release);
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
v = strjoina("> ", u.release);
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
v = strjoina("< ", u.release);
condition = condition_new(CONDITION_KERNEL_VERSION, v, false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
}
@@ -411,12 +433,12 @@ static void test_condition_test_null(void) {
condition = condition_new(CONDITION_NULL, NULL, false, false);
assert_se(condition);
- assert_se(condition_test(condition));
+ assert_se(condition_test(condition) > 0);
condition_free(condition);
condition = condition_new(CONDITION_NULL, NULL, false, true);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
}
@@ -425,7 +447,7 @@ static void test_condition_test_security(void) {
condition = condition_new(CONDITION_SECURITY, "garbage oifdsjfoidsjoj", false, false);
assert_se(condition);
- assert_se(!condition_test(condition));
+ assert_se(condition_test(condition) == 0);
condition_free(condition);
condition = condition_new(CONDITION_SECURITY, "selinux", false, true);
diff --git a/src/test/test-extract-word.c b/src/test/test-extract-word.c
index 30019382ae..f148b3e6f1 100644
--- a/src/test/test-extract-word.c
+++ b/src/test/test-extract-word.c
@@ -43,12 +43,12 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "\"foobar\" \'waldo\'";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) > 0);
assert_se(streq(t, "foobar"));
free(t);
assert_se(p == original + 9);
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) > 0);
assert_se(streq(t, "waldo"));
free(t);
assert_se(isempty(p));
@@ -64,7 +64,7 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "\"";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) == -EINVAL);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) == -EINVAL);
assert_se(p == original + 1);
p = original = "\'";
@@ -74,7 +74,7 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "\'";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) == -EINVAL);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) == -EINVAL);
assert_se(p == original + 1);
p = original = "\'fooo";
@@ -84,17 +84,17 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "\'fooo";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) == -EINVAL);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) == -EINVAL);
assert_se(p == original + 5);
p = original = "\'fooo";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_RELAX) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX) > 0);
assert_se(streq(t, "fooo"));
free(t);
assert_se(isempty(p));
p = original = "\"fooo";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_RELAX) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX) > 0);
assert_se(streq(t, "fooo"));
free(t);
assert_se(isempty(p));
@@ -106,7 +106,7 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "yay\'foo\'bar";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) > 0);
assert_se(streq(t, "yayfoobar"));
free(t);
assert_se(isempty(p));
@@ -135,7 +135,7 @@ static void test_extract_first_word(void) {
free(t);
assert_se(p == original + 13);
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE) > 0);
assert_se(streq(t, "pi\360\237\222\251le"));
free(t);
assert_se(isempty(p));
@@ -169,7 +169,7 @@ static void test_extract_first_word(void) {
assert_se(p == original + 5);
p = original = "\"foo\\";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_RELAX) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX) > 0);
assert_se(streq(t, "foo"));
free(t);
assert_se(isempty(p));
@@ -205,17 +205,17 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "\"foo\\";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE_RELAX) == -EINVAL);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE_RELAX) == -EINVAL);
assert_se(p == original + 5);
p = original = "\"foo\\";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0);
assert_se(streq(t, "foo\\"));
free(t);
assert_se(isempty(p));
p = original = "\"foo\\";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0);
assert_se(streq(t, "foo\\"));
free(t);
assert_se(isempty(p));
@@ -265,12 +265,12 @@ static void test_extract_first_word(void) {
assert_se(isempty(p));
p = original = "-N ''";
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) > 0);
assert_se(streq(t, "-N"));
free(t);
assert_se(p == original + 3);
- assert_se(extract_first_word(&p, &t, NULL, EXTRACT_QUOTES) > 0);
+ assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE) > 0);
assert_se(streq(t, ""));
free(t);
assert_se(isempty(p));
@@ -340,12 +340,12 @@ static void test_extract_first_word_and_warn(void) {
assert_se(isempty(p));
p = original = "\"foobar\" \'waldo\'";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES, NULL, "fake", 1, original) > 0);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE, NULL, "fake", 1, original) > 0);
assert_se(streq(t, "foobar"));
free(t);
assert_se(p == original + 9);
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES, NULL, "fake", 1, original) > 0);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE, NULL, "fake", 1, original) > 0);
assert_se(streq(t, "waldo"));
free(t);
assert_se(isempty(p));
@@ -355,19 +355,19 @@ static void test_extract_first_word_and_warn(void) {
assert_se(isempty(p));
p = original = "\"";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES, NULL, "fake", 1, original) == -EINVAL);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE, NULL, "fake", 1, original) == -EINVAL);
assert_se(p == original + 1);
p = original = "\'";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES, NULL, "fake", 1, original) == -EINVAL);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE, NULL, "fake", 1, original) == -EINVAL);
assert_se(p == original + 1);
p = original = "\'fooo";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES, NULL, "fake", 1, original) == -EINVAL);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE, NULL, "fake", 1, original) == -EINVAL);
assert_se(p == original + 5);
p = original = "\'fooo";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_RELAX, NULL, "fake", 1, original) > 0);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX, NULL, "fake", 1, original) > 0);
assert_se(streq(t, "fooo"));
free(t);
assert_se(isempty(p));
@@ -390,7 +390,7 @@ static void test_extract_first_word_and_warn(void) {
free(t);
assert_se(p == original + 13);
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE, NULL, "fake", 1, original) > 0);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE, NULL, "fake", 1, original) > 0);
assert_se(streq(t, "pi\360\237\222\251le"));
free(t);
assert_se(isempty(p));
@@ -414,21 +414,21 @@ static void test_extract_first_word_and_warn(void) {
assert_se(isempty(p));
p = original = "\"foo\\";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES, NULL, "fake", 1, original) == -EINVAL);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE, NULL, "fake", 1, original) == -EINVAL);
assert_se(p == original + 5);
p = original = "\"foo\\";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_RELAX, NULL, "fake", 1, original) > 0);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX, NULL, "fake", 1, original) > 0);
assert_se(streq(t, "foo"));
free(t);
assert_se(isempty(p));
p = original = "\"foo\\";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE, NULL, "fake", 1, original) == -EINVAL);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE, NULL, "fake", 1, original) == -EINVAL);
assert_se(p == original + 5);
p = original = "\"foo\\";
- assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE|EXTRACT_RELAX, NULL, "fake", 1, original) > 0);
+ assert_se(extract_first_word_and_warn(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_RELAX, NULL, "fake", 1, original) > 0);
assert_se(streq(t, "foo"));
free(t);
assert_se(isempty(p));
@@ -488,7 +488,7 @@ static void test_extract_many_words(void) {
free(b);
p = original = "'foobar' wa\"ld\"i ";
- assert_se(extract_many_words(&p, NULL, EXTRACT_QUOTES, &a, &b, &c, NULL) == 2);
+ assert_se(extract_many_words(&p, NULL, EXTRACT_UNQUOTE, &a, &b, &c, NULL) == 2);
assert_se(isempty(p));
assert_se(streq_ptr(a, "foobar"));
assert_se(streq_ptr(b, "waldi"));
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
index 064a5abdac..f7dde618d3 100644
--- a/src/test/test-string-util.c
+++ b/src/test/test-string-util.c
@@ -380,7 +380,7 @@ static void check(const char *test, char** expected, bool trailing) {
for (;;) {
_cleanup_free_ char *word = NULL;
- r = extract_first_word(&test, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&test, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0) {
assert_se(!trailing);
break;
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 18ad03669c..488025f23a 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -204,7 +204,7 @@ static void test_strv_unquote(const char *quoted, char **list) {
char **t;
int r;
- r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_UNQUOTE);
assert_se(r == (int) strv_length(list));
assert_se(s);
j = strv_join(s, " | ");
@@ -221,7 +221,7 @@ static void test_invalid_unquote(const char *quoted) {
char **s = NULL;
int r;
- r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_UNQUOTE);
assert_se(s == NULL);
assert_se(r == -EINVAL);
}
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 7b091006ea..b8ee856a15 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -923,7 +923,7 @@ static int parse_xattrs_from_arg(Item *i) {
for (;;) {
_cleanup_free_ char *name = NULL, *value = NULL, *xattr = NULL;
- r = extract_first_word(&p, &xattr, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE);
+ r = extract_first_word(&p, &xattr, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE);
if (r < 0)
log_warning_errno(r, "Failed to parse extended attribute '%s', ignoring: %m", p);
if (r <= 0)
@@ -2502,7 +2502,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
r = extract_many_words(
&buffer,
NULL,
- EXTRACT_QUOTES,
+ EXTRACT_UNQUOTE,
&action,
&path,
&mode,