diff options
author | Mantas MikulÄ—nas <grawity@gmail.com> | 2014-07-13 18:49:00 +0300 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-13 22:50:24 -0400 |
commit | 0ce5a80601597fe4d1a715a8f70ce8d5ccaa2d86 (patch) | |
tree | 5f16e4a27e78e170170de36486d339f9eb8be3fe /src/shared/fileio.c | |
parent | 667a1cd645c9402921dedff08a86bb35cddbcbf9 (diff) |
fileio: quote more shell characters in envfiles
Turns out, making strings shell-proof is harder than expected:
# machinectl set-hostname "foo|poweroff" && . /etc/machine-info
(This could be simplified by quoting *and* escaping all characters,
which is harmless in shell but unnecessary.)
Diffstat (limited to 'src/shared/fileio.c')
-rw-r--r-- | src/shared/fileio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/fileio.c b/src/shared/fileio.c index b0ab780d77..cbb40c2379 100644 --- a/src/shared/fileio.c +++ b/src/shared/fileio.c @@ -738,11 +738,11 @@ static void write_env_var(FILE *f, const char *v) { p++; fwrite(v, 1, p-v, f); - if (string_has_cc(p, NULL) || chars_intersect(p, WHITESPACE "\'\"\\`$")) { + if (string_has_cc(p, NULL) || chars_intersect(p, WHITESPACE SHELL_NEED_QUOTES)) { fputc('\"', f); for (; *p; p++) { - if (strchr("\'\"\\`$", *p)) + if (strchr(SHELL_NEED_ESCAPE, *p)) fputc('\\', f); fputc(*p, f); |