summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am97
-rw-r--r--README4
-rw-r--r--man/journalctl.xml8
-rw-r--r--man/sd_notify.xml2
-rw-r--r--man/systemd.exec.xml2
-rw-r--r--shell-completion/bash/systemd-run2
-rw-r--r--shell-completion/zsh/_systemd-run2
-rw-r--r--src/backlight/backlight.c2
-rw-r--r--src/basic/def.h3
-rw-r--r--src/basic/parse-util.c13
-rw-r--r--src/basic/parse-util.h1
-rw-r--r--src/basic/proc-cmdline.c31
-rw-r--r--src/basic/proc-cmdline.h1
-rw-r--r--src/basic/string-util.c31
-rw-r--r--src/basic/string-util.h4
-rw-r--r--src/core/dbus-execute.c35
-rw-r--r--src/core/dbus-service.c3
-rw-r--r--src/core/main.c91
-rw-r--r--src/debug-generator/debug-generator.c28
-rwxr-xr-xsrc/journal-remote/log-generator.py10
-rw-r--r--src/journal/journal-file.c2
-rw-r--r--src/journal/journal-internal.h2
-rw-r--r--src/journal/journalctl.c32
-rw-r--r--src/journal/sd-journal.c296
-rw-r--r--src/libsystemd/sd-device/sd-device.c9
-rw-r--r--src/libsystemd/sd-login/sd-login.c4
-rw-r--r--src/machine/machine.c10
-rw-r--r--src/network/networkctl.c2
-rw-r--r--src/network/networkd-link-bus.c2
-rw-r--r--src/resolve-host/resolve-host.c5
-rw-r--r--src/rfkill/rfkill.c2
-rw-r--r--src/shared/bus-util.c36
-rw-r--r--src/systemctl/systemctl.c54
-rw-r--r--src/sysv-generator/sysv-generator.c2
-rw-r--r--src/test/test-execute.c51
-rw-r--r--src/test/test-path.c2
-rw-r--r--src/test/test-string-util.c61
-rw-r--r--src/test/test-util.c8
-rw-r--r--sysctl.d/50-default.conf3
l---------test/paths.target1
-rw-r--r--test/test-execute/exec-capabilityboundingset-invert.service (renamed from test/exec-capabilityboundingset-invert.service)0
-rw-r--r--test/test-execute/exec-capabilityboundingset-merge.service (renamed from test/exec-capabilityboundingset-merge.service)0
-rw-r--r--test/test-execute/exec-capabilityboundingset-reset.service (renamed from test/exec-capabilityboundingset-reset.service)0
-rw-r--r--test/test-execute/exec-capabilityboundingset-simple.service (renamed from test/exec-capabilityboundingset-simple.service)0
-rw-r--r--test/test-execute/exec-environment-empty.service (renamed from test/exec-environment-empty.service)0
-rw-r--r--test/test-execute/exec-environment-multiple.service (renamed from test/exec-environment-multiple.service)0
-rw-r--r--test/test-execute/exec-environment.service (renamed from test/exec-environment.service)0
-rw-r--r--test/test-execute/exec-environmentfile.service7
-rw-r--r--test/test-execute/exec-group.service (renamed from test/exec-group.service)0
-rw-r--r--test/test-execute/exec-ignoresigpipe-no.service (renamed from test/exec-ignoresigpipe-no.service)0
-rw-r--r--test/test-execute/exec-ignoresigpipe-yes.service (renamed from test/exec-ignoresigpipe-yes.service)0
-rw-r--r--test/test-execute/exec-ioschedulingclass-best-effort.service7
-rw-r--r--test/test-execute/exec-ioschedulingclass-idle.service7
-rw-r--r--test/test-execute/exec-ioschedulingclass-none.service7
-rw-r--r--test/test-execute/exec-ioschedulingclass-realtime.service7
-rw-r--r--test/test-execute/exec-oomscoreadjust-negative.service7
-rw-r--r--test/test-execute/exec-oomscoreadjust-positive.service7
-rw-r--r--test/test-execute/exec-personality-s390.service (renamed from test/exec-personality-s390.service)0
-rw-r--r--test/test-execute/exec-personality-x86-64.service (renamed from test/exec-personality-x86-64.service)0
-rw-r--r--test/test-execute/exec-personality-x86.service (renamed from test/exec-personality-x86.service)0
-rw-r--r--test/test-execute/exec-privatedevices-no.service (renamed from test/exec-privatedevices-no.service)0
-rw-r--r--test/test-execute/exec-privatedevices-yes.service (renamed from test/exec-privatedevices-yes.service)0
-rw-r--r--test/test-execute/exec-privatenetwork-yes.service6
-rw-r--r--test/test-execute/exec-privatetmp-no.service (renamed from test/exec-privatetmp-no.service)0
-rw-r--r--test/test-execute/exec-privatetmp-yes.service (renamed from test/exec-privatetmp-yes.service)0
-rw-r--r--test/test-execute/exec-runtimedirectory-mode.service (renamed from test/exec-runtimedirectory-mode.service)0
-rw-r--r--test/test-execute/exec-runtimedirectory-owner.service (renamed from test/exec-runtimedirectory-owner.service)0
-rw-r--r--test/test-execute/exec-runtimedirectory.service (renamed from test/exec-runtimedirectory.service)0
-rw-r--r--test/test-execute/exec-systemcallerrornumber.service (renamed from test/exec-systemcallerrornumber.service)0
-rw-r--r--test/test-execute/exec-systemcallfilter-failing.service (renamed from test/exec-systemcallfilter-failing.service)0
-rw-r--r--test/test-execute/exec-systemcallfilter-failing2.service (renamed from test/exec-systemcallfilter-failing2.service)0
-rw-r--r--test/test-execute/exec-systemcallfilter-not-failing.service (renamed from test/exec-systemcallfilter-not-failing.service)0
-rw-r--r--test/test-execute/exec-systemcallfilter-not-failing2.service (renamed from test/exec-systemcallfilter-not-failing2.service)0
-rw-r--r--test/test-execute/exec-umask-0177.service (renamed from test/exec-umask-0177.service)0
-rw-r--r--test/test-execute/exec-umask-default.service (renamed from test/exec-umask-default.service)0
-rw-r--r--test/test-execute/exec-user.service (renamed from test/exec-user.service)0
-rw-r--r--test/test-execute/exec-workingdirectory.service (renamed from test/exec-workingdirectory.service)0
l---------test/test-path/basic.target1
-rw-r--r--test/test-path/path-changed.path (renamed from test/path-changed.path)0
l---------test/test-path/path-changed.service (renamed from test/path-changed.service)0
-rw-r--r--test/test-path/path-directorynotempty.path (renamed from test/path-directorynotempty.path)0
l---------test/test-path/path-directorynotempty.service (renamed from test/path-directorynotempty.service)0
-rw-r--r--test/test-path/path-exists.path (renamed from test/path-exists.path)0
l---------test/test-path/path-exists.service (renamed from test/path-exists.service)0
-rw-r--r--test/test-path/path-existsglob.path (renamed from test/path-existsglob.path)0
l---------test/test-path/path-existsglob.service (renamed from test/path-existsglob.service)0
-rw-r--r--test/test-path/path-makedirectory.path (renamed from test/path-makedirectory.path)0
l---------test/test-path/path-makedirectory.service (renamed from test/path-makedirectory.service)0
-rw-r--r--test/test-path/path-modified.path (renamed from test/path-modified.path)0
l---------test/test-path/path-modified.service (renamed from test/path-modified.service)0
-rw-r--r--test/test-path/path-mycustomunit.service (renamed from test/path-mycustomunit.service)0
-rw-r--r--test/test-path/path-service.service (renamed from test/path-service.service)0
-rw-r--r--test/test-path/path-unit.path (renamed from test/path-unit.path)0
l---------test/test-path/paths.target1
l---------test/test-path/sysinit.target1
96 files changed, 695 insertions, 318 deletions
diff --git a/.gitignore b/.gitignore
index 7abe8e7dae..1c006b53f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -256,6 +256,7 @@
/test-socket-util
/test-ssd
/test-strbuf
+/test-string-util
/test-strip-tab-ansi
/test-strv
/test-strxcpyx
diff --git a/Makefile.am b/Makefile.am
index 00b9e86346..a601265d78 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1447,6 +1447,7 @@ tests += \
test-utf8 \
test-ellipsize \
test-util \
+ test-string-util \
test-extract-word \
test-parse-util \
test-user-util \
@@ -1515,7 +1516,6 @@ EXTRA_DIST += \
test/h.service \
test/parent-deep.slice \
test/parent.slice \
- test/paths.target \
test/sched_idle_bad.service \
test/sched_idle_ok.service \
test/sched_rr_bad.service \
@@ -1529,43 +1529,58 @@ EXTRA_DIST += \
test/testsuite.target \
test/timers.target \
test/unstoppable.service \
- test/path-changed.service \
- test/path-directorynotempty.service \
- test/path-existsglob.service \
- test/path-exists.service \
- test/path-makedirectory.service \
- test/path-modified.service \
- test/path-mycustomunit.service \
- test/path-service.service \
- test/path-changed.path \
- test/path-directorynotempty.path \
- test/path-existsglob.path \
- test/path-exists.path \
- test/path-makedirectory.path \
- test/path-modified.path \
- test/path-unit.path \
- test/exec-environment-empty.service \
- test/exec-environment-multiple.service \
- test/exec-environment.service \
- test/exec-group.service \
- test/exec-ignoresigpipe-no.service \
- test/exec-ignoresigpipe-yes.service \
- test/exec-personality-x86-64.service \
- test/exec-personality-x86.service \
- test/exec-personality-s390.service \
- test/exec-privatedevices-no.service \
- test/exec-privatedevices-yes.service \
- test/exec-privatetmp-no.service \
- test/exec-privatetmp-yes.service \
- test/exec-systemcallerrornumber.service \
- test/exec-systemcallfilter-failing2.service \
- test/exec-systemcallfilter-failing.service \
- test/exec-systemcallfilter-not-failing2.service \
- test/exec-systemcallfilter-not-failing.service \
- test/exec-user.service \
- test/exec-workingdirectory.service \
- test/exec-umask-0177.service \
- test/exec-umask-default.service \
+ test/test-path/paths.target \
+ test/test-path/basic.target \
+ test/test-path/sysinit.target \
+ test/test-path/path-changed.service \
+ test/test-path/path-directorynotempty.service \
+ test/test-path/path-existsglob.service \
+ test/test-path/path-exists.service \
+ test/test-path/path-makedirectory.service \
+ test/test-path/path-modified.service \
+ test/test-path/path-mycustomunit.service \
+ test/test-path/path-service.service \
+ test/test-path/path-changed.path \
+ test/test-path/path-directorynotempty.path \
+ test/test-path/path-existsglob.path \
+ test/test-path/path-exists.path \
+ test/test-path/path-makedirectory.path \
+ test/test-path/path-modified.path \
+ test/test-path/path-unit.path \
+ test/test-execute/exec-environment-empty.service \
+ test/test-execute/exec-environment-multiple.service \
+ test/test-execute/exec-environment.service \
+ test/test-execute/exec-group.service \
+ test/test-execute/exec-ignoresigpipe-no.service \
+ test/test-execute/exec-ignoresigpipe-yes.service \
+ test/test-execute/exec-personality-x86-64.service \
+ test/test-execute/exec-personality-x86.service \
+ test/test-execute/exec-personality-s390.service \
+ test/test-execute/exec-privatedevices-no.service \
+ test/test-execute/exec-privatedevices-yes.service \
+ test/test-execute/exec-privatetmp-no.service \
+ test/test-execute/exec-privatetmp-yes.service \
+ test/test-execute/exec-systemcallerrornumber.service \
+ test/test-execute/exec-systemcallfilter-failing2.service \
+ test/test-execute/exec-systemcallfilter-failing.service \
+ test/test-execute/exec-systemcallfilter-not-failing2.service \
+ test/test-execute/exec-systemcallfilter-not-failing.service \
+ test/test-execute/exec-user.service \
+ test/test-execute/exec-workingdirectory.service \
+ test/test-execute/exec-umask-0177.service \
+ test/test-execute/exec-umask-default.service \
+ test/test-execute/exec-privatenetwork-yes.service \
+ test/test-execute/exec-environmentfile.service \
+ test/test-execute/exec-oomscoreadjust-positive.service \
+ test/test-execute/exec-oomscoreadjust-negative.service \
+ test/test-execute/exec-ioschedulingclass-best-effort.service \
+ test/test-execute/exec-ioschedulingclass-idle.service \
+ test/test-execute/exec-ioschedulingclass-none.service \
+ test/test-execute/exec-ioschedulingclass-realtime.service \
+ test/test-execute/exec-capabilityboundingset-invert.service \
+ test/test-execute/exec-capabilityboundingset-merge.service \
+ test/test-execute/exec-capabilityboundingset-reset.service \
+ test/test-execute/exec-capabilityboundingset-simple.service \
test/bus-policy/hello.conf \
test/bus-policy/methods.conf \
test/bus-policy/ownerships.conf \
@@ -1734,6 +1749,12 @@ test_util_SOURCES = \
test_util_LDADD = \
libshared.la
+test_string_util_SOURCES = \
+ src/test/test-string-util.c
+
+test_string_util_LDADD = \
+ libshared.la
+
test_extract_word_SOURCES = \
src/test/test-extract-word.c
diff --git a/README b/README
index f6fb966b26..bc7068a66d 100644
--- a/README
+++ b/README
@@ -122,7 +122,7 @@ REQUIREMENTS:
glibc >= 2.16
libcap
- libmount >= 2.27 (from util-linux)
+ libmount >= 2.27.1 (from util-linux)
libseccomp >= 1.0.0 (optional)
libblkid >= 2.24 (from util-linux) (optional)
libkmod >= 15 (optional)
@@ -144,7 +144,7 @@ REQUIREMENTS:
During runtime, you need the following additional
dependencies:
- util-linux >= v2.27 required
+ util-linux >= v2.27.1 required
dbus >= 1.4.0 (strictly speaking optional, but recommended)
dracut (optional)
PolicyKit (optional)
diff --git a/man/journalctl.xml b/man/journalctl.xml
index 9784b9f2a8..ea319ba373 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -395,7 +395,7 @@
<para>If the boot ID is omitted, a positive
<replaceable>offset</replaceable> will look up the boots
- starting from the beginning of the journal, and a
+ starting from the beginning of the journal, and an
equal-or-less-than zero <replaceable>offset</replaceable> will
look up boots starting from the end of the journal. Thus,
<constant>1</constant> means the first boot found in the
@@ -413,7 +413,7 @@
<replaceable>offset</replaceable> which identifies the boot
relative to the one given by boot
<replaceable>ID</replaceable>. Negative values mean earlier
- boots and a positive values mean later boots. If
+ boots and positive values mean later boots. If
<replaceable>offset</replaceable> is not specified, a value of
zero is assumed, and the logs for the boot given by
<replaceable>ID</replaceable> are shown.</para>
@@ -520,7 +520,7 @@
<listitem><para>Start showing entries from the location in the
journal <emphasis>after</emphasis> the location specified by
- the this cursor. The cursor is shown when the
+ the passed cursor. The cursor is shown when the
<option>--show-cursor</option> option is used.</para>
</listitem>
</varlistentry>
@@ -666,7 +666,7 @@
remain. Note that running <option>--vacuum-size=</option> has
only indirect effect on the output shown by
<option>--disk-usage</option> as the latter includes active
- journal files, while the the vacuuming operation only operates
+ journal files, while the vacuuming operation only operates
on archived journal files. Similar,
<option>--vacuum-files=</option> might not actually reduce the
number of journal files to below the specified number, as it
diff --git a/man/sd_notify.xml b/man/sd_notify.xml
index 2d73c27f62..b7ee4286f0 100644
--- a/man/sd_notify.xml
+++ b/man/sd_notify.xml
@@ -311,7 +311,7 @@
<xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
- <para>Internally, these functions send a single datagram with the
+ <para>These functions send a single datagram with the
state string as payload to the <constant>AF_UNIX</constant> socket
referenced in the <varname>$NOTIFY_SOCKET</varname> environment
variable. If the first character of
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index 5f99fa875e..c0ecf92419 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -994,7 +994,7 @@
<listitem><para>Takes a <option>SMACK64</option> security
label as argument. The process executed by the unit will be
started under this label and SMACK will decide whether the
- processes is allowed to run or not based on it. The process
+ process is allowed to run or not based on it. The process
will continue to run under the label specified here unless the
executable has its own <option>SMACK64EXEC</option> label, in
which case the process will transition to run under that
diff --git a/shell-completion/bash/systemd-run b/shell-completion/bash/systemd-run
index dfcb01231f..7379431b71 100644
--- a/shell-completion/bash/systemd-run
+++ b/shell-completion/bash/systemd-run
@@ -86,7 +86,7 @@ _systemd_run() {
TTYPath= SyslogIdentifier= SyslogLevelPrefix= SyslogLevel=
SyslogFacility= TimerSlackNSec= OOMScoreAdjust= ReadWriteDirectories=
ReadOnlyDirectories= InaccessibleDirectories= EnvironmentFile=
- ProtectSystem= ProtectHome='
+ ProtectSystem= ProtectHome= RuntimeDirectory='
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run
index d4fa39341c..8bb0156a85 100644
--- a/shell-completion/zsh/_systemd-run
+++ b/shell-completion/zsh/_systemd-run
@@ -39,7 +39,7 @@ _arguments \
TTYPath= SyslogIdentifier= SyslogLevelPrefix= SyslogLevel= \
SyslogFacility= TimerSlackNSec= OOMScoreAdjust= ReadWriteDirectories= \
ReadOnlyDirectories= InaccessibleDirectories= EnvironmentFile= \
- ProtectSystem= ProtectHome= \
+ ProtectSystem= ProtectHome= RuntimeDirectory= \
))' \
'--description=[Description for unit]:description' \
'--slice=[Run in the specified slice]:slices:__slices' \
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 08980fba82..b0fa079fec 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -381,7 +381,7 @@ int main(int argc, char *argv[]) {
_cleanup_free_ char *value = NULL;
const char *clamp;
- if (!shall_restore_state())
+ if (shall_restore_state() == 0)
return EXIT_SUCCESS;
if (!validate_device(udev, device))
diff --git a/src/basic/def.h b/src/basic/def.h
index 7c4161eb72..cbef137410 100644
--- a/src/basic/def.h
+++ b/src/basic/def.h
@@ -35,6 +35,9 @@
* the watchdog pings will keep the loop busy. */
#define DEFAULT_EXIT_USEC (30*USEC_PER_SEC)
+/* The default value for the net.unix.max_dgram_qlen sysctl */
+#define DEFAULT_UNIX_MAX_DGRAM_QLEN 512UL
+
#define SYSTEMD_CGROUP_CONTROLLER "name=systemd"
#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
index 1ee5783680..b6358c459a 100644
--- a/src/basic/parse-util.c
+++ b/src/basic/parse-util.c
@@ -81,6 +81,19 @@ int parse_mode(const char *s, mode_t *ret) {
return 0;
}
+int parse_ifindex(const char *s, int *ret) {
+ int ifi, r;
+
+ r = safe_atoi(s, &ifi);
+ if (r < 0)
+ return r;
+ if (ifi <= 0)
+ return -EINVAL;
+
+ *ret = ifi;
+ return 0;
+}
+
int parse_size(const char *t, uint64_t base, uint64_t *size) {
/* Soo, sometimes we want to parse IEC binary suffixes, and
diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h
index 0e56848e26..408690d0b3 100644
--- a/src/basic/parse-util.h
+++ b/src/basic/parse-util.h
@@ -31,6 +31,7 @@
int parse_boolean(const char *v) _pure_;
int parse_pid(const char *s, pid_t* ret_pid);
int parse_mode(const char *s, mode_t *ret);
+int parse_ifindex(const char *s, int *ret);
int parse_size(const char *t, uint64_t base, uint64_t *size);
int parse_range(const char *t, unsigned *lower, unsigned *upper);
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c
index dd91ce7dbc..4464573c5b 100644
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -26,6 +26,7 @@
#include "parse-util.h"
#include "proc-cmdline.h"
#include "process-util.h"
+#include "special.h"
#include "string-util.h"
#include "util.h"
#include "virt.h"
@@ -141,5 +142,33 @@ int shall_restore_state(void) {
if (r == 0)
return true;
- return parse_boolean(value) != 0;
+ return parse_boolean(value);
+}
+
+static const char * const rlmap[] = {
+ "emergency", SPECIAL_EMERGENCY_TARGET,
+ "-b", SPECIAL_EMERGENCY_TARGET,
+ "rescue", SPECIAL_RESCUE_TARGET,
+ "single", SPECIAL_RESCUE_TARGET,
+ "-s", SPECIAL_RESCUE_TARGET,
+ "s", SPECIAL_RESCUE_TARGET,
+ "S", SPECIAL_RESCUE_TARGET,
+ "1", SPECIAL_RESCUE_TARGET,
+ "2", SPECIAL_MULTI_USER_TARGET,
+ "3", SPECIAL_MULTI_USER_TARGET,
+ "4", SPECIAL_MULTI_USER_TARGET,
+ "5", SPECIAL_GRAPHICAL_TARGET,
+};
+
+const char* runlevel_to_target(const char *word) {
+ size_t i;
+
+ if (!word)
+ return NULL;
+
+ for (i = 0; i < ELEMENTSOF(rlmap); i += 2)
+ if (streq(word, rlmap[i]))
+ return rlmap[i+1];
+
+ return NULL;
}
diff --git a/src/basic/proc-cmdline.h b/src/basic/proc-cmdline.h
index ea8277b053..ce6e84995a 100644
--- a/src/basic/proc-cmdline.h
+++ b/src/basic/proc-cmdline.h
@@ -26,3 +26,4 @@ int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value));
int get_proc_cmdline_key(const char *parameter, char **value);
int shall_restore_state(void);
+const char* runlevel_to_target(const char *rl);
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 63b9b79df9..c3be576816 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -748,23 +748,38 @@ int free_and_strdup(char **p, const char *s) {
return 1;
}
-void string_erase(char *x) {
+#pragma GCC push_options
+#pragma GCC optimize("O0")
+
+void* memory_erase(void *p, size_t l) {
+ volatile uint8_t* x = (volatile uint8_t*) p;
+
+ /* This basically does what memset() does, but hopefully isn't
+ * optimized away by the compiler. One of those days, when
+ * glibc learns memset_s() we should replace this call by
+ * memset_s(), but until then this has to do. */
+
+ for (; l > 0; l--)
+ *(x++) = 'x';
+
+ return p;
+}
+
+#pragma GCC pop_options
+
+char* string_erase(char *x) {
if (!x)
- return;
+ return NULL;
/* A delicious drop of snake-oil! To be called on memory where
* we stored passphrases or so, after we used them. */
- memory_erase(x, strlen(x));
+ return memory_erase(x, strlen(x));
}
char *string_free_erase(char *s) {
- if (!s)
- return NULL;
-
- string_erase(s);
- return mfree(s);
+ return mfree(string_erase(s));
}
bool string_is_safe(const char *p) {
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index 297b8f8232..15244b8184 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -162,8 +162,8 @@ static inline void *memmem_safe(const void *haystack, size_t haystacklen, const
return memmem(haystack, haystacklen, needle, needlelen);
}
-#define memory_erase(p, l) memset((p), 'x', (l))
-void string_erase(char *x);
+void* memory_erase(void *p, size_t l);
+char *string_erase(char *x);
char *string_free_erase(char *s);
DEFINE_TRIVIAL_CLEANUP_FUNC(char *, string_free_erase);
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 04a5a22b72..db4206a523 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -1391,6 +1391,41 @@ int bus_exec_context_set_transient_property(
return 1;
+ } else if (streq(name, "RuntimeDirectory")) {
+ _cleanup_strv_free_ char **l = NULL;
+ char **p;
+
+ r = sd_bus_message_read_strv(message, &l);
+ if (r < 0)
+ return r;
+
+ STRV_FOREACH(p, l) {
+ if (!filename_is_valid(*p))
+ return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Runtime directory is not valid %s", *p);
+ }
+
+ if (mode != UNIT_CHECK) {
+ _cleanup_free_ char *joined = NULL;
+
+ if (strv_isempty(l)) {
+ c->runtime_directory = strv_free(c->runtime_directory);
+ unit_write_drop_in_private_format(u, mode, name, "%s=\n", name);
+ } else {
+ r = strv_extend_strv(&c->runtime_directory, l, true);
+
+ if (r < 0)
+ return -ENOMEM;
+
+ joined = strv_join_quoted(c->runtime_directory);
+ if (!joined)
+ return -ENOMEM;
+
+ unit_write_drop_in_private_format(u, mode, name, "%s=%s\n", name, joined);
+ }
+ }
+
+ return 1;
+
} else if (rlimit_from_string(name) >= 0) {
uint64_t rl;
rlim_t x;
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index c41b3e1723..24f611a593 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -63,7 +63,8 @@ const sd_bus_vtable bus_service_vtable[] = {
SD_BUS_PROPERTY("MainPID", "u", bus_property_get_pid, offsetof(Service, main_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Service, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("BusName", "s", NULL, offsetof(Service, bus_name), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("FileDescriptorStoreMax", "u", NULL, offsetof(Service, n_fd_store_max), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("FileDescriptorStoreMax", "u", bus_property_get_unsigned, offsetof(Service, n_fd_store_max), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("NFileDescriptorStore", "u", bus_property_get_unsigned, offsetof(Service, n_fd_store), 0),
SD_BUS_PROPERTY("StatusText", "s", NULL, offsetof(Service, status_text), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("StatusErrno", "i", NULL, offsetof(Service, status_errno), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Service, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
diff --git a/src/core/main.c b/src/core/main.c
index 593b974566..ea4fd0589d 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -301,20 +301,6 @@ static int parse_crash_chvt(const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value) {
- static const char * const rlmap[] = {
- "emergency", SPECIAL_EMERGENCY_TARGET,
- "-b", SPECIAL_EMERGENCY_TARGET,
- "rescue", SPECIAL_RESCUE_TARGET,
- "single", SPECIAL_RESCUE_TARGET,
- "-s", SPECIAL_RESCUE_TARGET,
- "s", SPECIAL_RESCUE_TARGET,
- "S", SPECIAL_RESCUE_TARGET,
- "1", SPECIAL_RESCUE_TARGET,
- "2", SPECIAL_MULTI_USER_TARGET,
- "3", SPECIAL_MULTI_USER_TARGET,
- "4", SPECIAL_MULTI_USER_TARGET,
- "5", SPECIAL_GRAPHICAL_TARGET,
- };
int r;
assert(key);
@@ -415,12 +401,12 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
log_set_target(LOG_TARGET_CONSOLE);
} else if (!in_initrd() && !value) {
- unsigned i;
+ const char *target;
/* SysV compatibility */
- for (i = 0; i < ELEMENTSOF(rlmap); i += 2)
- if (streq(key, rlmap[i]))
- return free_and_strdup(&arg_default_unit, rlmap[i+1]);
+ target = runlevel_to_target(key);
+ if (target)
+ return free_and_strdup(&arg_default_unit, target);
}
return 0;
@@ -1113,33 +1099,6 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) {
return 0;
}
-static void test_mtab(void) {
-
- static const char ok[] =
- "/proc/self/mounts\0"
- "/proc/mounts\0"
- "../proc/self/mounts\0"
- "../proc/mounts\0";
-
- _cleanup_free_ char *p = NULL;
- int r;
-
- /* Check that /etc/mtab is a symlink to the right place or
- * non-existing. But certainly not a file, or a symlink to
- * some weird place... */
-
- r = readlink_malloc("/etc/mtab", &p);
- if (r == -ENOENT)
- return;
- if (r >= 0 && nulstr_contains(ok, p))
- return;
-
- log_error("/etc/mtab is not a symlink or not pointing to /proc/self/mounts. "
- "This is not supported anymore. "
- "Please replace /etc/mtab with a symlink to /proc/self/mounts.");
- freeze_or_reboot();
-}
-
static void test_usr(void) {
/* Check that /usr is not a separate fs */
@@ -1242,12 +1201,50 @@ static int status_welcome(void) {
static int write_container_id(void) {
const char *c;
+ int r;
c = getenv("container");
if (isempty(c))
return 0;
- return write_string_file("/run/systemd/container", c, WRITE_STRING_FILE_CREATE);
+ r = write_string_file("/run/systemd/container", c, WRITE_STRING_FILE_CREATE);
+ if (r < 0)
+ return log_warning_errno(r, "Failed to write /run/systed/container, ignoring: %m");
+
+ return 1;
+}
+
+static int bump_unix_max_dgram_qlen(void) {
+ _cleanup_free_ char *qlen = NULL;
+ unsigned long v;
+ int r;
+
+ /* Let's bump the net.unix.max_dgram_qlen sysctl. The kernel
+ * default of 16 is simply too low. We set the value really
+ * really early during boot, so that it is actually applied to
+ * all our sockets, including the $NOTIFY_SOCKET one. */
+
+ r = read_one_line_file("/proc/sys/net/unix/max_dgram_qlen", &qlen);
+ if (r < 0)
+ return log_warning_errno(r, "Failed to read AF_UNIX datagram queue length, ignoring: %m");
+
+ r = safe_atolu(qlen, &v);
+ if (r < 0)
+ return log_warning_errno(r, "Failed to parse AF_UNIX datagram queue length, ignoring: %m");
+
+ if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN)
+ return 0;
+
+ qlen = mfree(qlen);
+ if (asprintf(&qlen, "%lu\n", DEFAULT_UNIX_MAX_DGRAM_QLEN) < 0)
+ return log_oom();
+
+ r = write_string_file("/proc/sys/net/unix/max_dgram_qlen", qlen, 0);
+ if (r < 0)
+ return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
+ "Failed to bump AF_UNIX datagram queue length, ignoring: %m");
+
+ return 1;
}
int main(int argc, char *argv[]) {
@@ -1613,8 +1610,8 @@ int main(int argc, char *argv[]) {
hostname_setup();
machine_id_setup(NULL);
loopback_setup();
+ bump_unix_max_dgram_qlen();
- test_mtab();
test_usr();
}
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index e16c3b9453..413cfd0388 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -23,11 +23,13 @@
#include "mkdir.h"
#include "parse-util.h"
#include "proc-cmdline.h"
+#include "special.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "util.h"
+static char *arg_default_unit = NULL;
static const char *arg_dest = "/tmp";
static char **arg_mask = NULL;
static char **arg_wants = NULL;
@@ -80,6 +82,24 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
arg_debug_shell = r;
} else
arg_debug_shell = true;
+ } else if (streq(key, "systemd.unit")) {
+
+ if (!value)
+ log_error("Missing argument for systemd.unit= kernel command line parameter.");
+ else {
+ r = free_and_strdup(&arg_default_unit, value);
+ if (r < 0)
+ return log_error_errno(r, "Failed to set default unit %s: %m", value);
+ }
+ } else if (!value) {
+ const char *target;
+
+ target = runlevel_to_target(key);
+ if (target) {
+ r = free_and_strdup(&arg_default_unit, target);
+ if (r < 0)
+ return log_error_errno(r, "Failed to set default unit %s: %m", target);
+ }
}
return 0;
@@ -118,7 +138,7 @@ static int generate_wants_symlinks(void) {
STRV_FOREACH(u, arg_wants) {
_cleanup_free_ char *p = NULL, *f = NULL;
- p = strjoin(arg_dest, "/default.target.wants/", *u, NULL);
+ p = strjoin(arg_dest, "/", arg_default_unit, ".wants/", *u, NULL);
if (!p)
return log_oom();
@@ -154,6 +174,12 @@ int main(int argc, char *argv[]) {
umask(0022);
+ r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
+ if (r < 0) {
+ log_error_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET);
+ goto finish;
+ }
+
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/journal-remote/log-generator.py b/src/journal-remote/log-generator.py
index 9a8fb07c7f..fd6964e758 100755
--- a/src/journal-remote/log-generator.py
+++ b/src/journal-remote/log-generator.py
@@ -6,6 +6,8 @@ import argparse
PARSER = argparse.ArgumentParser()
PARSER.add_argument('n', type=int)
PARSER.add_argument('--dots', action='store_true')
+PARSER.add_argument('--data-size', type=int, default=4000)
+PARSER.add_argument('--data-type', choices={'random', 'simple'})
OPTIONS = PARSER.parse_args()
template = """\
@@ -38,10 +40,16 @@ facility = 6
src = open('/dev/urandom', 'rb')
bytes = 0
+counter = 0
for i in range(OPTIONS.n):
message = repr(src.read(2000))
- data = repr(src.read(4000))
+ if OPTIONS.data_type == 'random':
+ data = repr(src.read(OPTIONS.data_size))
+ else:
+ # keep the pattern non-repeating so we get a different blob every time
+ data = '{:0{}}'.format(counter, OPTIONS.data_size)
+ counter += 1
entry = template.format(m=m,
realtime_ts=realtime_ts,
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 12b39dbb27..e00a0d711d 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2705,7 +2705,7 @@ int journal_file_open(
}
if (f->last_stat.st_size < (off_t) HEADER_SIZE_MIN) {
- r = -EIO;
+ r = -ENODATA;
goto fail;
}
diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
index 1221799c1d..06847402e0 100644
--- a/src/journal/journal-internal.h
+++ b/src/journal/journal-internal.h
@@ -121,7 +121,7 @@ struct sd_journal {
Hashmap *directories_by_path;
Hashmap *directories_by_wd;
- Set *errors;
+ Hashmap *errors;
};
char *journal_make_match_string(sd_journal *j);
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index a35783e3ff..98a852cb50 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1708,36 +1708,50 @@ static int access_check_var_log_journal(sd_journal *j) {
static int access_check(sd_journal *j) {
Iterator it;
void *code;
+ char *path;
int r = 0;
assert(j);
- if (set_isempty(j->errors)) {
+ if (hashmap_isempty(j->errors)) {
if (ordered_hashmap_isempty(j->files))
log_notice("No journal files were found.");
return 0;
}
- if (set_contains(j->errors, INT_TO_PTR(-EACCES))) {
+ if (hashmap_contains(j->errors, INT_TO_PTR(-EACCES))) {
(void) access_check_var_log_journal(j);
if (ordered_hashmap_isempty(j->files))
r = log_error_errno(EACCES, "No journal files were opened due to insufficient permissions.");
}
- SET_FOREACH(code, j->errors, it) {
+ HASHMAP_FOREACH_KEY(path, code, j->errors, it) {
int err;
- err = -PTR_TO_INT(code);
- assert(err > 0);
+ err = abs(PTR_TO_INT(code));
- if (err == EACCES)
+ switch (err) {
+ case EACCES:
continue;
- log_warning_errno(err, "Error was encountered while opening journal files: %m");
- if (r == 0)
- r = -err;
+ case ENODATA:
+ log_warning_errno(err, "Journal file %s is truncated, ignoring file.", path);
+ break;
+
+ case EPROTONOSUPPORT:
+ log_warning_errno(err, "Journal file %s uses an unsupported feature, ignoring file.", path);
+ break;
+
+ case EBADMSG:
+ log_warning_errno(err, "Journal file %s corrupted, ignoring file.", path);
+ break;
+
+ default:
+ log_warning_errno(err, "An error was encountered while opening journal file %s, ignoring file.", path);
+ break;
+ }
}
return r;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 218df8cebe..5cde7f17f7 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -73,19 +73,46 @@ static bool journal_pid_changed(sd_journal *j) {
return j->original_pid != getpid();
}
-/* We return an error here only if we didn't manage to
- memorize the real error. */
-static int set_put_error(sd_journal *j, int r) {
+static int journal_put_error(sd_journal *j, int r, const char *path) {
+ char *copy;
int k;
+ /* Memorize an error we encountered, and store which
+ * file/directory it was generated from. Note that we store
+ * only *one* path per error code, as the error code is the
+ * key into the hashmap, and the path is the value. This means
+ * we keep track only of all error kinds, but not of all error
+ * locations. This has the benefit that the hashmap cannot
+ * grow beyond bounds.
+ *
+ * We return an error here only if we didn't manage to
+ * memorize the real error. */
+
if (r >= 0)
return r;
- k = set_ensure_allocated(&j->errors, NULL);
+ k = hashmap_ensure_allocated(&j->errors, NULL);
if (k < 0)
return k;
- return set_put(j->errors, INT_TO_PTR(r));
+ if (path) {
+ copy = strdup(path);
+ if (!copy)
+ return -ENOMEM;
+ } else
+ copy = NULL;
+
+ k = hashmap_put(j->errors, INT_TO_PTR(r), copy);
+ if (k < 0) {
+ free(copy);
+
+ if (k == -EEXIST)
+ return 0;
+
+ return k;
+ }
+
+ return 0;
}
static void detach_location(sd_journal *j) {
@@ -1183,6 +1210,8 @@ static bool file_has_type_prefix(const char *prefix, const char *filename) {
}
static bool file_type_wanted(int flags, const char *filename) {
+ assert(filename);
+
if (!endswith(filename, ".journal") && !endswith(filename, ".journal~"))
return false;
@@ -1207,7 +1236,7 @@ static bool file_type_wanted(int flags, const char *filename) {
static int add_any_file(sd_journal *j, const char *path) {
JournalFile *f = NULL;
- int r;
+ int r, k;
assert(j);
assert(path);
@@ -1216,20 +1245,23 @@ static int add_any_file(sd_journal *j, const char *path) {
return 0;
if (ordered_hashmap_size(j->files) >= JOURNAL_FILES_MAX) {
- log_warning("Too many open journal files, not adding %s.", path);
- return set_put_error(j, -ETOOMANYREFS);
+ log_debug("Too many open journal files, not adding %s.", path);
+ r = -ETOOMANYREFS;
+ goto fail;
}
r = journal_file_open(path, O_RDONLY, 0, false, false, NULL, j->mmap, NULL, &f);
- if (r < 0)
- return r;
+ if (r < 0) {
+ log_debug_errno(r, "Failed to open journal file %s: %m", path);
+ goto fail;
+ }
/* journal_file_dump(f); */
r = ordered_hashmap_put(j->files, f->path, f);
if (r < 0) {
journal_file_close(f);
- return r;
+ goto fail;
}
log_debug("File %s added.", f->path);
@@ -1239,11 +1271,17 @@ static int add_any_file(sd_journal *j, const char *path) {
j->current_invalidate_counter ++;
return 0;
+
+fail:
+ k = journal_put_error(j, r, path);
+ if (k < 0)
+ return k;
+
+ return r;
}
static int add_file(sd_journal *j, const char *prefix, const char *filename) {
- _cleanup_free_ char *path = NULL;
- int r;
+ const char *path;
assert(j);
assert(prefix);
@@ -1253,34 +1291,24 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
!file_type_wanted(j->flags, filename))
return 0;
- path = strjoin(prefix, "/", filename, NULL);
- if (!path)
- return -ENOMEM;
-
- r = add_any_file(j, path);
- if (r == -ENOENT)
- return 0;
- return r;
+ path = strjoina(prefix, "/", filename);
+ return add_any_file(j, path);
}
-static int remove_file(sd_journal *j, const char *prefix, const char *filename) {
- _cleanup_free_ char *path;
+static void remove_file(sd_journal *j, const char *prefix, const char *filename) {
+ const char *path;
JournalFile *f;
assert(j);
assert(prefix);
assert(filename);
- path = strjoin(prefix, "/", filename, NULL);
- if (!path)
- return -ENOMEM;
-
+ path = strjoina(prefix, "/", filename);
f = ordered_hashmap_get(j->files, path);
if (!f)
- return 0;
+ return;
remove_file_real(j, f);
- return 0;
}
static void remove_file_real(sd_journal *j, JournalFile *f) {
@@ -1309,12 +1337,27 @@ static void remove_file_real(sd_journal *j, JournalFile *f) {
j->current_invalidate_counter ++;
}
+static int dirname_is_machine_id(const char *fn) {
+ sd_id128_t id, machine;
+ int r;
+
+ r = sd_id128_get_machine(&machine);
+ if (r < 0)
+ return r;
+
+ r = sd_id128_from_string(fn, &id);
+ if (r < 0)
+ return r;
+
+ return sd_id128_equal(id, machine);
+}
+
static int add_directory(sd_journal *j, const char *prefix, const char *dirname) {
_cleanup_free_ char *path = NULL;
- int r;
_cleanup_closedir_ DIR *d = NULL;
- sd_id128_t id, mid;
+ struct dirent *de = NULL;
Directory *m;
+ int r, k;
assert(j);
assert(prefix);
@@ -1323,35 +1366,36 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
log_debug("Considering %s/%s.", prefix, dirname);
if ((j->flags & SD_JOURNAL_LOCAL_ONLY) &&
- (sd_id128_from_string(dirname, &id) < 0 ||
- sd_id128_get_machine(&mid) < 0 ||
- !(sd_id128_equal(id, mid) || path_startswith(prefix, "/run"))))
+ !(dirname_is_machine_id(dirname) > 0 || path_startswith(prefix, "/run")))
return 0;
path = strjoin(prefix, "/", dirname, NULL);
- if (!path)
- return -ENOMEM;
+ if (!path) {
+ r = -ENOMEM;
+ goto fail;
+ }
d = opendir(path);
if (!d) {
- log_debug_errno(errno, "Failed to open %s: %m", path);
- if (errno == ENOENT)
- return 0;
- return -errno;
+ r = log_debug_errno(errno, "Failed to open directory %s: %m", path);
+ goto fail;
}
m = hashmap_get(j->directories_by_path, path);
if (!m) {
m = new0(Directory, 1);
- if (!m)
- return -ENOMEM;
+ if (!m) {
+ r = -ENOMEM;
+ goto fail;
+ }
m->is_root = false;
m->path = path;
if (hashmap_put(j->directories_by_path, m->path, m) < 0) {
free(m);
- return -ENOMEM;
+ r = -ENOMEM;
+ goto fail;
}
path = NULL; /* avoid freeing in cleanup */
@@ -1373,41 +1417,30 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
inotify_rm_watch(j->inotify_fd, m->wd);
}
- for (;;) {
- struct dirent *de;
-
- errno = 0;
- de = readdir(d);
- if (!de && errno != 0) {
- r = -errno;
- log_debug_errno(errno, "Failed to read directory %s: %m", m->path);
- return r;
- }
- if (!de)
- break;
+ FOREACH_DIRENT_ALL(de, d, return log_debug_errno(errno, "Failed to read directory %s: %m", m->path)) {
if (dirent_is_file_with_suffix(de, ".journal") ||
- dirent_is_file_with_suffix(de, ".journal~")) {
- r = add_file(j, m->path, de->d_name);
- if (r < 0) {
- log_debug_errno(r, "Failed to add file %s/%s: %m",
- m->path, de->d_name);
- r = set_put_error(j, r);
- if (r < 0)
- return r;
- }
- }
+ dirent_is_file_with_suffix(de, ".journal~"))
+ (void) add_file(j, m->path, de->d_name);
}
check_network(j, dirfd(d));
return 0;
+
+fail:
+ k = journal_put_error(j, r, path ?: dirname);
+ if (k < 0)
+ return k;
+
+ return r;
}
-static int add_root_directory(sd_journal *j, const char *p) {
+static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
_cleanup_closedir_ DIR *d = NULL;
+ struct dirent *de;
Directory *m;
- int r;
+ int r, k;
assert(j);
assert(p);
@@ -1420,26 +1453,35 @@ static int add_root_directory(sd_journal *j, const char *p) {
p = strjoina(j->prefix, p);
d = opendir(p);
- if (!d)
- return -errno;
+ if (!d) {
+ if (errno == ENOENT && missing_ok)
+ return 0;
+
+ r = log_debug_errno(errno, "Failed to open root directory %s: %m", p);
+ goto fail;
+ }
m = hashmap_get(j->directories_by_path, p);
if (!m) {
m = new0(Directory, 1);
- if (!m)
- return -ENOMEM;
+ if (!m) {
+ r = -ENOMEM;
+ goto fail;
+ }
m->is_root = true;
m->path = strdup(p);
if (!m->path) {
free(m);
- return -ENOMEM;
+ r = -ENOMEM;
+ goto fail;
}
if (hashmap_put(j->directories_by_path, m->path, m) < 0) {
free(m->path);
free(m);
- return -ENOMEM;
+ r = -ENOMEM;
+ goto fail;
}
j->current_invalidate_counter ++;
@@ -1462,42 +1504,27 @@ static int add_root_directory(sd_journal *j, const char *p) {
if (j->no_new_files)
return 0;
- for (;;) {
- struct dirent *de;
+ FOREACH_DIRENT_ALL(de, d, return log_debug_errno(errno, "Failed to read directory %s: %m", m->path)) {
sd_id128_t id;
- errno = 0;
- de = readdir(d);
- if (!de && errno != 0) {
- r = -errno;
- log_debug_errno(errno, "Failed to read directory %s: %m", m->path);
- return r;
- }
- if (!de)
- break;
-
if (dirent_is_file_with_suffix(de, ".journal") ||
- dirent_is_file_with_suffix(de, ".journal~")) {
- r = add_file(j, m->path, de->d_name);
- if (r < 0) {
- log_debug_errno(r, "Failed to add file %s/%s: %m",
- m->path, de->d_name);
- r = set_put_error(j, r);
- if (r < 0)
- return r;
- }
- } else if ((de->d_type == DT_DIR || de->d_type == DT_LNK || de->d_type == DT_UNKNOWN) &&
- sd_id128_from_string(de->d_name, &id) >= 0) {
-
- r = add_directory(j, m->path, de->d_name);
- if (r < 0)
- log_debug_errno(r, "Failed to add directory %s/%s: %m", m->path, de->d_name);
- }
+ dirent_is_file_with_suffix(de, ".journal~"))
+ (void) add_file(j, m->path, de->d_name);
+ else if (IN_SET(de->d_type, DT_DIR, DT_LNK, DT_UNKNOWN) &&
+ sd_id128_from_string(de->d_name, &id) >= 0)
+ (void) add_directory(j, m->path, de->d_name);
}
check_network(j, dirfd(d));
return 0;
+
+fail:
+ k = journal_put_error(j, r, p);
+ if (k < 0)
+ return k;
+
+ return r;
}
static void remove_directory(sd_journal *j, Directory *d) {
@@ -1522,8 +1549,8 @@ static void remove_directory(sd_journal *j, Directory *d) {
}
static int add_search_paths(sd_journal *j) {
- int r;
- const char search_paths[] =
+
+ static const char search_paths[] =
"/run/log/journal\0"
"/var/log/journal\0";
const char *p;
@@ -1533,14 +1560,8 @@ static int add_search_paths(sd_journal *j) {
/* We ignore most errors here, since the idea is to only open
* what's actually accessible, and ignore the rest. */
- NULSTR_FOREACH(p, search_paths) {
- r = add_root_directory(j, p);
- if (r < 0 && r != -ENOENT) {
- r = set_put_error(j, r);
- if (r < 0)
- return r;
- }
- }
+ NULSTR_FOREACH(p, search_paths)
+ (void) add_root_directory(j, p, true);
return 0;
}
@@ -1564,17 +1585,14 @@ static int add_current_paths(sd_journal *j) {
if (!dir)
return -ENOMEM;
- r = add_root_directory(j, dir);
- if (r < 0) {
- set_put_error(j, r);
+ r = add_root_directory(j, dir, true);
+ if (r < 0)
return r;
- }
}
return 0;
}
-
static int allocate_inotify(sd_journal *j) {
assert(j);
@@ -1702,11 +1720,9 @@ _public_ int sd_journal_open_directory(sd_journal **ret, const char *path, int f
if (!j)
return -ENOMEM;
- r = add_root_directory(j, path);
- if (r < 0) {
- set_put_error(j, r);
+ r = add_root_directory(j, path, false);
+ if (r < 0)
goto fail;
- }
*ret = j;
return 0;
@@ -1731,10 +1747,8 @@ _public_ int sd_journal_open_files(sd_journal **ret, const char **paths, int fla
STRV_FOREACH(path, paths) {
r = add_any_file(j, *path);
- if (r < 0) {
- log_error_errno(r, "Failed to open %s: %m", *path);
+ if (r < 0)
goto fail;
- }
}
j->no_new_files = true;
@@ -1751,6 +1765,7 @@ fail:
_public_ void sd_journal_close(sd_journal *j) {
Directory *d;
JournalFile *f;
+ char *p;
if (!j)
return;
@@ -1778,10 +1793,13 @@ _public_ void sd_journal_close(sd_journal *j) {
mmap_cache_unref(j->mmap);
}
+ while ((p = hashmap_steal_first(j->errors)))
+ free(p);
+ hashmap_free(j->errors);
+
free(j->path);
free(j->prefix);
free(j->unique_field);
- set_free(j->errors);
free(j);
}
@@ -2074,7 +2092,7 @@ _public_ int sd_journal_get_fd(sd_journal *j) {
if (j->no_new_files)
r = add_current_paths(j);
else if (j->path)
- r = add_root_directory(j, j->path);
+ r = add_root_directory(j, j->path, true);
else
r = add_search_paths(j);
if (r < 0)
@@ -2121,7 +2139,6 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) {
static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
Directory *d;
- int r;
assert(j);
assert(e);
@@ -2137,20 +2154,10 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
/* Event for a journal file */
- if (e->mask & (IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB)) {
- r = add_file(j, d->path, e->name);
- if (r < 0) {
- log_debug_errno(r, "Failed to add file %s/%s: %m",
- d->path, e->name);
- set_put_error(j, r);
- }
-
- } else if (e->mask & (IN_DELETE|IN_MOVED_FROM|IN_UNMOUNT)) {
-
- r = remove_file(j, d->path, e->name);
- if (r < 0)
- log_debug_errno(r, "Failed to remove file %s/%s: %m", d->path, e->name);
- }
+ if (e->mask & (IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB))
+ (void) add_file(j, d->path, e->name);
+ else if (e->mask & (IN_DELETE|IN_MOVED_FROM|IN_UNMOUNT))
+ remove_file(j, d->path, e->name);
} else if (!d->is_root && e->len == 0) {
@@ -2163,11 +2170,8 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
/* Event for root directory */
- if (e->mask & (IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB)) {
- r = add_directory(j, d->path, e->name);
- if (r < 0)
- log_debug_errno(r, "Failed to add directory %s/%s: %m", d->path, e->name);
- }
+ if (e->mask & (IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB))
+ (void) add_directory(j, d->path, e->name);
}
return;
@@ -2176,7 +2180,7 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
if (e->mask & IN_IGNORED)
return;
- log_warning("Unknown inotify event.");
+ log_debug("Unknown inotify event.");
}
static int determine_change(sd_journal *j) {
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index 0d40bc5c00..0e49262087 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -356,13 +356,10 @@ int device_set_ifindex(sd_device *device, const char *_ifindex) {
assert(device);
assert(_ifindex);
- r = safe_atoi(_ifindex, &ifindex);
+ r = parse_ifindex(_ifindex, &ifindex);
if (r < 0)
return r;
- if (ifindex <= 0)
- return -EINVAL;
-
r = device_add_property_internal(device, "IFINDEX", _ifindex);
if (r < 0)
return r;
@@ -632,11 +629,9 @@ _public_ int sd_device_new_from_device_id(sd_device **ret, const char *id) {
struct ifreq ifr = {};
int ifindex;
- r = safe_atoi(&id[1], &ifr.ifr_ifindex);
+ r = parse_ifindex(&id[1], &ifr.ifr_ifindex);
if (r < 0)
return r;
- else if (ifr.ifr_ifindex <= 0)
- return -EINVAL;
sk = socket(PF_INET, SOCK_DGRAM, 0);
if (sk < 0)
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
index cd766c3f91..3f2e459825 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -932,9 +932,7 @@ _public_ int sd_machine_get_ifindices(const char *machine, int **ifindices) {
*(char*) (mempcpy(buf, word, l)) = 0;
- if (safe_atoi(buf, &ifi) < 0)
- continue;
- if (ifi <= 0)
+ if (parse_ifindex(buf, &ifi) < 0)
continue;
if (!GREEDY_REALLOC(ni, allocated, nr+1)) {
diff --git a/src/machine/machine.c b/src/machine/machine.c
index ef5c8551b5..cbc03640c1 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -325,16 +325,14 @@ int machine_load(Machine *m) {
r = extract_first_word(&p, &word, NULL, 0);
if (r == 0)
break;
- else if (r == -ENOMEM)
+ if (r == -ENOMEM)
return log_oom();
- else if (r < 0) {
+ if (r < 0) {
log_warning_errno(r, "Failed to parse NETIF: %s", netif);
- continue;
+ break;
}
- if (safe_atoi(word, &ifi) < 0)
- continue;
- if (ifi <= 0)
+ if (parse_ifindex(word, &ifi) < 0)
continue;
if (!GREEDY_REALLOC(ni, allocated, nr+1)) {
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 97c1fe6560..ba7e3ba74a 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -521,7 +521,7 @@ static int link_status_one(
assert(rtnl);
assert(name);
- if (safe_atoi(name, &ifindex) >= 0 && ifindex > 0)
+ if (parse_ifindex(name, &ifindex) >= 0)
r = sd_rtnl_message_new_link(rtnl, &req, RTM_GETLINK, ifindex);
else {
r = sd_rtnl_message_new_link(rtnl, &req, RTM_GETLINK, 0);
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c
index 7fc4510ac9..11b35d6cf8 100644
--- a/src/network/networkd-link-bus.c
+++ b/src/network/networkd-link-bus.c
@@ -103,7 +103,7 @@ int link_object_find(sd_bus *bus, const char *path, const char *interface, void
if (r < 0)
return 0;
- r = safe_atoi(identifier, &ifindex);
+ r = parse_ifindex(identifier, &ifindex);
if (r < 0)
return 0;
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 57739d1f3e..432e62dd9f 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -300,8 +300,7 @@ static int parse_address(const char *s, int *family, union in_addr_union *addres
percent = strchr(s, '%');
if (percent) {
- r = safe_atoi(percent+1, &ifi);
- if (r < 0 || ifi <= 0) {
+ if (parse_ifindex(percent+1, &ifi) < 0) {
ifi = if_nametoindex(percent+1);
if (ifi <= 0)
return -EINVAL;
@@ -521,7 +520,7 @@ static int parse_argv(int argc, char *argv[]) {
case 'i': {
int ifi;
- if (safe_atoi(optarg, &ifi) >= 0 && ifi > 0)
+ if (parse_ifindex(optarg, &ifi) >= 0)
arg_ifindex = ifi;
else {
ifi = if_nametoindex(optarg);
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index bb00f99ecf..5c45a3ae6c 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -212,7 +212,7 @@ static int load_state(
assert(udev);
assert(event);
- if (!shall_restore_state())
+ if (shall_restore_state() == 0)
return 0;
r = find_device(udev, event, &device);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 940e393318..a13991a960 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1450,7 +1450,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
"SendSIGHUP", "SendSIGKILL", "WakeSystem", "DefaultDependencies",
"IgnoreSIGPIPE", "TTYVHangup", "TTYReset", "RemainAfterExit",
"PrivateTmp", "PrivateDevices", "PrivateNetwork", "NoNewPrivileges",
- "SyslogLevelPrefix")) {
+ "SyslogLevelPrefix", "Delegate")) {
r = parse_boolean(eq);
if (r < 0) {
@@ -1789,6 +1789,40 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
r = sd_bus_message_close_container(m);
+ } else if (streq(field, "RuntimeDirectory")) {
+ const char *p;
+
+ r = sd_bus_message_open_container(m, 'v', "as");
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_open_container(m, 'a', "s");
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ p = eq;
+
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+
+ r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse %s value %s", field, eq);
+
+ if (r == 0)
+ break;
+
+ r = sd_bus_message_append_basic(m, 's', word);
+ if (r < 0)
+ return bus_log_create_error(r);
+ }
+
+ r = sd_bus_message_close_container(m);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_close_container(m);
+
} else {
log_error("Unknown assignment %s.", assignment);
return -EINVAL;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index da816e6d0e..70871cf3e6 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -6631,6 +6631,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
{}
};
+ const char *p;
int c, r;
assert(argc >= 0);
@@ -6651,15 +6652,19 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
return version();
case 't': {
- const char *word, *state;
- size_t size;
+ if (isempty(optarg))
+ return log_error_errno(r, "--type requires arguments.");
- FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) {
- _cleanup_free_ char *type;
+ p = optarg;
+ for(;;) {
+ _cleanup_free_ char *type = NULL;
- type = strndup(word, size);
- if (!type)
- return -ENOMEM;
+ r = extract_first_word(&p, &type, ",", 0);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse type: %s", optarg);
+
+ if (r == 0)
+ break;
if (streq(type, "help")) {
help_types();
@@ -6700,18 +6705,21 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
if (!arg_properties)
return log_oom();
} else {
- const char *word, *state;
- size_t size;
+ p = optarg;
+ for(;;) {
+ _cleanup_free_ char *prop = NULL;
- FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) {
- char *prop;
+ r = extract_first_word(&p, &prop, ",", 0);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse property: %s", optarg);
- prop = strndup(word, size);
- if (!prop)
- return log_oom();
+ if (r == 0)
+ break;
- if (strv_consume(&arg_properties, prop) < 0)
+ if (strv_push(&arg_properties, prop) < 0)
return log_oom();
+
+ prop = NULL;
}
}
@@ -6877,15 +6885,19 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case ARG_STATE: {
- const char *word, *state;
- size_t size;
+ if (isempty(optarg))
+ return log_error_errno(r, "--signal requires arguments.");
- FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) {
+ p = optarg;
+ for(;;) {
_cleanup_free_ char *s = NULL;
- s = strndup(word, size);
- if (!s)
- return log_oom();
+ r = extract_first_word(&p, &s, ",", 0);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse signal: %s", optarg);
+
+ if (r == 0)
+ break;
if (streq(s, "help")) {
help_states();
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index b2d53d3b4f..042be97840 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -530,7 +530,7 @@ static int load_sysv(SysvStub *s) {
if (startswith_no_case(t, "description:")) {
size_t k;
- const const char *j;
+ const char *j;
k = strlen(t);
if (k > 0 && t[k-1] == '\\') {
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index afbaa12e94..e2ec53ee51 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <sys/types.h>
+#include "fileio.h"
#include "fs-util.h"
#include "macro.h"
#include "manager.h"
@@ -147,6 +148,26 @@ static void test_exec_environment(Manager *m) {
test(m, "exec-environment-empty.service", 0, CLD_EXITED);
}
+static void test_exec_environmentfile(Manager *m) {
+ static const char e[] =
+ "VAR1='word1 word2'\n"
+ "VAR2=word3 \n"
+ "# comment1\n"
+ "\n"
+ "; comment2\n"
+ " ; # comment3\n"
+ "line without an equal\n"
+ "VAR3='$word 5 6'\n";
+ int r;
+
+ r = write_string_file("/tmp/test-exec_environmentfile.conf", e, WRITE_STRING_FILE_CREATE);
+ assert_se(r == 0);
+
+ test(m, "exec-environmentfile.service", 0, CLD_EXITED);
+
+ unlink("/tmp/test-exec_environmentfile.conf");
+}
+
static void test_exec_umask(Manager *m) {
test(m, "exec-umask-default.service", 0, CLD_EXITED);
test(m, "exec-umask-0177.service", 0, CLD_EXITED);
@@ -178,6 +199,30 @@ static void test_exec_capabilityboundingset(Manager *m) {
test(m, "exec-capabilityboundingset-invert.service", 0, CLD_EXITED);
}
+static void test_exec_privatenetwork(Manager *m) {
+ int r;
+
+ r = find_binary("ip", NULL);
+ if (r < 0) {
+ log_error_errno(r, "Skipping test_exec_privatenetwork, could not find ip binary: %m");
+ return;
+ }
+
+ test(m, "exec-privatenetwork-yes.service", 0, CLD_EXITED);
+}
+
+static void test_exec_oomscoreadjust(Manager *m) {
+ test(m, "exec-oomscoreadjust-positive.service", 0, CLD_EXITED);
+ test(m, "exec-oomscoreadjust-negative.service", 0, CLD_EXITED);
+}
+
+static void test_exec_ioschedulingclass(Manager *m) {
+ test(m, "exec-ioschedulingclass-none.service", 0, CLD_EXITED);
+ test(m, "exec-ioschedulingclass-idle.service", 0, CLD_EXITED);
+ test(m, "exec-ioschedulingclass-realtime.service", 0, CLD_EXITED);
+ test(m, "exec-ioschedulingclass-best-effort.service", 0, CLD_EXITED);
+}
+
int main(int argc, char *argv[]) {
test_function_t tests[] = {
test_exec_workingdirectory,
@@ -185,14 +230,18 @@ int main(int argc, char *argv[]) {
test_exec_ignoresigpipe,
test_exec_privatetmp,
test_exec_privatedevices,
+ test_exec_privatenetwork,
test_exec_systemcallfilter,
test_exec_systemcallerrornumber,
test_exec_user,
test_exec_group,
test_exec_environment,
+ test_exec_environmentfile,
test_exec_umask,
test_exec_runtimedirectory,
test_exec_capabilityboundingset,
+ test_exec_oomscoreadjust,
+ test_exec_ioschedulingclass,
NULL,
};
test_function_t *test = NULL;
@@ -209,7 +258,7 @@ int main(int argc, char *argv[]) {
}
assert_se(setenv("XDG_RUNTIME_DIR", "/tmp/", 1) == 0);
- assert_se(set_unit_path(TEST_DIR) >= 0);
+ assert_se(set_unit_path(TEST_DIR "/test-execute/") >= 0);
r = manager_new(MANAGER_USER, true, &m);
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
diff --git a/src/test/test-path.c b/src/test/test-path.c
index ff0f044958..8302bdd283 100644
--- a/src/test/test-path.c
+++ b/src/test/test-path.c
@@ -258,7 +258,7 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
- assert_se(set_unit_path(TEST_DIR) >= 0);
+ assert_se(set_unit_path(TEST_DIR "/test-path/") >= 0);
for (test = tests; test && *test; test++) {
int r;
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
new file mode 100644
index 0000000000..25444c794a
--- /dev/null
+++ b/src/test/test-string-util.c
@@ -0,0 +1,61 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2015 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 "string-util.h"
+
+static void test_string_erase(void) {
+ char *x;
+
+ x = strdupa("");
+ assert_se(streq(string_erase(x), ""));
+
+ x = strdupa("1");
+ assert_se(streq(string_erase(x), "x"));
+
+ x = strdupa("12");
+ assert_se(streq(string_erase(x), "xx"));
+
+ x = strdupa("123");
+ assert_se(streq(string_erase(x), "xxx"));
+
+ x = strdupa("1234");
+ assert_se(streq(string_erase(x), "xxxx"));
+
+ x = strdupa("12345");
+ assert_se(streq(string_erase(x), "xxxxx"));
+
+ x = strdupa("123456");
+ assert_se(streq(string_erase(x), "xxxxxx"));
+
+ x = strdupa("1234567");
+ assert_se(streq(string_erase(x), "xxxxxxx"));
+
+ x = strdupa("12345678");
+ assert_se(streq(string_erase(x), "xxxxxxxx"));
+
+ x = strdupa("123456789");
+ assert_se(streq(string_erase(x), "xxxxxxxxx"));
+}
+
+int main(int argc, char *argv[]) {
+ test_string_erase();
+ return 0;
+}
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 647df4f5c3..f6ed55878c 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -48,6 +48,7 @@
#include "process-util.h"
#include "rm-rf.h"
#include "signal-util.h"
+#include "special.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
@@ -1638,6 +1639,12 @@ cleanup:
assert_se(rmdir(t) >= 0);
}
+static void test_runlevel_to_target(void) {
+ assert_se(streq_ptr(runlevel_to_target(NULL), NULL));
+ assert_se(streq_ptr(runlevel_to_target("unknown-runlevel"), NULL));
+ assert_se(streq_ptr(runlevel_to_target("3"), SPECIAL_MULTI_USER_TARGET));
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -1718,6 +1725,7 @@ int main(int argc, char *argv[]) {
test_tempfn();
test_strcmp_ptr();
test_fgetxattrat_fake();
+ test_runlevel_to_target();
return 0;
}
diff --git a/sysctl.d/50-default.conf b/sysctl.d/50-default.conf
index 2097551c33..def151bb84 100644
--- a/sysctl.d/50-default.conf
+++ b/sysctl.d/50-default.conf
@@ -35,9 +35,6 @@ net.ipv4.conf.all.promote_secondaries = 1
# Fair Queue CoDel packet scheduler to fight bufferbloat
net.core.default_qdisc = fq_codel
-# Make sure we can queue more than just a few datagrams in AF_UNIX sockets.
-net.unix.max_dgram_qlen = 512
-
# Enable hard and soft link protection
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
diff --git a/test/paths.target b/test/paths.target
deleted file mode 120000
index e9939c9801..0000000000
--- a/test/paths.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/paths.target \ No newline at end of file
diff --git a/test/exec-capabilityboundingset-invert.service b/test/test-execute/exec-capabilityboundingset-invert.service
index e2b09e1550..e2b09e1550 100644
--- a/test/exec-capabilityboundingset-invert.service
+++ b/test/test-execute/exec-capabilityboundingset-invert.service
diff --git a/test/exec-capabilityboundingset-merge.service b/test/test-execute/exec-capabilityboundingset-merge.service
index b0f4732529..b0f4732529 100644
--- a/test/exec-capabilityboundingset-merge.service
+++ b/test/test-execute/exec-capabilityboundingset-merge.service
diff --git a/test/exec-capabilityboundingset-reset.service b/test/test-execute/exec-capabilityboundingset-reset.service
index 51092ab0d5..51092ab0d5 100644
--- a/test/exec-capabilityboundingset-reset.service
+++ b/test/test-execute/exec-capabilityboundingset-reset.service
diff --git a/test/exec-capabilityboundingset-simple.service b/test/test-execute/exec-capabilityboundingset-simple.service
index b9037a0ddf..b9037a0ddf 100644
--- a/test/exec-capabilityboundingset-simple.service
+++ b/test/test-execute/exec-capabilityboundingset-simple.service
diff --git a/test/exec-environment-empty.service b/test/test-execute/exec-environment-empty.service
index 0219ca4fd7..0219ca4fd7 100644
--- a/test/exec-environment-empty.service
+++ b/test/test-execute/exec-environment-empty.service
diff --git a/test/exec-environment-multiple.service b/test/test-execute/exec-environment-multiple.service
index 479005a5d8..479005a5d8 100644
--- a/test/exec-environment-multiple.service
+++ b/test/test-execute/exec-environment-multiple.service
diff --git a/test/exec-environment.service b/test/test-execute/exec-environment.service
index 4586b4c4a9..4586b4c4a9 100644
--- a/test/exec-environment.service
+++ b/test/test-execute/exec-environment.service
diff --git a/test/test-execute/exec-environmentfile.service b/test/test-execute/exec-environmentfile.service
new file mode 100644
index 0000000000..848f2a120c
--- /dev/null
+++ b/test/test-execute/exec-environmentfile.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for EnvironmentFile
+
+[Service]
+ExecStart=/bin/sh -c 'exit $(test "$VAR1" = "word1 word2") && $(test "$VAR2" = word3) && $(test "$VAR3" = \'$word 5 6\')'
+Type=oneshot
+EnvironmentFile=/tmp/test-exec_environmentfile.conf
diff --git a/test/exec-group.service b/test/test-execute/exec-group.service
index 1aa04b5bd2..1aa04b5bd2 100644
--- a/test/exec-group.service
+++ b/test/test-execute/exec-group.service
diff --git a/test/exec-ignoresigpipe-no.service b/test/test-execute/exec-ignoresigpipe-no.service
index 69b2e9d8a8..69b2e9d8a8 100644
--- a/test/exec-ignoresigpipe-no.service
+++ b/test/test-execute/exec-ignoresigpipe-no.service
diff --git a/test/exec-ignoresigpipe-yes.service b/test/test-execute/exec-ignoresigpipe-yes.service
index 877ec8aed0..877ec8aed0 100644
--- a/test/exec-ignoresigpipe-yes.service
+++ b/test/test-execute/exec-ignoresigpipe-yes.service
diff --git a/test/test-execute/exec-ioschedulingclass-best-effort.service b/test/test-execute/exec-ioschedulingclass-best-effort.service
new file mode 100644
index 0000000000..56e2718505
--- /dev/null
+++ b/test/test-execute/exec-ioschedulingclass-best-effort.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for IOSchedulingClass=best-effort
+
+[Service]
+ExecStart=/bin/bash -c 'c=$(ionice); echo $c; [[ "$c" == best-effort* ]]'
+Type=oneshot
+IOSchedulingClass=best-effort
diff --git a/test/test-execute/exec-ioschedulingclass-idle.service b/test/test-execute/exec-ioschedulingclass-idle.service
new file mode 100644
index 0000000000..b45795cab7
--- /dev/null
+++ b/test/test-execute/exec-ioschedulingclass-idle.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for IOSchedulingClass=idle
+
+[Service]
+ExecStart=/bin/bash -c 'c=$(ionice); echo $c; [[ "$c" == idle* ]]'
+Type=oneshot
+IOSchedulingClass=idle
diff --git a/test/test-execute/exec-ioschedulingclass-none.service b/test/test-execute/exec-ioschedulingclass-none.service
new file mode 100644
index 0000000000..36b546ca01
--- /dev/null
+++ b/test/test-execute/exec-ioschedulingclass-none.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for IOSchedulingClass=none
+
+[Service]
+ExecStart=/bin/bash -c 'c=$(ionice); echo $c; [[ "$c" == none* ]]'
+Type=oneshot
+IOSchedulingClass=none
diff --git a/test/test-execute/exec-ioschedulingclass-realtime.service b/test/test-execute/exec-ioschedulingclass-realtime.service
new file mode 100644
index 0000000000..74936d8079
--- /dev/null
+++ b/test/test-execute/exec-ioschedulingclass-realtime.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for IOSchedulingClass=realtime
+
+[Service]
+ExecStart=/bin/bash -c 'c=$(ionice); echo $c; [[ "$c" == realtime* ]]'
+Type=oneshot
+IOSchedulingClass=realtime
diff --git a/test/test-execute/exec-oomscoreadjust-negative.service b/test/test-execute/exec-oomscoreadjust-negative.service
new file mode 100644
index 0000000000..63ab501c63
--- /dev/null
+++ b/test/test-execute/exec-oomscoreadjust-negative.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for OOMScoreAdjust
+
+[Service]
+ExecStart=/bin/bash -c 'c=$(cat /proc/self/oom_score_adj); echo $c; exit $(test $c -eq -100)'
+OOMScoreAdjust=-100
+Type=oneshot
diff --git a/test/test-execute/exec-oomscoreadjust-positive.service b/test/test-execute/exec-oomscoreadjust-positive.service
new file mode 100644
index 0000000000..e47a4f1392
--- /dev/null
+++ b/test/test-execute/exec-oomscoreadjust-positive.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for OOMScoreAdjust
+
+[Service]
+ExecStart=/bin/bash -c 'c=$(cat /proc/self/oom_score_adj); echo $c; exit $(test $c -eq 100)'
+OOMScoreAdjust=100
+Type=oneshot
diff --git a/test/exec-personality-s390.service b/test/test-execute/exec-personality-s390.service
index f3c3b03e3d..f3c3b03e3d 100644
--- a/test/exec-personality-s390.service
+++ b/test/test-execute/exec-personality-s390.service
diff --git a/test/exec-personality-x86-64.service b/test/test-execute/exec-personality-x86-64.service
index 5bb5d910d0..5bb5d910d0 100644
--- a/test/exec-personality-x86-64.service
+++ b/test/test-execute/exec-personality-x86-64.service
diff --git a/test/exec-personality-x86.service b/test/test-execute/exec-personality-x86.service
index 0b370a6480..0b370a6480 100644
--- a/test/exec-personality-x86.service
+++ b/test/test-execute/exec-personality-x86.service
diff --git a/test/exec-privatedevices-no.service b/test/test-execute/exec-privatedevices-no.service
index cf4f275fb6..cf4f275fb6 100644
--- a/test/exec-privatedevices-no.service
+++ b/test/test-execute/exec-privatedevices-no.service
diff --git a/test/exec-privatedevices-yes.service b/test/test-execute/exec-privatedevices-yes.service
index 85b3f4f981..85b3f4f981 100644
--- a/test/exec-privatedevices-yes.service
+++ b/test/test-execute/exec-privatedevices-yes.service
diff --git a/test/test-execute/exec-privatenetwork-yes.service b/test/test-execute/exec-privatenetwork-yes.service
new file mode 100644
index 0000000000..494712e6a7
--- /dev/null
+++ b/test/test-execute/exec-privatenetwork-yes.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Test for PrivateNetwork
+
+[Service]
+ExecStart=/bin/sh -c 'i=$(ip link | grep ": " | grep -v lo); echo $i; exit $(test -z $i)'
+PrivateNetwork=yes
diff --git a/test/exec-privatetmp-no.service b/test/test-execute/exec-privatetmp-no.service
index d69e552a63..d69e552a63 100644
--- a/test/exec-privatetmp-no.service
+++ b/test/test-execute/exec-privatetmp-no.service
diff --git a/test/exec-privatetmp-yes.service b/test/test-execute/exec-privatetmp-yes.service
index 881a040b87..881a040b87 100644
--- a/test/exec-privatetmp-yes.service
+++ b/test/test-execute/exec-privatetmp-yes.service
diff --git a/test/exec-runtimedirectory-mode.service b/test/test-execute/exec-runtimedirectory-mode.service
index ba6d7ee39f..ba6d7ee39f 100644
--- a/test/exec-runtimedirectory-mode.service
+++ b/test/test-execute/exec-runtimedirectory-mode.service
diff --git a/test/exec-runtimedirectory-owner.service b/test/test-execute/exec-runtimedirectory-owner.service
index 077e08d1c5..077e08d1c5 100644
--- a/test/exec-runtimedirectory-owner.service
+++ b/test/test-execute/exec-runtimedirectory-owner.service
diff --git a/test/exec-runtimedirectory.service b/test/test-execute/exec-runtimedirectory.service
index c12a6c63d6..c12a6c63d6 100644
--- a/test/exec-runtimedirectory.service
+++ b/test/test-execute/exec-runtimedirectory.service
diff --git a/test/exec-systemcallerrornumber.service b/test/test-execute/exec-systemcallerrornumber.service
index 255a8b231a..255a8b231a 100644
--- a/test/exec-systemcallerrornumber.service
+++ b/test/test-execute/exec-systemcallerrornumber.service
diff --git a/test/exec-systemcallfilter-failing.service b/test/test-execute/exec-systemcallfilter-failing.service
index c6ce9368c9..c6ce9368c9 100644
--- a/test/exec-systemcallfilter-failing.service
+++ b/test/test-execute/exec-systemcallfilter-failing.service
diff --git a/test/exec-systemcallfilter-failing2.service b/test/test-execute/exec-systemcallfilter-failing2.service
index b7f7c2aff9..b7f7c2aff9 100644
--- a/test/exec-systemcallfilter-failing2.service
+++ b/test/test-execute/exec-systemcallfilter-failing2.service
diff --git a/test/exec-systemcallfilter-not-failing.service b/test/test-execute/exec-systemcallfilter-not-failing.service
index feb206ab6d..feb206ab6d 100644
--- a/test/exec-systemcallfilter-not-failing.service
+++ b/test/test-execute/exec-systemcallfilter-not-failing.service
diff --git a/test/exec-systemcallfilter-not-failing2.service b/test/test-execute/exec-systemcallfilter-not-failing2.service
index cca469aa3d..cca469aa3d 100644
--- a/test/exec-systemcallfilter-not-failing2.service
+++ b/test/test-execute/exec-systemcallfilter-not-failing2.service
diff --git a/test/exec-umask-0177.service b/test/test-execute/exec-umask-0177.service
index af9295888e..af9295888e 100644
--- a/test/exec-umask-0177.service
+++ b/test/test-execute/exec-umask-0177.service
diff --git a/test/exec-umask-default.service b/test/test-execute/exec-umask-default.service
index 41e20a60a1..41e20a60a1 100644
--- a/test/exec-umask-default.service
+++ b/test/test-execute/exec-umask-default.service
diff --git a/test/exec-user.service b/test/test-execute/exec-user.service
index 2ca08ebb42..2ca08ebb42 100644
--- a/test/exec-user.service
+++ b/test/test-execute/exec-user.service
diff --git a/test/exec-workingdirectory.service b/test/test-execute/exec-workingdirectory.service
index 10855d682a..10855d682a 100644
--- a/test/exec-workingdirectory.service
+++ b/test/test-execute/exec-workingdirectory.service
diff --git a/test/test-path/basic.target b/test/test-path/basic.target
new file mode 120000
index 0000000000..a882b72cc9
--- /dev/null
+++ b/test/test-path/basic.target
@@ -0,0 +1 @@
+../../units/basic.target \ No newline at end of file
diff --git a/test/path-changed.path b/test/test-path/path-changed.path
index e58bdd925f..e58bdd925f 100644
--- a/test/path-changed.path
+++ b/test/test-path/path-changed.path
diff --git a/test/path-changed.service b/test/test-path/path-changed.service
index 8bdf178830..8bdf178830 120000
--- a/test/path-changed.service
+++ b/test/test-path/path-changed.service
diff --git a/test/path-directorynotempty.path b/test/test-path/path-directorynotempty.path
index 17e599fc0e..17e599fc0e 100644
--- a/test/path-directorynotempty.path
+++ b/test/test-path/path-directorynotempty.path
diff --git a/test/path-directorynotempty.service b/test/test-path/path-directorynotempty.service
index 8bdf178830..8bdf178830 120000
--- a/test/path-directorynotempty.service
+++ b/test/test-path/path-directorynotempty.service
diff --git a/test/path-exists.path b/test/test-path/path-exists.path
index c4c9105af4..c4c9105af4 100644
--- a/test/path-exists.path
+++ b/test/test-path/path-exists.path
diff --git a/test/path-exists.service b/test/test-path/path-exists.service
index 8bdf178830..8bdf178830 120000
--- a/test/path-exists.service
+++ b/test/test-path/path-exists.service
diff --git a/test/path-existsglob.path b/test/test-path/path-existsglob.path
index a058599605..a058599605 100644
--- a/test/path-existsglob.path
+++ b/test/test-path/path-existsglob.path
diff --git a/test/path-existsglob.service b/test/test-path/path-existsglob.service
index 8bdf178830..8bdf178830 120000
--- a/test/path-existsglob.service
+++ b/test/test-path/path-existsglob.service
diff --git a/test/path-makedirectory.path b/test/test-path/path-makedirectory.path
index 9408479c0f..9408479c0f 100644
--- a/test/path-makedirectory.path
+++ b/test/test-path/path-makedirectory.path
diff --git a/test/path-makedirectory.service b/test/test-path/path-makedirectory.service
index 8bdf178830..8bdf178830 120000
--- a/test/path-makedirectory.service
+++ b/test/test-path/path-makedirectory.service
diff --git a/test/path-modified.path b/test/test-path/path-modified.path
index 18363227ba..18363227ba 100644
--- a/test/path-modified.path
+++ b/test/test-path/path-modified.path
diff --git a/test/path-modified.service b/test/test-path/path-modified.service
index 8bdf178830..8bdf178830 120000
--- a/test/path-modified.service
+++ b/test/test-path/path-modified.service
diff --git a/test/path-mycustomunit.service b/test/test-path/path-mycustomunit.service
index 172ac0d0d5..172ac0d0d5 100644
--- a/test/path-mycustomunit.service
+++ b/test/test-path/path-mycustomunit.service
diff --git a/test/path-service.service b/test/test-path/path-service.service
index f8499ec619..f8499ec619 100644
--- a/test/path-service.service
+++ b/test/test-path/path-service.service
diff --git a/test/path-unit.path b/test/test-path/path-unit.path
index 95e572d6d5..95e572d6d5 100644
--- a/test/path-unit.path
+++ b/test/test-path/path-unit.path
diff --git a/test/test-path/paths.target b/test/test-path/paths.target
new file mode 120000
index 0000000000..b402796cb9
--- /dev/null
+++ b/test/test-path/paths.target
@@ -0,0 +1 @@
+../../units/paths.target \ No newline at end of file
diff --git a/test/test-path/sysinit.target b/test/test-path/sysinit.target
new file mode 120000
index 0000000000..9d10e5b2e2
--- /dev/null
+++ b/test/test-path/sysinit.target
@@ -0,0 +1 @@
+../../units/sysinit.target \ No newline at end of file