mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 06:52:22 +03:00
systemctl: show Environment entries with whitespace
This makes the Environment entries more round-trippable: a similar format is used for input and output. It is certainly more useful for users, because showing [unprintable] on anything non-trivial makes systemctl show -p Environment useless in many cases. Fixes: #14723 and https://bugzilla.redhat.com/show_bug.cgi?id=1525593. $ systemctl --user show -p Environment run-*.service Environment=ASDF=asfd "SPACE= " Environment=ASDF=asfd "SPACE=\n\n\n" Environment=ASDF=asfd "TAB=\t\\" "FOO=X X"
This commit is contained in:
parent
2b99f645c6
commit
241c4b6ada
@ -21,6 +21,7 @@
|
||||
#include "bus-util.h"
|
||||
#include "cap-list.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "escape.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "nsflags.h"
|
||||
#include "parse-util.h"
|
||||
@ -500,18 +501,20 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
|
||||
return r;
|
||||
|
||||
while ((r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &str)) > 0) {
|
||||
bool good;
|
||||
_cleanup_free_ char *e = NULL;
|
||||
|
||||
if (first && !value)
|
||||
printf("%s=", name);
|
||||
e = shell_maybe_quote(str, ESCAPE_BACKSLASH_ONELINE);
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
/* This property has multiple space-separated values, so
|
||||
* neither spaces nor newlines can be allowed in a value. */
|
||||
good = str[strcspn(str, " \n")] == '\0';
|
||||
if (first) {
|
||||
if (!value)
|
||||
printf("%s=", name);
|
||||
first = false;
|
||||
} else
|
||||
fputs(" ", stdout);
|
||||
|
||||
printf("%s%s", first ? "" : " ", good ? str : "[unprintable]");
|
||||
|
||||
first = false;
|
||||
fputs(e, stdout);
|
||||
}
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
Loading…
Reference in New Issue
Block a user