X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fgenerator.c;h=414470be1c4a1ecf8029c60bb711ac93ea0a802e;hb=c73d180dc4bbd87c945a524b42b672af2ffe2609;hp=1db5f8fb626802a2a7b9e75d7411abb41763e38d;hpb=b3208b662948b51ff34e7b7752e28ec7a48708ae;p=elogind.git diff --git a/src/shared/generator.c b/src/shared/generator.c index 1db5f8fb6..414470be1 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -108,7 +108,7 @@ int generator_write_timeouts(const char *dir, const char *what, const char *wher timeout = start + 25; else { if (filtered) { - *filtered = strdup(opts); + *filtered = strdup(opts ?: ""); if (!*filtered) return log_oom(); } @@ -125,7 +125,7 @@ int generator_write_timeouts(const char *dir, const char *what, const char *wher char *prefix, *postfix; prefix = strndupa(opts, start - opts - (start != opts)); - postfix = timeout + len + (timeout[len] != '\0'); + postfix = timeout + len + (start == opts && timeout[len] != '\0'); *filtered = strjoin(prefix, *postfix ? postfix : NULL, NULL); if (!*filtered) return log_oom(); @@ -146,6 +146,9 @@ int generator_write_timeouts(const char *dir, const char *what, const char *wher if (!unit) return -ENOMEM; - return write_drop_in_format(dir, unit, "device-timeout", - "[Unit]\nJobTimeoutSec=%u", u / USEC_PER_SEC); + return write_drop_in_format(dir, unit, 50, "device-timeout", + "# Automatically generated by %s\n\n" + "[Unit]\nJobTimeoutSec=" USEC_FMT, + program_invocation_short_name, + u / USEC_PER_SEC); }