summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backlight/backlight.c7
-rw-r--r--src/basic/escape.c480
-rw-r--r--src/basic/escape.h48
-rw-r--r--src/basic/extract-word.c1
-rw-r--r--src/basic/fileio.c5
-rw-r--r--src/basic/process-util.c17
-rw-r--r--src/basic/strv.c1
-rw-r--r--src/basic/util.c458
-rw-r--r--src/basic/util.h23
-rw-r--r--src/core/job.c19
-rw-r--r--src/core/load-fragment.c1
-rw-r--r--src/core/manager.c1
-rw-r--r--src/core/mount.c26
-rw-r--r--src/core/service.c35
-rw-r--r--src/core/swap.c19
-rw-r--r--src/core/umount.c11
-rw-r--r--src/core/unit.c41
-rw-r--r--src/cryptsetup/cryptsetup.c11
-rw-r--r--src/import/pull-common.c13
-rw-r--r--src/journal-remote/journal-remote.c3
-rw-r--r--src/journal/coredump.c28
-rw-r--r--src/journal/journald-kmsg.c13
-rw-r--r--src/journal/journald-stream.c16
-rw-r--r--src/libsystemd/sd-bus/busctl.c1
-rw-r--r--src/libsystemd/sd-login/sd-login.c15
-rw-r--r--src/login/logind-acl.c7
-rw-r--r--src/login/logind-dbus.c28
-rw-r--r--src/login/logind-inhibit.c7
-rw-r--r--src/login/logind-session.c16
-rw-r--r--src/login/logind-user.c27
-rw-r--r--src/machine/machine.c3
-rw-r--r--src/nspawn/nspawn-mount.c15
-rw-r--r--src/rfkill/rfkill.c1
-rw-r--r--src/shared/bus-util.c3
-rw-r--r--src/shared/dropin.c11
-rw-r--r--src/shared/generator.c13
-rw-r--r--src/test/test-util.c1
-rw-r--r--src/tmpfiles/tmpfiles.c1
-rw-r--r--src/udev/udev-rules.c28
39 files changed, 775 insertions, 679 deletions
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index c8961de946..84ce842cae 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -19,12 +19,13 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
-#include "mkdir.h"
+#include "def.h"
+#include "escape.h"
#include "fileio.h"
#include "libudev.h"
+#include "mkdir.h"
#include "udev-util.h"
-#include "def.h"
+#include "util.h"
static struct udev_device *find_pci_or_platform_parent(struct udev_device *device) {
struct udev_device *parent;
diff --git a/src/basic/escape.c b/src/basic/escape.c
new file mode 100644
index 0000000000..cf05ce10ef
--- /dev/null
+++ b/src/basic/escape.c
@@ -0,0 +1,480 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "utf8.h"
+#include "util.h"
+
+#include "escape.h"
+
+size_t cescape_char(char c, char *buf) {
+ char * buf_old = buf;
+
+ switch (c) {
+
+ case '\a':
+ *(buf++) = '\\';
+ *(buf++) = 'a';
+ break;
+ case '\b':
+ *(buf++) = '\\';
+ *(buf++) = 'b';
+ break;
+ case '\f':
+ *(buf++) = '\\';
+ *(buf++) = 'f';
+ break;
+ case '\n':
+ *(buf++) = '\\';
+ *(buf++) = 'n';
+ break;
+ case '\r':
+ *(buf++) = '\\';
+ *(buf++) = 'r';
+ break;
+ case '\t':
+ *(buf++) = '\\';
+ *(buf++) = 't';
+ break;
+ case '\v':
+ *(buf++) = '\\';
+ *(buf++) = 'v';
+ break;
+ case '\\':
+ *(buf++) = '\\';
+ *(buf++) = '\\';
+ break;
+ case '"':
+ *(buf++) = '\\';
+ *(buf++) = '"';
+ break;
+ case '\'':
+ *(buf++) = '\\';
+ *(buf++) = '\'';
+ break;
+
+ default:
+ /* For special chars we prefer octal over
+ * hexadecimal encoding, simply because glib's
+ * g_strescape() does the same */
+ if ((c < ' ') || (c >= 127)) {
+ *(buf++) = '\\';
+ *(buf++) = octchar((unsigned char) c >> 6);
+ *(buf++) = octchar((unsigned char) c >> 3);
+ *(buf++) = octchar((unsigned char) c);
+ } else
+ *(buf++) = c;
+ break;
+ }
+
+ return buf - buf_old;
+}
+
+char *cescape(const char *s) {
+ char *r, *t;
+ const char *f;
+
+ assert(s);
+
+ /* Does C style string escaping. May be reversed with
+ * cunescape(). */
+
+ r = new(char, strlen(s)*4 + 1);
+ if (!r)
+ return NULL;
+
+ for (f = s, t = r; *f; f++)
+ t += cescape_char(*f, t);
+
+ *t = 0;
+
+ return r;
+}
+
+int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode) {
+ int r = 1;
+
+ assert(p);
+ assert(*p);
+ assert(ret);
+
+ /* Unescapes C style. Returns the unescaped character in ret,
+ * unless we encountered a \u sequence in which case the full
+ * unicode character is returned in ret_unicode, instead. */
+
+ if (length != (size_t) -1 && length < 1)
+ return -EINVAL;
+
+ switch (p[0]) {
+
+ case 'a':
+ *ret = '\a';
+ break;
+ case 'b':
+ *ret = '\b';
+ break;
+ case 'f':
+ *ret = '\f';
+ break;
+ case 'n':
+ *ret = '\n';
+ break;
+ case 'r':
+ *ret = '\r';
+ break;
+ case 't':
+ *ret = '\t';
+ break;
+ case 'v':
+ *ret = '\v';
+ break;
+ case '\\':
+ *ret = '\\';
+ break;
+ case '"':
+ *ret = '"';
+ break;
+ case '\'':
+ *ret = '\'';
+ break;
+
+ case 's':
+ /* This is an extension of the XDG syntax files */
+ *ret = ' ';
+ break;
+
+ case 'x': {
+ /* hexadecimal encoding */
+ int a, b;
+
+ if (length != (size_t) -1 && length < 3)
+ return -EINVAL;
+
+ a = unhexchar(p[1]);
+ if (a < 0)
+ return -EINVAL;
+
+ b = unhexchar(p[2]);
+ if (b < 0)
+ return -EINVAL;
+
+ /* Don't allow NUL bytes */
+ if (a == 0 && b == 0)
+ return -EINVAL;
+
+ *ret = (char) ((a << 4U) | b);
+ r = 3;
+ break;
+ }
+
+ case 'u': {
+ /* C++11 style 16bit unicode */
+
+ int a[4];
+ unsigned i;
+ uint32_t c;
+
+ if (length != (size_t) -1 && length < 5)
+ return -EINVAL;
+
+ for (i = 0; i < 4; i++) {
+ a[i] = unhexchar(p[1 + i]);
+ if (a[i] < 0)
+ return a[i];
+ }
+
+ c = ((uint32_t) a[0] << 12U) | ((uint32_t) a[1] << 8U) | ((uint32_t) a[2] << 4U) | (uint32_t) a[3];
+
+ /* Don't allow 0 chars */
+ if (c == 0)
+ return -EINVAL;
+
+ if (c < 128)
+ *ret = c;
+ else {
+ if (!ret_unicode)
+ return -EINVAL;
+
+ *ret = 0;
+ *ret_unicode = c;
+ }
+
+ r = 5;
+ break;
+ }
+
+ case 'U': {
+ /* C++11 style 32bit unicode */
+
+ int a[8];
+ unsigned i;
+ uint32_t c;
+
+ if (length != (size_t) -1 && length < 9)
+ return -EINVAL;
+
+ for (i = 0; i < 8; i++) {
+ a[i] = unhexchar(p[1 + i]);
+ if (a[i] < 0)
+ return a[i];
+ }
+
+ c = ((uint32_t) a[0] << 28U) | ((uint32_t) a[1] << 24U) | ((uint32_t) a[2] << 20U) | ((uint32_t) a[3] << 16U) |
+ ((uint32_t) a[4] << 12U) | ((uint32_t) a[5] << 8U) | ((uint32_t) a[6] << 4U) | (uint32_t) a[7];
+
+ /* Don't allow 0 chars */
+ if (c == 0)
+ return -EINVAL;
+
+ /* Don't allow invalid code points */
+ if (!unichar_is_valid(c))
+ return -EINVAL;
+
+ if (c < 128)
+ *ret = c;
+ else {
+ if (!ret_unicode)
+ return -EINVAL;
+
+ *ret = 0;
+ *ret_unicode = c;
+ }
+
+ r = 9;
+ break;
+ }
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7': {
+ /* octal encoding */
+ int a, b, c;
+ uint32_t m;
+
+ if (length != (size_t) -1 && length < 3)
+ return -EINVAL;
+
+ a = unoctchar(p[0]);
+ if (a < 0)
+ return -EINVAL;
+
+ b = unoctchar(p[1]);
+ if (b < 0)
+ return -EINVAL;
+
+ c = unoctchar(p[2]);
+ if (c < 0)
+ return -EINVAL;
+
+ /* don't allow NUL bytes */
+ if (a == 0 && b == 0 && c == 0)
+ return -EINVAL;
+
+ /* Don't allow bytes above 255 */
+ m = ((uint32_t) a << 6U) | ((uint32_t) b << 3U) | (uint32_t) c;
+ if (m > 255)
+ return -EINVAL;
+
+ *ret = m;
+ r = 3;
+ break;
+ }
+
+ default:
+ return -EINVAL;
+ }
+
+ return r;
+}
+
+int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret) {
+ char *r, *t;
+ const char *f;
+ size_t pl;
+
+ assert(s);
+ assert(ret);
+
+ /* Undoes C style string escaping, and optionally prefixes it. */
+
+ pl = prefix ? strlen(prefix) : 0;
+
+ r = new(char, pl+length+1);
+ if (!r)
+ return -ENOMEM;
+
+ if (prefix)
+ memcpy(r, prefix, pl);
+
+ for (f = s, t = r + pl; f < s + length; f++) {
+ size_t remaining;
+ uint32_t u;
+ char c;
+ int k;
+
+ remaining = s + length - f;
+ assert(remaining > 0);
+
+ if (*f != '\\') {
+ /* A literal literal, copy verbatim */
+ *(t++) = *f;
+ continue;
+ }
+
+ if (remaining == 1) {
+ if (flags & UNESCAPE_RELAX) {
+ /* A trailing backslash, copy verbatim */
+ *(t++) = *f;
+ continue;
+ }
+
+ free(r);
+ return -EINVAL;
+ }
+
+ k = cunescape_one(f + 1, remaining - 1, &c, &u);
+ if (k < 0) {
+ if (flags & UNESCAPE_RELAX) {
+ /* Invalid escape code, let's take it literal then */
+ *(t++) = '\\';
+ continue;
+ }
+
+ free(r);
+ return k;
+ }
+
+ if (c != 0)
+ /* Non-Unicode? Let's encode this directly */
+ *(t++) = c;
+ else
+ /* Unicode? Then let's encode this in UTF-8 */
+ t += utf8_encode_unichar(t, u);
+
+ f += k;
+ }
+
+ *t = 0;
+
+ *ret = r;
+ return t - r;
+}
+
+int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret) {
+ return cunescape_length_with_prefix(s, length, NULL, flags, ret);
+}
+
+int cunescape(const char *s, UnescapeFlags flags, char **ret) {
+ return cunescape_length(s, strlen(s), flags, ret);
+}
+
+char *xescape(const char *s, const char *bad) {
+ char *r, *t;
+ const char *f;
+
+ /* Escapes all chars in bad, in addition to \ and all special
+ * chars, in \xFF style escaping. May be reversed with
+ * cunescape(). */
+
+ r = new(char, strlen(s) * 4 + 1);
+ if (!r)
+ return NULL;
+
+ for (f = s, t = r; *f; f++) {
+
+ if ((*f < ' ') || (*f >= 127) ||
+ (*f == '\\') || strchr(bad, *f)) {
+ *(t++) = '\\';
+ *(t++) = 'x';
+ *(t++) = hexchar(*f >> 4);
+ *(t++) = hexchar(*f);
+ } else
+ *(t++) = *f;
+ }
+
+ *t = 0;
+
+ return r;
+}
+
+static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) {
+ assert(bad);
+
+ for (; *s; s++) {
+ if (*s == '\\' || strchr(bad, *s))
+ *(t++) = '\\';
+
+ *(t++) = *s;
+ }
+
+ return t;
+}
+
+char *shell_escape(const char *s, const char *bad) {
+ char *r, *t;
+
+ r = new(char, strlen(s)*2+1);
+ if (!r)
+ return NULL;
+
+ t = strcpy_backslash_escaped(r, s, bad);
+ *t = 0;
+
+ return r;
+}
+
+char *shell_maybe_quote(const char *s) {
+ const char *p;
+ char *r, *t;
+
+ assert(s);
+
+ /* Encloses a string in double quotes if necessary to make it
+ * OK as shell string. */
+
+ for (p = s; *p; p++)
+ if (*p <= ' ' ||
+ *p >= 127 ||
+ strchr(SHELL_NEED_QUOTES, *p))
+ break;
+
+ if (!*p)
+ return strdup(s);
+
+ r = new(char, 1+strlen(s)*2+1+1);
+ if (!r)
+ return NULL;
+
+ t = r;
+ *(t++) = '"';
+ t = mempcpy(t, s, p - s);
+
+ t = strcpy_backslash_escaped(t, p, SHELL_NEED_ESCAPE);
+
+ *(t++)= '"';
+ *t = 0;
+
+ return r;
+}
diff --git a/src/basic/escape.h b/src/basic/escape.h
new file mode 100644
index 0000000000..85ba909081
--- /dev/null
+++ b/src/basic/escape.h
@@ -0,0 +1,48 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <sys/types.h>
+#include <inttypes.h>
+
+/* What characters are special in the shell? */
+/* must be escaped outside and inside double-quotes */
+#define SHELL_NEED_ESCAPE "\"\\`$"
+/* can be escaped or double-quoted */
+#define SHELL_NEED_QUOTES SHELL_NEED_ESCAPE GLOB_CHARS "'()<>|&;"
+
+typedef enum UnescapeFlags {
+ UNESCAPE_RELAX = 1,
+} UnescapeFlags;
+
+char *cescape(const char *s);
+size_t cescape_char(char c, char *buf);
+
+int cunescape(const char *s, UnescapeFlags flags, char **ret);
+int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret);
+int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret);
+int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode);
+
+char *xescape(const char *s, const char *bad);
+
+char *shell_escape(const char *s, const char *bad);
+char *shell_maybe_quote(const char *s);
diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c
index 5e74f1832b..52d2672390 100644
--- a/src/basic/extract-word.c
+++ b/src/basic/extract-word.c
@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "escape.h"
#include "utf8.h"
#include "util.h"
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 13a85e1158..65a6a6558b 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -21,10 +21,11 @@
#include <unistd.h>
-#include "util.h"
+#include "ctype.h"
+#include "escape.h"
#include "strv.h"
#include "utf8.h"
-#include "ctype.h"
+#include "util.h"
#include "fileio.h"
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index d8a94a4572..3199efeafd 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -17,21 +17,22 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdbool.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
#include <signal.h>
-#include <ctype.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include "escape.h"
#include "fileio.h"
-#include "util.h"
#include "log.h"
#include "signal-util.h"
+#include "util.h"
#include "process-util.h"
int get_process_state(pid_t pid) {
diff --git a/src/basic/strv.c b/src/basic/strv.c
index 501d022cb9..446d4a5631 100644
--- a/src/basic/strv.c
+++ b/src/basic/strv.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <errno.h>
+#include "escape.h"
#include "util.h"
#include "strv.h"
diff --git a/src/basic/util.c b/src/basic/util.c
index 641e0b4d89..d6488f8fd6 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -77,6 +77,7 @@
#include "def.h"
#include "device-nodes.h"
#include "env-util.h"
+#include "escape.h"
#include "exit-status.h"
#include "fileio.h"
#include "formats-util.h"
@@ -96,8 +97,8 @@
#include "strv.h"
#include "terminal-util.h"
#include "utf8.h"
-#include "util.h"
#include "virt.h"
+#include "util.h"
/* Put this test here for a lack of better place */
assert_cc(EAGAIN == EWOULDBLOCK);
@@ -214,69 +215,6 @@ char* first_word(const char *s, const char *word) {
return (char*) p;
}
-size_t cescape_char(char c, char *buf) {
- char * buf_old = buf;
-
- switch (c) {
-
- case '\a':
- *(buf++) = '\\';
- *(buf++) = 'a';
- break;
- case '\b':
- *(buf++) = '\\';
- *(buf++) = 'b';
- break;
- case '\f':
- *(buf++) = '\\';
- *(buf++) = 'f';
- break;
- case '\n':
- *(buf++) = '\\';
- *(buf++) = 'n';
- break;
- case '\r':
- *(buf++) = '\\';
- *(buf++) = 'r';
- break;
- case '\t':
- *(buf++) = '\\';
- *(buf++) = 't';
- break;
- case '\v':
- *(buf++) = '\\';
- *(buf++) = 'v';
- break;
- case '\\':
- *(buf++) = '\\';
- *(buf++) = '\\';
- break;
- case '"':
- *(buf++) = '\\';
- *(buf++) = '"';
- break;
- case '\'':
- *(buf++) = '\\';
- *(buf++) = '\'';
- break;
-
- default:
- /* For special chars we prefer octal over
- * hexadecimal encoding, simply because glib's
- * g_strescape() does the same */
- if ((c < ' ') || (c >= 127)) {
- *(buf++) = '\\';
- *(buf++) = octchar((unsigned char) c >> 6);
- *(buf++) = octchar((unsigned char) c >> 3);
- *(buf++) = octchar((unsigned char) c);
- } else
- *(buf++) = c;
- break;
- }
-
- return buf - buf_old;
-}
-
int close_nointr(int fd) {
assert(fd >= 0);
@@ -1566,338 +1504,6 @@ int undecchar(char c) {
return -EINVAL;
}
-char *cescape(const char *s) {
- char *r, *t;
- const char *f;
-
- assert(s);
-
- /* Does C style string escaping. May be reversed with
- * cunescape(). */
-
- r = new(char, strlen(s)*4 + 1);
- if (!r)
- return NULL;
-
- for (f = s, t = r; *f; f++)
- t += cescape_char(*f, t);
-
- *t = 0;
-
- return r;
-}
-
-int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode) {
- int r = 1;
-
- assert(p);
- assert(*p);
- assert(ret);
-
- /* Unescapes C style. Returns the unescaped character in ret,
- * unless we encountered a \u sequence in which case the full
- * unicode character is returned in ret_unicode, instead. */
-
- if (length != (size_t) -1 && length < 1)
- return -EINVAL;
-
- switch (p[0]) {
-
- case 'a':
- *ret = '\a';
- break;
- case 'b':
- *ret = '\b';
- break;
- case 'f':
- *ret = '\f';
- break;
- case 'n':
- *ret = '\n';
- break;
- case 'r':
- *ret = '\r';
- break;
- case 't':
- *ret = '\t';
- break;
- case 'v':
- *ret = '\v';
- break;
- case '\\':
- *ret = '\\';
- break;
- case '"':
- *ret = '"';
- break;
- case '\'':
- *ret = '\'';
- break;
-
- case 's':
- /* This is an extension of the XDG syntax files */
- *ret = ' ';
- break;
-
- case 'x': {
- /* hexadecimal encoding */
- int a, b;
-
- if (length != (size_t) -1 && length < 3)
- return -EINVAL;
-
- a = unhexchar(p[1]);
- if (a < 0)
- return -EINVAL;
-
- b = unhexchar(p[2]);
- if (b < 0)
- return -EINVAL;
-
- /* Don't allow NUL bytes */
- if (a == 0 && b == 0)
- return -EINVAL;
-
- *ret = (char) ((a << 4U) | b);
- r = 3;
- break;
- }
-
- case 'u': {
- /* C++11 style 16bit unicode */
-
- int a[4];
- unsigned i;
- uint32_t c;
-
- if (length != (size_t) -1 && length < 5)
- return -EINVAL;
-
- for (i = 0; i < 4; i++) {
- a[i] = unhexchar(p[1 + i]);
- if (a[i] < 0)
- return a[i];
- }
-
- c = ((uint32_t) a[0] << 12U) | ((uint32_t) a[1] << 8U) | ((uint32_t) a[2] << 4U) | (uint32_t) a[3];
-
- /* Don't allow 0 chars */
- if (c == 0)
- return -EINVAL;
-
- if (c < 128)
- *ret = c;
- else {
- if (!ret_unicode)
- return -EINVAL;
-
- *ret = 0;
- *ret_unicode = c;
- }
-
- r = 5;
- break;
- }
-
- case 'U': {
- /* C++11 style 32bit unicode */
-
- int a[8];
- unsigned i;
- uint32_t c;
-
- if (length != (size_t) -1 && length < 9)
- return -EINVAL;
-
- for (i = 0; i < 8; i++) {
- a[i] = unhexchar(p[1 + i]);
- if (a[i] < 0)
- return a[i];
- }
-
- c = ((uint32_t) a[0] << 28U) | ((uint32_t) a[1] << 24U) | ((uint32_t) a[2] << 20U) | ((uint32_t) a[3] << 16U) |
- ((uint32_t) a[4] << 12U) | ((uint32_t) a[5] << 8U) | ((uint32_t) a[6] << 4U) | (uint32_t) a[7];
-
- /* Don't allow 0 chars */
- if (c == 0)
- return -EINVAL;
-
- /* Don't allow invalid code points */
- if (!unichar_is_valid(c))
- return -EINVAL;
-
- if (c < 128)
- *ret = c;
- else {
- if (!ret_unicode)
- return -EINVAL;
-
- *ret = 0;
- *ret_unicode = c;
- }
-
- r = 9;
- break;
- }
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7': {
- /* octal encoding */
- int a, b, c;
- uint32_t m;
-
- if (length != (size_t) -1 && length < 3)
- return -EINVAL;
-
- a = unoctchar(p[0]);
- if (a < 0)
- return -EINVAL;
-
- b = unoctchar(p[1]);
- if (b < 0)
- return -EINVAL;
-
- c = unoctchar(p[2]);
- if (c < 0)
- return -EINVAL;
-
- /* don't allow NUL bytes */
- if (a == 0 && b == 0 && c == 0)
- return -EINVAL;
-
- /* Don't allow bytes above 255 */
- m = ((uint32_t) a << 6U) | ((uint32_t) b << 3U) | (uint32_t) c;
- if (m > 255)
- return -EINVAL;
-
- *ret = m;
- r = 3;
- break;
- }
-
- default:
- return -EINVAL;
- }
-
- return r;
-}
-
-int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret) {
- char *r, *t;
- const char *f;
- size_t pl;
-
- assert(s);
- assert(ret);
-
- /* Undoes C style string escaping, and optionally prefixes it. */
-
- pl = prefix ? strlen(prefix) : 0;
-
- r = new(char, pl+length+1);
- if (!r)
- return -ENOMEM;
-
- if (prefix)
- memcpy(r, prefix, pl);
-
- for (f = s, t = r + pl; f < s + length; f++) {
- size_t remaining;
- uint32_t u;
- char c;
- int k;
-
- remaining = s + length - f;
- assert(remaining > 0);
-
- if (*f != '\\') {
- /* A literal literal, copy verbatim */
- *(t++) = *f;
- continue;
- }
-
- if (remaining == 1) {
- if (flags & UNESCAPE_RELAX) {
- /* A trailing backslash, copy verbatim */
- *(t++) = *f;
- continue;
- }
-
- free(r);
- return -EINVAL;
- }
-
- k = cunescape_one(f + 1, remaining - 1, &c, &u);
- if (k < 0) {
- if (flags & UNESCAPE_RELAX) {
- /* Invalid escape code, let's take it literal then */
- *(t++) = '\\';
- continue;
- }
-
- free(r);
- return k;
- }
-
- if (c != 0)
- /* Non-Unicode? Let's encode this directly */
- *(t++) = c;
- else
- /* Unicode? Then let's encode this in UTF-8 */
- t += utf8_encode_unichar(t, u);
-
- f += k;
- }
-
- *t = 0;
-
- *ret = r;
- return t - r;
-}
-
-int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret) {
- return cunescape_length_with_prefix(s, length, NULL, flags, ret);
-}
-
-int cunescape(const char *s, UnescapeFlags flags, char **ret) {
- return cunescape_length(s, strlen(s), flags, ret);
-}
-
-char *xescape(const char *s, const char *bad) {
- char *r, *t;
- const char *f;
-
- /* Escapes all chars in bad, in addition to \ and all special
- * chars, in \xFF style escaping. May be reversed with
- * cunescape(). */
-
- r = new(char, strlen(s) * 4 + 1);
- if (!r)
- return NULL;
-
- for (f = s, t = r; *f; f++) {
-
- if ((*f < ' ') || (*f >= 127) ||
- (*f == '\\') || strchr(bad, *f)) {
- *(t++) = '\\';
- *(t++) = 'x';
- *(t++) = hexchar(*f >> 4);
- *(t++) = hexchar(*f);
- } else
- *(t++) = *f;
- }
-
- *t = 0;
-
- return r;
-}
-
char *ascii_strlower(char *t) {
char *p;
@@ -6242,66 +5848,6 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char
return 0;
}
-static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) {
- assert(bad);
-
- for (; *s; s++) {
- if (*s == '\\' || strchr(bad, *s))
- *(t++) = '\\';
-
- *(t++) = *s;
- }
-
- return t;
-}
-
-char *shell_escape(const char *s, const char *bad) {
- char *r, *t;
-
- r = new(char, strlen(s)*2+1);
- if (!r)
- return NULL;
-
- t = strcpy_backslash_escaped(r, s, bad);
- *t = 0;
-
- return r;
-}
-
-char *shell_maybe_quote(const char *s) {
- const char *p;
- char *r, *t;
-
- assert(s);
-
- /* Encloses a string in double quotes if necessary to make it
- * OK as shell string. */
-
- for (p = s; *p; p++)
- if (*p <= ' ' ||
- *p >= 127 ||
- strchr(SHELL_NEED_QUOTES, *p))
- break;
-
- if (!*p)
- return strdup(s);
-
- r = new(char, 1+strlen(s)*2+1+1);
- if (!r)
- return NULL;
-
- t = r;
- *(t++) = '"';
- t = mempcpy(t, s, p - s);
-
- t = strcpy_backslash_escaped(t, p, SHELL_NEED_ESCAPE);
-
- *(t++)= '"';
- *t = 0;
-
- return r;
-}
-
int parse_mode(const char *s, mode_t *ret) {
char *x;
long l;
diff --git a/src/basic/util.h b/src/basic/util.h
index 132e6f862b..6674111145 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -53,12 +53,6 @@
#define COMMENTS "#;"
#define GLOB_CHARS "*?["
-/* What characters are special in the shell? */
-/* must be escaped outside and inside double-quotes */
-#define SHELL_NEED_ESCAPE "\"\\`$"
-/* can be escaped or double-quoted */
-#define SHELL_NEED_QUOTES SHELL_NEED_ESCAPE GLOB_CHARS "'()<>|&;"
-
#define FORMAT_BYTES_MAX 8
size_t page_size(void) _pure_;
@@ -260,20 +254,6 @@ int unbase32hexchar(char c) _const_;
char base64char(int x) _const_;
int unbase64char(char c) _const_;
-char *cescape(const char *s);
-size_t cescape_char(char c, char *buf);
-
-typedef enum UnescapeFlags {
- UNESCAPE_RELAX = 1,
-} UnescapeFlags;
-
-int cunescape(const char *s, UnescapeFlags flags, char **ret);
-int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret);
-int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret);
-int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode);
-
-char *xescape(const char *s, const char *bad);
-
char *ascii_strlower(char *path);
bool dirent_is_file(const struct dirent *de) _pure_;
@@ -924,9 +904,6 @@ void cmsg_close_all(struct msghdr *mh);
int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
-char *shell_escape(const char *s, const char *bad);
-char *shell_maybe_quote(const char *s);
-
int parse_mode(const char *s, mode_t *ret);
int mount_move_root(const char *path);
diff --git a/src/core/job.c b/src/core/job.c
index 558d8d2d52..13a4e44ec7 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -23,17 +23,20 @@
#include "sd-id128.h"
#include "sd-messages.h"
-#include "set.h"
-#include "unit.h"
-#include "macro.h"
-#include "strv.h"
-#include "log.h"
-#include "dbus-job.h"
-#include "special.h"
+
#include "async.h"
-#include "virt.h"
+#include "dbus-job.h"
#include "dbus.h"
+#include "escape.h"
+#include "log.h"
+#include "macro.h"
+#include "set.h"
+#include "special.h"
+#include "strv.h"
#include "terminal-util.h"
+#include "unit.h"
+#include "virt.h"
+#include "job.h"
Job* job_new_raw(Unit *unit) {
Job *j;
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 0500e2ba33..ae85da25ac 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -42,6 +42,7 @@
#include "cpu-set-util.h"
#include "env-util.h"
#include "errno-list.h"
+#include "escape.h"
#include "ioprio.h"
#include "log.h"
#include "missing.h"
diff --git a/src/core/manager.c b/src/core/manager.c
index 6ae836148d..d1955a9701 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -51,6 +51,7 @@
#include "dbus-unit.h"
#include "dbus.h"
#include "env-util.h"
+#include "escape.h"
#include "exit-status.h"
#include "hashmap.h"
#include "locale-setup.h"
diff --git a/src/core/mount.c b/src/core/mount.c
index 0d1a9b9de7..d6da99ecb9 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -20,26 +20,28 @@
***/
#include <errno.h>
+#include <signal.h>
#include <stdio.h>
#include <sys/epoll.h>
-#include <signal.h>
-#include "manager.h"
-#include "unit.h"
-#include "mount.h"
-#include "log.h"
#include "sd-messages.h"
-#include "strv.h"
-#include "mkdir.h"
-#include "path-util.h"
-#include "mount-setup.h"
-#include "unit-name.h"
+
#include "dbus-mount.h"
-#include "special.h"
+#include "escape.h"
#include "exit-status.h"
-#include "fstab-util.h"
#include "formats-util.h"
+#include "fstab-util.h"
+#include "log.h"
+#include "manager.h"
+#include "mkdir.h"
+#include "mount-setup.h"
+#include "mount.h"
+#include "path-util.h"
#include "smack-util.h"
+#include "special.h"
+#include "strv.h"
+#include "unit-name.h"
+#include "unit.h"
#define RETRY_UMOUNT_MAX 32
diff --git a/src/core/service.c b/src/core/service.c
index c77d4dc796..29be0928d3 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -24,30 +24,31 @@
#include <unistd.h>
#include "async.h"
-#include "manager.h"
-#include "unit.h"
-#include "service.h"
-#include "load-fragment.h"
-#include "load-dropin.h"
-#include "log.h"
-#include "strv.h"
-#include "unit-name.h"
-#include "unit-printf.h"
+#include "bus-error.h"
+#include "bus-kernel.h"
+#include "bus-util.h"
#include "dbus-service.h"
-#include "special.h"
-#include "exit-status.h"
#include "def.h"
-#include "path-util.h"
-#include "util.h"
-#include "utf8.h"
#include "env-util.h"
+#include "escape.h"
+#include "exit-status.h"
#include "fileio.h"
-#include "bus-error.h"
-#include "bus-util.h"
-#include "bus-kernel.h"
#include "formats-util.h"
+#include "load-dropin.h"
+#include "load-fragment.h"
+#include "log.h"
+#include "manager.h"
+#include "path-util.h"
#include "process-util.h"
#include "signal-util.h"
+#include "special.h"
+#include "strv.h"
+#include "unit-name.h"
+#include "unit-printf.h"
+#include "unit.h"
+#include "utf8.h"
+#include "util.h"
+#include "service.h"
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
[SERVICE_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/swap.c b/src/core/swap.c
index f42d151075..82ca58cd7a 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -20,22 +20,23 @@
***/
#include <errno.h>
-#include <unistd.h>
+#include <libudev.h>
#include <sys/epoll.h>
#include <sys/stat.h>
-#include <libudev.h>
+#include <unistd.h>
-#include "unit.h"
-#include "swap.h"
-#include "unit-name.h"
#include "dbus-swap.h"
-#include "special.h"
+#include "escape.h"
#include "exit-status.h"
+#include "formats-util.h"
+#include "fstab-util.h"
#include "path-util.h"
-#include "virt.h"
+#include "special.h"
#include "udev-util.h"
-#include "fstab-util.h"
-#include "formats-util.h"
+#include "unit-name.h"
+#include "unit.h"
+#include "virt.h"
+#include "swap.h"
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
[SWAP_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/umount.c b/src/core/umount.c
index 22dbe67259..38d004ece3 100644
--- a/src/core/umount.c
+++ b/src/core/umount.c
@@ -21,20 +21,21 @@
#include <errno.h>
#include <fcntl.h>
+#include <linux/dm-ioctl.h>
+#include <linux/loop.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/swap.h>
-#include <linux/loop.h>
-#include <linux/dm-ioctl.h>
+#include "escape.h"
+#include "libudev.h"
#include "list.h"
#include "mount-setup.h"
-#include "umount.h"
#include "path-util.h"
+#include "udev-util.h"
#include "util.h"
#include "virt.h"
-#include "libudev.h"
-#include "udev-util.h"
+#include "umount.h"
typedef struct MountPoint {
char *path;
diff --git a/src/core/unit.c b/src/core/unit.c
index e3ab74b8fa..841c1ac018 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -20,36 +20,39 @@
***/
#include <errno.h>
-#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <string.h>
#include <sys/stat.h>
+#include <unistd.h>
#include "sd-id128.h"
#include "sd-messages.h"
-#include "set.h"
-#include "macro.h"
-#include "strv.h"
-#include "path-util.h"
-#include "log.h"
+
+#include "bus-common-errors.h"
+#include "bus-util.h"
#include "cgroup-util.h"
-#include "missing.h"
-#include "mkdir.h"
+#include "dbus-unit.h"
+#include "dbus.h"
+#include "dropin.h"
+#include "escape.h"
+#include "execute.h"
#include "fileio-label.h"
#include "formats-util.h"
+#include "load-dropin.h"
+#include "load-fragment.h"
+#include "log.h"
+#include "macro.h"
+#include "missing.h"
+#include "mkdir.h"
+#include "path-util.h"
#include "process-util.h"
-#include "virt.h"
-#include "bus-common-errors.h"
-#include "bus-util.h"
-#include "dropin.h"
-#include "unit-name.h"
+#include "set.h"
#include "special.h"
+#include "strv.h"
+#include "unit-name.h"
+#include "virt.h"
+
#include "unit.h"
-#include "load-fragment.h"
-#include "load-dropin.h"
-#include "dbus.h"
-#include "dbus-unit.h"
-#include "execute.h"
const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
[UNIT_SERVICE] = &service_vtable,
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index ecc1273eec..4b5f24ff2e 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -23,17 +23,18 @@
#include <errno.h>
#include <sys/mman.h>
#include <mntent.h>
-
#include <libcryptsetup.h>
+#include "sd-device.h"
+
+#include "ask-password-api.h"
+#include "device-util.h"
+#include "escape.h"
#include "fileio.h"
#include "log.h"
-#include "util.h"
#include "path-util.h"
#include "strv.h"
-#include "ask-password-api.h"
-#include "sd-device.h"
-#include "device-util.h"
+#include "util.h"
static const char *arg_type = NULL; /* CRYPT_LUKS1, CRYPT_TCRYPT or CRYPT_PLAIN */
static char *arg_cipher = NULL;
diff --git a/src/import/pull-common.c b/src/import/pull-common.c
index edebb91556..94d4438912 100644
--- a/src/import/pull-common.c
+++ b/src/import/pull-common.c
@@ -21,17 +21,18 @@
#include <sys/prctl.h>
-#include "util.h"
-#include "strv.h"
-#include "copy.h"
-#include "rm-rf.h"
#include "btrfs-util.h"
#include "capability.h"
-#include "pull-job.h"
-#include "pull-common.h"
+#include "copy.h"
+#include "escape.h"
#include "process-util.h"
+#include "pull-job.h"
+#include "rm-rf.h"
#include "signal-util.h"
#include "siphash24.h"
+#include "strv.h"
+#include "util.h"
+#include "pull-common.h"
#define FILENAME_ESCAPE "/.#\"\'"
#define HASH_URL_THRESHOLD_LENGTH (_POSIX_PATH_MAX - 16)
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index c920ef7626..0fcd987664 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -36,14 +36,15 @@
#include "sd-daemon.h"
#include "conf-parser.h"
+#include "escape.h"
#include "fileio.h"
#include "journal-file.h"
+#include "journal-remote-write.h"
#include "journald-native.h"
#include "macro.h"
#include "signal-util.h"
#include "socket-util.h"
#include "strv.h"
-#include "journal-remote-write.h"
#include "journal-remote.h"
#define REMOTE_JOURNAL_PATH "/var/log/journal/remote"
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index e1e66b9826..e20a73c159 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -20,10 +20,10 @@
***/
#include <errno.h>
-#include <unistd.h>
#include <stdio.h>
#include <sys/prctl.h>
#include <sys/xattr.h>
+#include <unistd.h>
#ifdef HAVE_ELFUTILS
# include <dwarf.h>
@@ -32,23 +32,25 @@
#include "sd-journal.h"
#include "sd-login.h"
-#include "log.h"
-#include "util.h"
-#include "fileio.h"
-#include "strv.h"
-#include "macro.h"
-#include "mkdir.h"
-#include "special.h"
+
+#include "acl-util.h"
+#include "capability.h"
#include "cgroup-util.h"
+#include "compress.h"
#include "conf-parser.h"
#include "copy.h"
-#include "stacktrace.h"
-#include "compress.h"
-#include "acl-util.h"
-#include "capability.h"
-#include "journald-native.h"
#include "coredump-vacuum.h"
+#include "escape.h"
+#include "fileio.h"
+#include "journald-native.h"
+#include "log.h"
+#include "macro.h"
+#include "mkdir.h"
#include "process-util.h"
+#include "special.h"
+#include "stacktrace.h"
+#include "strv.h"
+#include "util.h"
/* The maximum size up to which we process coredumps */
#define PROCESS_SIZE_MAX ((uint64_t) (2LLU*1024LLU*1024LLU*1024LLU))
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 51fe3aa50a..9ed368b586 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -19,20 +19,21 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
-#include <sys/epoll.h>
#include <fcntl.h>
+#include <sys/epoll.h>
#include <sys/mman.h>
#include <sys/socket.h>
+#include <unistd.h>
-#include "systemd/sd-messages.h"
-#include <libudev.h>
+#include "libudev.h"
+#include "sd-messages.h"
+#include "escape.h"
+#include "formats-util.h"
#include "journald-server.h"
-#include "journald-kmsg.h"
#include "journald-syslog.h"
-#include "formats-util.h"
#include "process-util.h"
+#include "journald-kmsg.h"
void server_forward_kmsg(
Server *s,
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index cbdaa3b888..0c4b82f80d 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -26,18 +26,20 @@
#include <selinux/selinux.h>
#endif
-#include "sd-event.h"
#include "sd-daemon.h"
-#include "socket-util.h"
-#include "selinux-util.h"
-#include "mkdir.h"
+#include "sd-event.h"
+
+#include "escape.h"
#include "fileio.h"
+#include "journald-console.h"
+#include "journald-kmsg.h"
#include "journald-server.h"
-#include "journald-stream.h"
#include "journald-syslog.h"
-#include "journald-kmsg.h"
-#include "journald-console.h"
#include "journald-wall.h"
+#include "mkdir.h"
+#include "selinux-util.h"
+#include "socket-util.h"
+#include "journald-stream.h"
#define STDOUT_STREAMS_MAX 4096
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index 49c97af339..04c6b1e8ef 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -29,6 +29,7 @@
#include "bus-type.h"
#include "bus-util.h"
#include "busctl-introspect.h"
+#include "escape.h"
#include "log.h"
#include "pager.h"
#include "path-util.h"
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
index 265c7c7db2..db1fae2ebf 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -19,20 +19,21 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
-#include <string.h>
#include <errno.h>
-#include <sys/inotify.h>
#include <poll.h>
+#include <string.h>
+#include <sys/inotify.h>
+#include <unistd.h>
-#include "util.h"
#include "cgroup-util.h"
-#include "macro.h"
-#include "strv.h"
+#include "escape.h"
#include "fileio.h"
-#include "login-util.h"
#include "formats-util.h"
#include "hostname-util.h"
+#include "login-util.h"
+#include "macro.h"
+#include "strv.h"
+#include "util.h"
#include "sd-login.h"
/* Error codes:
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c
index 466225d69c..c325c7bc0c 100644
--- a/src/login/logind-acl.c
+++ b/src/login/logind-acl.c
@@ -22,12 +22,13 @@
#include <errno.h>
#include <string.h>
-#include "util.h"
-#include "formats-util.h"
#include "acl-util.h"
+#include "escape.h"
+#include "formats-util.h"
#include "set.h"
-#include "logind-acl.h"
#include "udev-util.h"
+#include "util.h"
+#include "logind-acl.h"
static int flush_acl(acl_t acl) {
acl_entry_t i;
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index aeedf68e77..66807b3894 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -20,29 +20,31 @@
***/
#include <errno.h>
+#include <pwd.h>
#include <string.h>
#include <unistd.h>
-#include <pwd.h>
#include "sd-messages.h"
-#include "strv.h"
-#include "mkdir.h"
-#include "path-util.h"
-#include "special.h"
-#include "sleep-config.h"
-#include "fileio-label.h"
-#include "unit-name.h"
+
#include "audit.h"
-#include "bus-util.h"
-#include "bus-error.h"
#include "bus-common-errors.h"
-#include "udev-util.h"
-#include "selinux-util.h"
+#include "bus-error.h"
+#include "bus-util.h"
#include "efivars.h"
-#include "logind.h"
+#include "escape.h"
+#include "fileio-label.h"
#include "formats-util.h"
+#include "logind.h"
+#include "mkdir.h"
+#include "path-util.h"
#include "process-util.h"
+#include "selinux-util.h"
+#include "sleep-config.h"
+#include "special.h"
+#include "strv.h"
#include "terminal-util.h"
+#include "udev-util.h"
+#include "unit-name.h"
#include "utmp-wtmp.h"
int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index 0c9c1e5e97..7c7dd3ecb2 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -24,11 +24,12 @@
#include <string.h>
#include <unistd.h>
-#include "util.h"
-#include "mkdir.h"
-#include "logind-inhibit.h"
+#include "escape.h"
#include "fileio.h"
#include "formats-util.h"
+#include "mkdir.h"
+#include "util.h"
+#include "logind-inhibit.h"
Inhibitor* inhibitor_new(Manager *m, const char* id) {
Inhibitor *i;
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index fa82e444ef..e35b5e71a1 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -21,24 +21,26 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/vt.h>
#include <linux/kd.h>
+#include <linux/vt.h>
#include <signal.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "sd-messages.h"
-#include "util.h"
-#include "mkdir.h"
-#include "path-util.h"
-#include "fileio.h"
+
#include "audit.h"
-#include "bus-util.h"
#include "bus-error.h"
-#include "logind-session.h"
+#include "bus-util.h"
+#include "escape.h"
+#include "fileio.h"
#include "formats-util.h"
+#include "mkdir.h"
+#include "path-util.h"
#include "terminal-util.h"
+#include "util.h"
+#include "logind-session.h"
#define RELEASE_USEC (20*USEC_PER_SEC)
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 451954e860..ecfbf2c5cc 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -19,26 +19,27 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/mount.h>
+#include <errno.h>
#include <string.h>
+#include <sys/mount.h>
#include <unistd.h>
-#include <errno.h>
-#include "util.h"
-#include "mkdir.h"
-#include "rm-rf.h"
-#include "hashmap.h"
-#include "fileio.h"
-#include "path-util.h"
-#include "special.h"
-#include "unit-name.h"
-#include "bus-util.h"
#include "bus-error.h"
-#include "conf-parser.h"
+#include "bus-util.h"
#include "clean-ipc.h"
-#include "smack-util.h"
+#include "conf-parser.h"
+#include "escape.h"
+#include "fileio.h"
#include "formats-util.h"
+#include "hashmap.h"
#include "label.h"
+#include "mkdir.h"
+#include "path-util.h"
+#include "rm-rf.h"
+#include "smack-util.h"
+#include "special.h"
+#include "unit-name.h"
+#include "util.h"
#include "logind-user.h"
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) {
diff --git a/src/machine/machine.c b/src/machine/machine.c
index 7ab84607fb..e27d0af169 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -27,15 +27,16 @@
#include "bus-error.h"
#include "bus-util.h"
+#include "escape.h"
#include "fileio.h"
#include "formats-util.h"
#include "hashmap.h"
+#include "machine-dbus.h"
#include "mkdir.h"
#include "special.h"
#include "terminal-util.h"
#include "unit-name.h"
#include "util.h"
-#include "machine-dbus.h"
#include "machine.h"
Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index 65bcb68242..02de2541c4 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -19,17 +19,18 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/mount.h>
#include <linux/magic.h>
+#include <sys/mount.h>
-#include "util.h"
-#include "rm-rf.h"
-#include "strv.h"
-#include "path-util.h"
-#include "mkdir.h"
+#include "cgroup-util.h"
+#include "escape.h"
#include "label.h"
+#include "mkdir.h"
+#include "path-util.h"
+#include "rm-rf.h"
#include "set.h"
-#include "cgroup-util.h"
+#include "strv.h"
+#include "util.h"
#include "nspawn-mount.h"
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index 72c9eb4446..d66f71772e 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -25,6 +25,7 @@
#include "libudev.h"
#include "sd-daemon.h"
+#include "escape.h"
#include "fileio.h"
#include "mkdir.h"
#include "udev-util.h"
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 9c4d6a2da0..13af8bfcce 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -21,9 +21,9 @@
#include <sys/socket.h>
+#include "sd-bus.h"
#include "sd-daemon.h"
#include "sd-event.h"
-#include "sd-bus.h"
#include "bus-error.h"
#include "bus-internal.h"
@@ -32,6 +32,7 @@
#include "cgroup-util.h"
#include "def.h"
#include "env-util.h"
+#include "escape.h"
#include "macro.h"
#include "missing.h"
#include "path-util.h"
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
index 1845068adb..5e0436a55d 100644
--- a/src/shared/dropin.c
+++ b/src/shared/dropin.c
@@ -19,12 +19,13 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "dropin.h"
-#include "util.h"
-#include "strv.h"
-#include "mkdir.h"
-#include "fileio-label.h"
#include "conf-files.h"
+#include "escape.h"
+#include "fileio-label.h"
+#include "mkdir.h"
+#include "strv.h"
+#include "util.h"
+#include "dropin.h"
int drop_in_file(const char *dir, const char *unit, unsigned level,
const char *name, char **_p, char **_q) {
diff --git a/src/shared/generator.c b/src/shared/generator.c
index d912bcd9e1..264a54fb94 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -21,15 +21,16 @@
#include <unistd.h>
-#include "util.h"
-#include "special.h"
+#include "dropin.h"
+#include "escape.h"
+#include "fileio.h"
+#include "fstab-util.h"
#include "mkdir.h"
+#include "path-util.h"
+#include "special.h"
#include "unit-name.h"
+#include "util.h"
#include "generator.h"
-#include "path-util.h"
-#include "fstab-util.h"
-#include "fileio.h"
-#include "dropin.h"
static int write_fsck_sysroot_service(const char *dir, const char *what) {
_cleanup_free_ char *device = NULL, *escaped = NULL;
diff --git a/src/test/test-util.c b/src/test/test-util.c
index b5d9d01ba0..10bbb17b14 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -34,6 +34,7 @@
#include "conf-parser.h"
#include "cpu-set-util.h"
#include "def.h"
+#include "escape.h"
#include "fileio.h"
#include "mkdir.h"
#include "process-util.h"
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 1786e36674..ba9f82553b 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -43,6 +43,7 @@
#include "capability.h"
#include "conf-files.h"
#include "copy.h"
+#include "escape.h"
#include "formats-util.h"
#include "label.h"
#include "log.h"
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 10bf3880b0..62db0016eb 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -15,27 +15,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stddef.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
#include <ctype.h>
-#include <unistd.h>
-#include <errno.h>
#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
#include <fnmatch.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <time.h>
+#include <unistd.h>
-#include "udev.h"
-#include "path-util.h"
#include "conf-files.h"
+#include "escape.h"
+#include "path-util.h"
#include "strbuf.h"
#include "strv.h"
-#include "util.h"
#include "sysctl-util.h"
+#include "util.h"
+#include "udev.h"
#define PREALLOC_TOKEN 2048
@@ -51,7 +52,8 @@ static const char* const rules_dirs[] = {
"/etc/udev/rules.d",
"/run/udev/rules.d",
UDEVLIBEXECDIR "/rules.d",
- NULL};
+ NULL
+};
struct udev_rules {
struct udev *udev;