1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-13 17:18:18 +03:00
Commit Graph

64648 Commits

Author SHA1 Message Date
Emanuele Giuseppe Esposito
e673c5c2d9 ukify: typo in doc and print when package is missing
If a package is missing, a subprocess is started with None as
command argument. Error raised by subprocess is therefore not helpful
at all to understand what needs to be done to fix that error.

Also fix doc since systemd-stub will look for .cmdline files, and not
.cmdline.efi files.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2023-05-10 09:18:25 -04:00
Frantisek Sumsal
33dff897b9 test: merge TEST-11-ISSUE-3166 into TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
a8faac7dae test: merge TEST-10-ISSUE-2467 with TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
4966a31ba3 test: merge TEST-09-ISSUE-2691 into TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
cd62ba42a4 test: merge TEST-08-ISSUE-2730 into TEST-07-PID1 2023-05-10 14:29:38 +02:00
Yu Watanabe
39a39f18f2 udev: do not set ID_PATH and by-path symlink for nvmf disks
Prompted by #27391.
2023-05-10 19:42:49 +08:00
Frantisek Sumsal
09c033a276 test: rename TEST-07-ISSUE-1981 to TEST-07-PID1 2023-05-10 12:38:57 +02:00
Yu Watanabe
6112c86139 core: replace hashmap_get() with hashmap_contains() where appropriate 2023-05-10 15:06:44 +09:00
Yu Watanabe
735f0645db core: drop unused argument 2023-05-10 15:06:39 +09:00
Yu Watanabe
fcd7e0b7ed core: several cleanups for job_get_timeout()
- add missing assertion,
- rename the argument for storing result,
- always initialize result on success.
2023-05-10 15:06:39 +09:00
Yu Watanabe
bc52801034 tree-wide: drop _pure_ attribute from non-pure functions
Prompted by #27595.
Follow-ups for 6723c28f36.
2023-05-10 15:06:24 +09:00
Sam James
eb29296937 dirent: conditionalize dirent assert based on dirent64 existence
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: https://github.com/systemd/systemd/pull/25809
2023-05-10 15:05:18 +09:00
Mike Yuan
8707dcdf3b network/tc: rename settings in log messages too
Follow-up for c03ef420fa
2023-05-10 14:21:28 +09:00
Xi Ruoyao
6723c28f36 sd-bus: bus_message_type_from_string is not pure
GCC document [1] says:

    The pure attribute prohibits a function from modifying the state
    of the program that is observable by means other than inspecting
    the function’s return value.

And there is an example:

    `int hash (char *) __attribute__ ((pure));`
    ... Even though hash takes a non-const pointer argument it must
    not modify the array it points to, ...

But we are modifying the object pointed to by the pointer u, which is
clearly a violation of the semantic of pure.

With -ftrivial-auto-var-init (enabled by -Dmode=release), on some
targets (GCC 12.2 on AArch64 and GCC 13.1 on x86_64) performs an
optimization: as the variable "u" in bus_match_parse has been
zero-initialized (by the -ftrivial-auto-var-init option) and never
modified (because a "pure" bus_message_type_from_string is not allowed
to modify it), "u" will be always 0.

Then 0 is used to initialize .value_u8 field of struct
bus_match_component.  This then causes a infinite event loop, so
"systemctl restart" never stops, and pam_systemd timeouts communicating
with logind, etc.

So we should remove the "pure" attribute here.

Fixes #26395.

[1]:https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
2023-05-10 14:21:01 +09:00
Yu Watanabe
18449960b9
Merge pull request #27597 from mrc0mmand/more-test-shenanigans
test: slightly extend systemd-cryptenroll coverage
2023-05-10 08:16:29 +09:00
Michal Sekletar
aaf7b0e411 core/mount: replace invalid UTF-8 code points in "what" and "options"
Previously, these strings were copied w/o any modification. However, if
mount table contained e.g. remote fs mount like NFS or CIFS that was
mounted from server running with non UTF-8 locale then those strings
might have contained some non UTF-8 characters.

If then client asked about status of such mount unit we tried to forward
these non UTF-8 strings over D-Bus. That is the violation of the
protocol and we ended up kicked from the bus.
2023-05-10 00:01:32 +01:00
Frantisek Sumsal
a9fe7f66e8 test: slightly extend systemd-cryptenroll coverage 2023-05-09 22:47:42 +02:00
Frantisek Sumsal
0e43ab6d24 cryptenroll: fix an assertion with weak passwords
Passing 0 to log_xxx_errno() leads to an assertion, so let's not do that:

$ NEWPASSWORD="" build-san/systemd-cryptenroll --unlock-key-file=/tmp/password --password "$img"
/tmp/password has 0644 mode that is too permissive, please adjust the ownership and access mode.
Assertion '(_error) != 0' failed at src/cryptenroll/cryptenroll-password.c:164, function enroll_password(). Aborting.
Aborted (core dumped)
2023-05-09 22:17:15 +02:00
Frantisek Sumsal
920eb35db9 test: TEST-70-TPM2 cleanup
No functional changes.
2023-05-09 21:18:36 +02:00
Frantisek Sumsal
b6869359e6 test: add coverage for #27533
Issue: https://github.com/systemd/systemd/issues/27533
Fix: https://github.com/systemd/systemd/pull/27553
2023-05-09 19:59:13 +02:00
Frantisek Sumsal
5e8656e101 test: discard kill's output 2023-05-09 19:55:04 +02:00
Frantisek Sumsal
539af5c441 test: merge unit file related tests into TEST-23-UNIT-FILE
Rename TEST-23-TYPE-EXEC to TEST-23-UNIT-FILE and merge it with
following tests:
  - TEST-37-RUNTIMEDIRECTORYPRESERV
  - TEST-40-EXEC-COMMAND-EX
  - TEST-41-ONESHOT-RESTART
  - TEST-42-EXECSTOPPOST
  - TEST-57-ONSUCCESS-UPHOLD
2023-05-10 02:39:12 +09:00
Daan De Meyer
97211510b0 units: Add CAP_NET_ADMIN condition to systemd-networkd-wait-online@.service as well
It was added to CAP_NET_ADMIN but we forgot to add it to the template
service as well.
2023-05-09 17:59:55 +02:00
Yu Watanabe
251ca88230 sd-dhcp-client: client ID always has non-zero data
Follow-up for f04c991a2f.
Fixes CID#1510978.
2023-05-09 14:41:55 +01:00
Yu Watanabe
c093bfe0ad
Merge pull request #27534 from keszybz/deperlify
Rewrite udev-test.pl in Python
2023-05-09 18:06:51 +09:00
Yu Watanabe
9695b0c01b static-destruct: introduce STATIC_ARRAY_DESTRUCTOR_REGISTER() 2023-05-09 17:53:42 +09:00
Yu Watanabe
555ead8985 static-destruct: several cleanups
No functional changes, preparation for later commits.
2023-05-09 17:53:42 +09:00
Yu Watanabe
3facdc7da8 memory-util: make ArrayCleanup passed to array_cleanup() const
Should not change any behavior, preparation for later commits.
2023-05-09 17:53:42 +09:00
Zbigniew Jędrzejewski-Szmek
98e2089f1b mkosi,ci: do not install perl 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
711169905e test: use sed and grep instead of perl
This gets rid of the all-but-one remaining uses of perl. I tested the new code
on my machine, so I'm fairly confident that it works as expected.

install_iscsi() has one majestic perl invocation, but we can't get rid of it
easily: it extends the code of tgt-admin to print some list of files. Obviously
this only works because tgt-admin is written in perl, and perl will be installed
if tgt-admin is installed. install_iscsi() is used in TEST-64-UDEV-STORAGE
conditionally if tgtadm is installed, so this can stay as is.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
e11c9ba7bf tools/oss-fuzz: s/perl/awk/
The pattern is not exactly the same, but I don't think we need to
be super-precise here.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
b370f050f8 test-execute: use bash instead of perl
I think this is easier to grok too.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
21ec66420a test-udev: skip test on python3.6 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
7c0d79131b README: require python >= 3.7, clean up module descriptions
libpython was added in 2cc86f094a, it seems
because of python-systemd module that we built. But libpython by itself
is not enough for actual python programs, and now we also list python itself,
so let's drop libpython from the list.

meson requires >= 3.7. We have CI that runs on CentOS8 with Python 3.6, but
let's not provide official support for an EOL Python version. Individual
distributions can provide backports, but we don't need to mention that in
the user-facing docs. According to [1], 3.7 is on life support and 3.6 is EOL.

[1] https://devguide.python.org/versions/
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
e76ff43236 tools/check-includes: compat with Python 3.7
I thought that 3.8 is enough. But Centos8 CI chokes on the walrus.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
dcbbc7cef5 test/run-unit-tests, TEST-02: skip tests where the interpeter is not installed
When the interpeter is missing, we get an exit code of 127. Let's treat those
tests as skipped too. If we could run the test far enough so that it could do
the check itself, it would return 77 anyway.

$ test/asdf; echo $?
exec: Failed to execute process 'test/asdf': The file specified the interpreter '/bin/asdf', which is not an executable command.
127
$ test/asdf; echo $?
/usr/bin/env: ‘/bin/asdf’: No such file or directory
127

This should resolve the problem that TEST-02 fails or Debian's 'unit-tests' fail
when python3 is not installed. Installing python3 via the mechanism that is
used to construct TEST images, i.e. the dracut dependency chasing scheme, would
be a lot of work for python with its modules in multiple locations and hundreds
of little files. So I think it OK to just skip the test there, and also in
other cases where python is not available.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
0454cf05d3 test: rework how udev-test is invoked
As part of the build, we would populate build/test/sys/ using
sys-script.py, and then udev-test.p[ly] would create a tmpfs instance
on build/test/tmpfs and copy the sys tree to build/test/tmpfs/sys.

Also, we had udev-test.p[ly] which called test-udev. test-udev was
marked as a manual test and installed, but neither udev-test.p[ly] or
sys-script.py were.

test-udev is renamed to udev-rule-runner, which reduces confusion and
frees up the test-udev name. udev-test.py is renamed to test-udev.py.
All three files are now installed.

test-udev.py is modified to internally call sys-script.py to set up the
sys tree. Copying and creating it from scratch should take the same
amount of time. We avoid having a magic directory, everything is now
done underneath a temporary directory.

test-udev.py is now a normal installed test, and run-unit-tests.py will
pick it up. When test-udev.py is invoked from meson, the path to
udev-rule-runner is passed via envvar; when it is invoked via
run-unit-tests.py or directly, it looks for udev-rule-runner in a relative
path.

The goal of this whole change is to let Debian drop the 'udev' test.
It called sys-script.py and udev-test.pl from the source directory and
had to recreate a bunch of the logic. Now test-udev.py will now be called
via 'upstream'.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
09ea351b6f test: drop udev-test.pl 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
f2c02d232e test: rewrite udev-test.pl in Python
I tried to keep this a 1:1 rewrite with the same field names.
Nevertheless, some changes were made:
- exp_add_error and exp_rem_error are dropped. Those fields meant that
  "./test-udev add <devpath>" actually succeeded, but symlinks were not
  created, and exp_links was ignored and could contain bogus content.
  Instead, exp_links and not_exp_links are adjusted to not contain
  garbage and the tests check that "./test-udev add" succeeds and that
  the links are as expected from exp_links and not_exp_links.
- cleanup was only used in one rule, and that rule was expected to fail,
  so cleanup wasn't actually necessary. So the cleanup field and the
  logic to call cleanup from individual tests is removed.
- a bunch of fields were set, but didn't seem to be connected to any
  implementation: not_exp_name, not_exp_test.
  e62acc3159 did a rewrite of some of the
  tests and it seems that not_exp_test was added by mistake and
  not_exp_name was left behind by mistake.
  In Python, the field list is declared in the class, so it's harder to
  assign an unused attribute. Those uses were converted to not_exp_links.
- in most rules, r"""…""" is used, so that escaping is not necessary.
- the logic to generate devices was only used in one place, and the
  generator function also had provisions to handle arguments that were
  never given. all_block_devs() is made much simpler.
- Descriptions that started with a capital letter were shortened
  and lowercased.
- no special test case counting is done. pytest just counts the cases
  (Rules objects).
- the output for failures is also removed. If something goes wrong, the
  user can use pytest --pdb or such to debug the issue.
- perl version used a semaphore to manage udev runners, and would fork,
  optionally wait a bit, and then start the runner. In the python
  version, we just spawn them all and wait for them to exit. It's not
  very convenient to call fork() from python, so instead the runner
  was modified (in previous commit) to wait.

The test can be called as:
  (cd build && sudo pytest -v ../test/udev-test.py)
  sudo meson test -C build udev-test.py -v

I think this generally provides functionality that is close to the perl
version. It seems some of the checks are now more fully implemented.
Support for strace/gdb/valgrind is missing.

Runtime goes down: 8.36 s → 5.78 s.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
495658d43c check-includes: print path relative to project root
Instead of /home/zbyszek/src/systemd-work/build/../src/xdg-autostart-generator/xdg-autostart-service.h:11,
print just src/xdg-autostart-generator/xdg-autostart-service.h:11.

This is a bit annoying that this requires so much verbosity, but the output
with the full names was too annoying.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
b0bd2ae8b3 meson: fix indentation 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
6089235829 meson: add check-includes test to the test suite
Let's just call it always. It is quite fast (meson says 0.12 s).
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
ba9ca60a88 meson: include .cc files in tags too
We only have one, but it seems reasonable to not exclude it.
Result tested with emacs.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
c4a090d60e Rewrite check-includes.pl in python 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
083e2ba445 pid1: drop duplicate include 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
7d3d147c4a test_ukify: print message when skipping whole test file 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
fb5578b3c3 test-udev: add an optional timeout argument
The tests wants to call some workers with a delay. This implements the delay
directly in test-udev so that the caller can be simplified.

Note that the argument is to be used by the other test file, so this is
purposefully implemented in a simple way.
2023-05-09 08:10:20 +02:00
Yu Watanabe
d94027ad16 bus-util: drop unnecessary continue 2023-05-09 08:08:53 +09:00
Yu Watanabe
d421db6e8b units: add/fix Documentation= about bus interface 2023-05-09 06:10:23 +09:00
Daan De Meyer
d0287dc1d7 test-journal-verify: Use a more thorough machine ID check
Let's not only check if the file exists but also check if it contains
a valid machine ID.
2023-05-09 06:09:43 +09:00