diff options
author | David Edmundson <kde@davidedmundson.co.uk> | 2022-09-13 13:06:09 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-14 03:54:28 +0900 |
commit | 38429cb1e3f37c298aa20ab25d644c87a23dd2e2 (patch) | |
tree | f4e5cf42334039b1ded824ab313ab6fc250aed4c /src/xdg-autostart-generator/xdg-autostart-service.c | |
parent | TODO: various things about partitioning (diff) | |
download | systemd-38429cb1e3f37c298aa20ab25d644c87a23dd2e2.tar.xz systemd-38429cb1e3f37c298aa20ab25d644c87a23dd2e2.zip |
xdg-autostart-service: Use common boolean parser
Technically the desktop entry specification says value should be the
string "true" or "false". Pragmatically every desktop has their own
parsing rules which are typically less strict on how to interpret other
values.
This caused some regressions downstream when we switched to the
xdg-autostart-generator where existing handmade files contained values
with "True" or "False".
Diffstat (limited to 'src/xdg-autostart-generator/xdg-autostart-service.c')
-rw-r--r-- | src/xdg-autostart-generator/xdg-autostart-service.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c index 75b6a62a975..56cc4ceeb9a 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.c +++ b/src/xdg-autostart-generator/xdg-autostart-service.c @@ -8,15 +8,16 @@ #include "conf-parser.h" #include "escape.h" -#include "unit-name.h" -#include "path-util.h" #include "fd-util.h" #include "generator.h" #include "log.h" +#include "nulstr-util.h" +#include "parse-util.h" +#include "path-util.h" #include "specifier.h" #include "string-util.h" -#include "nulstr-util.h" #include "strv.h" +#include "unit-name.h" XdgAutostartService* xdg_autostart_service_free(XdgAutostartService *s) { if (!s) @@ -74,18 +75,16 @@ static int xdg_config_parse_bool( void *userdata) { bool *b = ASSERT_PTR(data); + int r; assert(filename); assert(lvalue); assert(rvalue); - if (streq(rvalue, "true")) - *b = true; - else if (streq(rvalue, "false")) - *b = false; - else + r = parse_boolean(rvalue); + if (r < 0) return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Invalid value for boolean: %s", rvalue); - + *b = r; return 0; } |