Commit Graph

35222 Commits

Author SHA1 Message Date
Yu Watanabe 5485deee6e
sd-device: use qsort_safe() (#10099)
The number of found devices may be zero. So, let's use qsort_safe().

Follow-up for 0a1665890c.
Fixes #10096.
2018-09-16 23:46:58 +09:00
Zbigniew Jędrzejewski-Szmek 32397af3d4
Merge pull request #9928 from yuwata/libudev-cleanups
libudev: coding style updates
2018-09-15 22:36:38 +02:00
Zbigniew Jędrzejewski-Szmek 9035119518
Merge pull request #9958 from yuwata/sd-device-enum-set
sd-device: make sd_device_enumerator_get_*_next() not destroy the list
2018-09-15 18:33:18 +02:00
Zbigniew Jędrzejewski-Szmek fe4bd4e501 test/test-functions: adjust to Exec*= paths not being absolute 2018-09-15 10:12:18 +02:00
Dimitri John Ledkov e180bdb5eb test/test-functions: drop all prefixes
When parsing and installing binaries mentioned in Exec*= lines the
5ed0dcf4d5 commit added parsing logic to drop
prefixes, including handling duplicate exclamation marks. But this did not
handle arbitrary combination of multiple prefixes, ie. StartExec=+-/bin/sh was
parsed as -/bin/sh which then would fail to install.

Instead of using egrep and shell replacements, replace both with sed command
that does it all. This sed script extract a group of characters starting with a
/ up to the first space (if any) after the equals sign. This correctly handles
existing non-prefixed, prefixed, multiple-prefixed commands.

About half commands seem to repeat themself, thus sort -u cuts the list of
binaries to install about in half.

To validate change of behaviour both old and new functions were modified to
echo parsed binaries into separate files, and then diffed. The incorrect
-/bin/sh was missing in the new output.

Without this patch tests fail on default Ubuntu installs.
2018-09-15 10:11:18 +02:00
Yu Watanabe 0ac4f1a513
Merge pull request #10070 from keszybz/test-reporting
Test reporting improvements
2018-09-15 15:55:15 +09:00
Evgeny Vereshchagin ff5f29eb69
Merge pull request #10089 from yuwata/fix-oss-fuzz-10350
bus-util: use _printf_ attribute

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10350.
2018-09-15 05:36:44 +03:00
Yu Watanabe 3332004e28 test-catalog: drop unused variable
Follow-up for 49cdae63d1.
2018-09-15 01:59:14 +09:00
Yu Watanabe 72a4d9f96c bus-util: use _printf_ attribute
Follow-up for eda193578e.

Fixes oss-fuzz#10350.
2018-09-15 01:50:59 +09:00
Zbigniew Jędrzejewski-Szmek 4aabca0058 man: remove recommendation to pull in slices from slices.target
That recommendation is likely to cause more trouble and for pretty
much all end-user units is not useful. Let's recommend relying on
the implicit dependency instead.

Fixes #10015.
2018-09-14 16:39:47 +02:00
Zbigniew Jędrzejewski-Szmek 23a9ffb093 man: add a description of systemctl return codes
Fixes #10056.
2018-09-14 16:02:48 +02:00
Franck Bui 10ce2e0681 socket-util: attempt SO_RCVBUFFORCE/SO_SNDBUFFORCE only if SO_RCVBUF/SO_SNDBUF fails
Both SO_SNDBUFFORCE and SO_RCVBUFFORCE requires capability 'net_admin'.

If this capability is not granted to the service the first attempt to increase
the recv/snd buffers (via sd_notify()) with SO_RCVBUFFORCE/SO_SNDBUFFORCE will
fail, even if the requested size is lower than the limit enforced by the
kernel.

If apparmor is used, the DENIED logs for net_admin will show up. These log
entries are seen as red warning light, because they could indicate that a
program has been hacked and tries to compromise the system.

It would be nicer if they can be avoided without giving services (relying on
sd_notify) net_admin capability or dropping DENIED logs for all such services
via their apparmor profile.

I'm not sure if sd_notify really needs to forcibly increase the buffer sizes,
but at least if the requested size is below the kernel limit, the capability
(hence the log entries) should be avoided.

Hence let's first ask politely for increasing the buffers and only if it fails
then ignore the kernel limit if we have sufficient privileges.
2018-09-14 13:00:38 +02:00
Zbigniew Jędrzejewski-Szmek 1327f272d3
Merge pull request #9920 from yuwata/udev-cleanup-4
udev: drop unused udev structs and use verbs in udevadm
2018-09-14 10:05:59 +02:00
Zbigniew Jędrzejewski-Szmek 730d989acc tests: add a helper function to skip with errno 2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 8b81c382c3 test-condition: make function return void
We don't look at the result anyway.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 317bb217d3 tests: add helper to unify skipping a test and exiting 2018-09-14 09:29:57 +02:00
Harshit Jain 8c63965c20 man: fix typo (#10084)
fixes #10083
2018-09-14 16:04:10 +09:00
Alan Jenkins 473b9c683a user-runtime-dir@.service: don't stop on runlevel switch (#10079)
Followup to commit 13cf422e04b7 ("user@.service: don't kill user manager at runlevel switch")

I think there's a general rule that units with `StopWhenUnneeded=yes` need
`IgnoreOnIsolate=yes`...  But it doesn't apply to `suspend.target` and friends.
`printer.target` and friends break on isolate even if we apply the rule[1].
That just leaves `graphical-session.target`, which is a user service.
"isolate" is *mostly* a weird attempt to emulate runlevels, so I decided
not to worry about it for user services.

[1] https://github.com/systemd/systemd/issues/6505#issuecomment-320644819
2018-09-14 12:11:57 +09:00
killermoehre a8a273743f replace https://github.com/systemd/systemd/blob/master/doc/* with https://github.com/systemd/systemd/blob/master/docs/* to point to proper documentation 2018-09-13 22:12:38 +02:00
Thomas Blume 8c1f04352b user@.service: don't kill user manager at runlevel switch
Loggin in as root user and then switching the runlevel results in a
stop of the user manager, even though the user ist still logged in.
That leaves a broken user session.

Adding "IgnoreOnIsolate=true" to user@.service fixes this.
2018-09-13 12:18:27 +02:00
Yu Watanabe 2b8b1056d9 test: unset $XDG_{CONFIG,DATA}_DIRS
When $XDG_DATA_DIRS is unset, then, the default value
'/usr/local/share:/usr/share' is used.
When $XDG_DATA_DIRS contain the default paths but the order
is inverted: '/usr/share:/usr/local/share', then test-path-lookup fails.

Fixes #10002.
2018-09-13 12:13:54 +02:00
Zbigniew Jędrzejewski-Szmek c1cd674357 meson: drop some unneeded parens 2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 3b2bdd625a meson: always allow compilation of tests binaries 2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 15c5594bec NEWS: remove repeated "slightly" 2018-09-13 12:07:34 +02:00
Yu Watanabe fd1939fbe7 meson: do not build tests by default when '-Dtests=false'
[zj: it is still possible to build tests explicitly by calling
     ninja -C build test-name. This way we have full flexibility.]
2018-09-13 12:07:34 +02:00
Yu Watanabe 964bc0ad60 test: log when skipping tests in more cases
Follow-up for the previous commit.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 08d541ca06 test: when skipping tests, always print something
It is quite confusing if the test "fails" without printing anything at all.

A typo in an 'if' statement is also fixed.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 938be08926 meson: disable _all_ tests when -Dtests=false
Back in 08318a2c5a, value "false" was enabled for
'-Dtests=', but various tests were not conditionalized properly. So even with
-Dtests=false -Dslow-tests=false we'd run 120 tests. Let's make this consistent.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek d3da291eb0 meson: disable "slow tests" too when tests are generally disabled
We would have a strange situation where after setting -Dslow-tests=true -Dtests=false
we'd get mostly the slow tests (plus some other ones which I'll fix in
subsequent commit). Let's simplify things by making -Dtests=false just
disable those tests too.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek f57d003cb6 test-barrier: just make this a slow test
test-barrier was using a custom mechanism to skip itself. Let's
just follow the normal scheme.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 0cf29baac0 tests: centralize check for slow tests 2018-09-13 12:07:27 +02:00
Yu Watanabe d491e65e74 man: document RUNTIME_DIRECTORY= or friends 2018-09-13 17:02:58 +09:00
Yu Watanabe 6088662d57 test-execute: add tests for $RUNTIME_DIRECTORY= or friends 2018-09-13 17:02:58 +09:00
Yu Watanabe fb2042dd55 core: add new environment variable $RUNTIME_DIRECTORY= or friends
The variable is generated from RuntimeDirectory= or friends.
If multiple directories are set, then they are concatenated with
the separator ':'.
2018-09-13 17:02:58 +09:00
Yu Watanabe a2917d3d2a test: replace swear words by 'hoge' 2018-09-13 17:02:58 +09:00
Yu Watanabe 474a595af7 test: add tests for strv_join_prefix() 2018-09-13 17:02:58 +09:00
Yu Watanabe 2b9a7d2e96 strv: introduce strv_join_prefix() 2018-09-13 17:02:58 +09:00
Yu Watanabe 7c1cb6f198 core: add one more assert() 2018-09-13 17:02:58 +09:00
Yu Watanabe 76a9460d44 core: fix assert() about number of built environment variables
Follow-up for 4b58153dd2 and
fd63e712b2.
2018-09-13 17:02:58 +09:00
Lennart Poettering c633b0a642 update TODO 2018-09-12 21:39:14 +02:00
afg 27b620b7db nspawn: use copy-static if systemd-resolved is up and image is writable 2018-09-12 20:48:21 +02:00
Lennart Poettering b0b3ba69c0
Merge pull request #10061 from xnox/fix-logindless-scheduled-shutdown
Fix logindless scheduled shutdown
2018-09-12 20:45:31 +02:00
Lennart Poettering b2b9edd4d1
Merge pull request #10060 from yuwata/property-take-value
bus-util: make --property= optionaly take value
2018-09-12 20:17:53 +02:00
Filipe Brandenburger 49cdae63d1 test: use ${builddir}/systemd-runtest.env for $SYSTEMD_CATALOG_DIR
This makes it so that tests no longer need to know the absolute paths to the
source and build dirs, instead using the systemd-runtest.env file to get these
paths when running from the build tree.

Confirmed that test-catalog works on `ninja test`, when called standalone and
also when the environment file is not present, in which case it will use the
installed location under /usr/lib/systemd/catalog.

The location can now also be overridden for this test by setting the
$SYSTEMD_CATALOG_DIR environment variable.
2018-09-12 09:49:03 -07:00
Filipe Brandenburger e2d413707f test: use ${builddir}/systemd-runtest.env to set $SYSTEMD_TEST_DATA
This simplifies get_testdata_dir() to simply checking for an environment
variable, with an additional function to locate a systemd-runtest.env file in
the same directory as the test binary and reading environment variable
assignments from that file if it exists.

This makes it possible to:
- Run `ninja test` from the build dir and have it use ${srcdir}/test for
  test unit definitions.
- Run a test directly, such as `build/test-execute` and have it locate
  them correctly.
- Run installed tests (from systemd-tests package) and locate the test
  units in the installed location (/usr/lib/systemd/tests/testdata), in
  which case the absence of the systemd-runtest.env file will have
  get_testdata_dir() use the installed location hardcoded into the
  binaries.

Explicit setting of $SYSTEMD_TEST_DATA still overrides the contents of
systemd-runtest.env.
2018-09-12 09:49:03 -07:00
Filipe Brandenburger 55890a40c3 test: remove support for suffix in get_testdata_dir()
Instead, use path_join() in callers wherever needed.
2018-09-12 09:49:03 -07:00
Zbigniew Jędrzejewski-Szmek 87ead8e298 Set theme jekyll-theme-slate 2018-09-12 11:51:27 +02:00
Yu Watanabe f28255e2d5 bash-completion: systemctl: re-implement __filter_units_by_properties()
This also unifies __filter_units_by_property() and
__filter_units_by_properties(), and makes completion for 'restart',
'reload' or 'stop' show more candidates.
2018-09-12 14:17:22 +09:00
Yu Watanabe eda193578e bus-util: make --property= optionally take value 2018-09-12 12:11:25 +09:00