diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-09 18:32:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-09 18:32:21 +0200 |
commit | 019c7fba754f74909bdb8bbbbbbe529082928a95 (patch) | |
tree | 9b53a83d39a2b128e46065625fb6a298942e90f8 /src/libsystemd/sd-bus/bus-util.c | |
parent | ab51b943d42eb6a5e4c6e26cd3c641d4e604bd1c (diff) |
util: add shell_maybe_quote() call for preparing a string for shell cmdline inclusion
If necessary the passed string is enclosed in "", and all special
characters escapes.
This also ports over usage in bus-util.c and job.c to use this, instead
of a incorrect local implementation that forgets to properly escape.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-util.c')
-rw-r--r-- | src/libsystemd/sd-bus/bus-util.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 6498769260..45882abaad 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -1735,16 +1735,15 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet) { else if (streq(d->result, "unsupported")) log_error("Operation on or unit type of %s not supported on this system.", strna(d->name)); else if (!streq(d->result, "done") && !streq(d->result, "skipped")) { - if (d->name) { - bool quotes; + _cleanup_free_ char *quoted = NULL; - quotes = chars_intersect(d->name, SHELL_NEED_QUOTES); + if (d->name) + quoted = shell_maybe_quote(d->name); - log_error("Job for %s failed. See \"systemctl status %s%s%s\" and \"journalctl -xe\" for details.", - d->name, - quotes ? "'" : "", d->name, quotes ? "'" : ""); - } else - log_error("Job failed. See \"journalctl -xe\" for details."); + if (quoted) + log_error("Job for %s failed. See 'systemctl status %s' and 'journalctl -xe' for details.", d->name, quoted); + else + log_error("Job failed. See 'journalctl -xe' for details."); } } |