Commit Graph

1674 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 7f546026ab Introduce free_and_strndup and use it in bus-message.c
v2: fix error in free_and_strndup()

When the orignal and copied message were the same, but shorter than specified
length l, memory read past the end of the buffer would be performed. A test
case is included: a string that had an embedded NUL ("q\0") is used to replace
"q".

v3: Fix one more bug in free_and_strndup and add tests.

v4: Some style fixed based on review, one more use of free_and_replace, and
make the tests more comprehensive.
2018-10-02 11:42:45 +02:00
Yu Watanabe 5c434af721
Merge pull request #10218 from keszybz/export-sd-device-hwdb
Export functions in sd-device and sd-hwdb
2018-10-01 19:45:55 +02:00
Zbigniew Jędrzejewski-Szmek 4dd73b883f test-sd-hwdb: skip tests if hwdb cannot be opened 2018-10-01 15:22:55 +02:00
Zbigniew Jędrzejewski-Szmek 3bdce0eac0
Merge pull request #10138 from yuwata/test-check-container
test: skip several tests when running in container
2018-10-01 10:09:54 +02:00
Zbigniew Jędrzejewski-Szmek ca7a9afc7e test-sd-hwdb: add a simple test for export sd-hwdb functions 2018-09-30 20:39:02 +02:00
Zbigniew Jędrzejewski-Szmek b6de93096e
Merge pull request #10173 from poettering/sd-boot-utf
the utf8.c changes from PR #9437 (i.e. the boot counting PR)
2018-09-27 08:21:20 +02:00
Lennart Poettering ee8d493cbd
Merge pull request #10158 from keszybz/seccomp-log-tightening
Seccomp log tightening
2018-09-26 15:56:32 +02:00
Lennart Poettering 80b0a59729 utf8: add utf8_to_utf16() helper 2018-09-25 15:57:47 +02:00
Lennart Poettering 7c428bb5d5
Merge pull request #10059 from yuwata/env-exec-directory
core: introduce $RUNTIME_DIRECTORY= or friends
2018-09-25 12:34:30 +02:00
Zbigniew Jędrzejewski-Szmek b54f36c604 seccomp: reduce logging about failure to add syscall to seccomp
Our logs are full of:
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldstat() / -10037, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call get_thread_area() / -10076, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call set_thread_area() / -10079, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldfstat() / -10034, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldolduname() / -10036, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldlstat() / -10035, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call waitpid() / -10073, ignoring: Numerical argument out of domain
...
This is pointless and makes debug logs hard to read. Let's keep the logs
in test code, but disable it in nspawn and pid1. This is done through a function
parameter because those functions operate recursively and it's not possible to
make the caller to log meaningfully.


There should be no functional change, except the skipped debug logs.
2018-09-24 17:21:09 +02:00
Zbigniew Jędrzejewski-Szmek f09da7ccbc test-seccomp: log function names
Various tests produce similar output, and the function names make it
easier to see where the output is generated.
2018-09-24 17:21:09 +02:00
Zbigniew Jędrzejewski-Szmek 23e12f8e6c test-seccomp: move two similar tests closer 2018-09-24 17:19:11 +02:00
Dimitri John Ledkov 78ec1bb436 exec-util: in execute_directories, support initial exec environment 2018-09-24 13:40:10 +01:00
Yu Watanabe feae122f3e test-udev: use LOG_REALM_UDEV
Otherwise, even if SYSTEMD_LOG_LEVEL=debug is specified, the test does
not show most debug messages.
2018-09-22 09:56:40 +02:00
Yu Watanabe 642d1a6d6e test-execute: skip several tests when running in container 2018-09-21 00:45:00 +09:00
Yu Watanabe 738c74d7b1 test-execute: also check python3 is installed or not 2018-09-21 00:45:00 +09:00
Yu Watanabe 767eab4750 test-process-util: skip several verifications when running in unprivileged container 2018-09-21 00:44:29 +09:00
Yu Watanabe 9590065f37 test-fs-util: skip some tests when running in unprivileged container 2018-09-21 00:44:29 +09:00
Yu Watanabe cd90ec7544 test-seccomp: add log messages when skipping tests 2018-09-21 00:32:44 +09:00
Yu Watanabe 92f6a1b6bc test-process-util: logs something when skipping tests 2018-09-21 00:32:36 +09:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Yu Watanabe 0ac4f1a513
Merge pull request #10070 from keszybz/test-reporting
Test reporting improvements
2018-09-15 15:55:15 +09: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
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
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 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 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
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 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
Yu Watanabe d9b6baa699 test: make test-catalog relocatable
Fixes #10045.
2018-09-11 09:19:36 +09:00
Yu Watanabe 2024ed616e udev: drop unused udev struct 2018-09-10 18:27:36 +09:00
Dongsu Park 21224070e8 importd, basic/string-util: use case-insensitive comparison for HTTP headers
According to RFC2616[1], HTTP header names are case-insensitive. So
it's totally valid to have a header starting with either `Date:` or
`date:`.

However, when systemd-importd pulls an image from an HTTP server, it
parses HTTP headers by comparing header names as-is, without any
conversion. That causes failures when some HTTP servers return headers
with different combinations of upper-/lower-cases.

An example:
https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_developer_container.bin.bz2 returns `Etag: "pe89so9oir60"`,
while https://alpha.release.core-os.net/amd64-usr/current/coreos_developer_container.bin.bz2
returns `ETag: "f03372edea9a1e7232e282c346099857"`.
Since systemd-importd expects to see `ETag`, the etag for the Container Linux image
is correctly interpreted as a part of the hidden file name.
However, it cannot parse etag for Flatcar Linux, so the etag the Flatcar Linux image
is not appended to the hidden file name.

```
$ sudo ls -al /var/lib/machines/
-r--r--r--  1 root root 3303014400 Aug 21 20:07 '.raw-https:\x2f\x2falpha\x2erelease\x2ecore-os\x2enet\x2famd64-usr\x2fcurrent\x2fcoreos_developer_container\x2ebin\x2ebz2.\x22f03372edea9a1e7232e282c346099857\x22.raw'
-r--r--r--  1 root root 3303014400 Aug 17 06:15 '.raw-https:\x2f\x2falpha\x2erelease\x2eflatcar-linux\x2enet\x2famd64-usr\x2fcurrent\x2fflatcar_developer_container\x2ebin\x2ebz2.raw'
```

As a result, when the Flatcar image is removed and downloaded again,
systemd-importd is not able to determine if the file has been already
downloaded, so it always download it again. Then it fails to rename it
to an expected name, because there's already a hidden file.

To fix this issue, let's introduce a new helper function
`memory_startswith_no_case()`, which compares memory regions in a
case-insensitive way. Use this function in `curl_header_strdup()`.

See also https://github.com/kinvolk/kube-spawn/issues/304

[1]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
2018-09-03 22:59:27 +02:00
Yu Watanabe efa1463693 test: fix a memleak
Follow-up for #9901.

Fixes #9968.
2018-08-29 17:45:37 +02:00
Ruixin Bao 4c9565eea5 install: allow instantiated units to be enabled via presets
This patch implements https://github.com/systemd/systemd/issues/9421.

The .preset file now is able to take a rule in the format of:(e.g)
enable foo@.service bar0 bar1 bar2

In the above example, when preset-all is called, all three instances of
foo@bar0.service, foo@bar1.service and foo@bar2.service will be enabled.

When preset is called on a single service(e.g: foo@bar1.service), only
the mentioned one(foo@bar1.service) will be enabled.

Tests are added for future regression.
2018-08-27 23:56:24 +00:00
Yu Watanabe 593a5213ce
Merge pull request #9917 from keszybz/cleanups
Some unrelated fixups for recent PRs
2018-08-24 10:43:41 +09:00
Zbigniew Jędrzejewski-Szmek e6a2feb57d
Merge pull request #8135 from shawnl/arg_host
sd-bus: rework host handling
2018-08-23 13:46:54 +02:00
Zbigniew Jędrzejewski-Szmek 181c4ba750 test-socket-util: avoid "memleak" reported by valgrind
valgrind reports the allocation done in the short-lived child as a leak.
Let's restructure the code to avoid this.
2018-08-23 11:30:57 +02:00
Yu Watanabe 152d0efa2b udev: move udev cleanup functions from udev-util.h to udev.h 2018-08-23 04:57:39 +09:00
Lennart Poettering 97fa202a61 random-util: use RDRAND for randomness if the kernel doesn't want to give us any
Pretty much all intel cpus have had RDRAND in a long time. While
CPU-internal RNG are widely not trusted, for seeding hash tables it's
perfectly OK to use: we don't high quality entropy in that case, hence
let's use it.

This is only hooked up with 'high_quality_required' is false. If we
require high quality entropy the kernel is the only source we should
use.
2018-08-21 20:13:32 +02:00
Zbigniew Jędrzejewski-Szmek 0566668016
Merge pull request #9712 from filbranden/socket1
socket-util: Introduce send_one_fd_iov() and receive_one_fd_iov()
2018-08-21 19:45:44 +02:00
Zbigniew Jędrzejewski-Szmek 7692fed98b
Merge pull request #9783 from poettering/get-user-creds-flags
beef up get_user_creds() a bit and other improvements
2018-08-21 10:09:33 +02:00
Lennart Poettering fafff8f1ff user-util: rework get_user_creds()
Let's fold get_user_creds_clean() into get_user_creds(), and introduce a
flags argument for it to select "clean" behaviour. This flags parameter
also learns to other new flags:

- USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for
  root/nobody are only synthesized as fallback. Normally, the synthesized
  records take precedence over what is in the user database.  With this
  flag set this is reversed, and the user database takes precedence, and
  the synthesized records are only used if they are missing there. This
  flag should be set in cases where doing NSS is deemed safe, and where
  there's interest in knowing the correct shell, for example if the
  admin changed root's shell to zsh or suchlike.

- USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by
  numeric value, and there's no user/group record for it accept it
  anyway. This allows us to fix #9767

This then also ports all users to set the most appropriate flags.

Fixes: #9767

[zj: remove one isempty() call]
2018-08-20 15:58:21 +02:00