diff options
author | Ansgar Burchardt <ansgar@debian.org> | 2014-07-27 15:19:00 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-27 15:15:11 -0400 |
commit | 0f625d0b87139fc18cd565c9b6da05c53a0eb7ab (patch) | |
tree | 176ec0f961fafc960b7dc80e2f766ffe6b12c511 /src/shared | |
parent | ccc6fa0d6b8e3ce5e7508ee8a141ee26f380b4a3 (diff) |
parse_boolean: require exact matches
Require exact matches in all cases instead of treating strings
starting with 't' ('f') as true (false).
This is required for config_parse_protect_system to parse ProtectSystem=full
correctly: it uses parse_boolean and only tries a more specific parsing
function if that did not return a valid result. Thus "full" was treated as
"false" before.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 4fda31c838..49c17eff85 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -231,9 +231,9 @@ int unlink_noerrno(const char *path) { int parse_boolean(const char *v) { assert(v); - if (streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || strcaseeq(v, "on")) + if (streq(v, "1") || strcaseeq(v, "yes") || strcaseeq(v, "y") || strcaseeq(v, "true") || strcaseeq(v, "t") || strcaseeq(v, "on")) return 1; - else if (streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || strcaseeq(v, "off")) + else if (streq(v, "0") || strcaseeq(v, "no") || strcaseeq(v, "n") || strcaseeq(v, "false") || strcaseeq(v, "f") || strcaseeq(v, "off")) return 0; return -EINVAL; |