Martin Wilck [Tue, 24 Apr 2018 08:50:24 +0000 (10:50 +0200)]
test/udev-test.pl: test correctness of symlink targets
Test if symlinks are created correctly by comparing the symlink
targets to the devnode path. This implies (for the symlink) that
major/minor numbers and permissions are correct, as we have tested
that on the devnode already.
(cherry picked from commit
997683c8f152e1c139a7ce537de81a0aeae4627f)
Related: #
1642728
Martin Wilck [Tue, 24 Apr 2018 07:38:26 +0000 (09:38 +0200)]
test/udev-test.pl: use computed devnode name
More often than not, the created devnode is the basename of the
sysfs entry. The "devnode" device may be used to override the
auto-detected node name.
Permissions and major/minor number are now verified on the devnode
itself, not on symlinks.
For those tests where exp_name is set to the computed devnode name,
the explicit "exp_name" can be removed. "exp_name" is only required for
symlinks.
This allows separate testing for devnodes and symlinks an a follow-up
patch.
(cherry picked from commit
f0dccf01a7b4e72278e14effd74782ea83d0a73b)
Related: #
1642728
Martin Wilck [Mon, 23 Apr 2018 19:59:05 +0000 (21:59 +0200)]
test/udev-test.pl: allow concurrent additions and removals
Allow testing cases where multiple devices are added and removed
simultaneously. Tests are started as synchronously as possible using a
semaphore, in order to test possible race conditions. If this isn't desired,
the test parameter "sleep_us" can be set to the number of microseconds to wait
between udev invocations.
(cherry picked from commit
09a4062d70b3a10d022e40066e2adf09df05bbbc)
Related: #
1642728
Martin Wilck [Mon, 23 Apr 2018 19:58:12 +0000 (21:58 +0200)]
test/udev-test.pl: create rules only once
It's not necessary to write the rules for every udev run, as we
now may have many (rather than just 2) per test.
(cherry picked from commit
af7ee3eae689f9c31b49ea13758ad9c901918ce3)
Related: #
1642728
Martin Wilck [Fri, 20 Apr 2018 20:38:30 +0000 (22:38 +0200)]
test/udev-test.pl: allow multiple devices per test
Allow testing cases where multiple devices are added and removed.
This implies a change of the data structure: every test allows
for multiple devices to be added, and "exp_name" etc. are now properties
of the device, not of the test.
(cherry picked from commit
255c05b72455dcad1b5552d12a813b31f68201a7)
Related: #
1642728
Zbigniew Jędrzejewski-Szmek [Fri, 4 Sep 2020 16:09:20 +0000 (18:09 +0200)]
udev-test: do not rely on "mail" group being defined
"audio" should be there, at least we declare it. "mail" nowadays is less
likely to exist than in the past.
Fixes one of the items in #16942.
(cherry picked from commit
a9030b81c154c3ec92227d04cad6b13cc1125608)
Related: #
1642728
gaoyi [Sun, 12 Jul 2020 07:27:45 +0000 (03:27 -0400)]
test: add test case for multi matches when use "||"
Signed-off-by: gaoyi <ymuemc@163.com>
(cherry picked from commit
0d3a8bc7ebd76591e14f7098b4266fd2065ac4db)
Related: #
1642728
Yu Watanabe [Wed, 11 Sep 2019 00:06:15 +0000 (09:06 +0900)]
test: add test cases for empty string match
(cherry picked from commit
48d26c90852c22ec94be961f5fbdcf462bb9a6e8)
Related: #
1642728
Dan Streetman [Fri, 5 Jul 2019 15:24:55 +0000 (11:24 -0400)]
test/udev-test.pl: cleanup if skipping test
In Ubuntu CI, udev-test.pl is run from the debian/test/udev script,
in a test dir created for it; but udev-test.pl setup mounts a
dir, so if it doesn't cleanup/unmount before exiting, the test dir
autopkgtest created for it can't be removed, and autopkgtest
aborts the entire test suite, for example this output (from a
test run inside an armhf container):
autopkgtest [12:45:36]: test udev: [-----------------------
umount: test/tmpfs: no mount point specified.
mknod: test/tmpfs/dev/null: Operation not permitted
unable to create test/tmpfs/dev/null at ./udev-test.pl line 1611.
Failed to set up the environment, skipping the test at ./udev-test.pl line 1731.
autopkgtest [12:45:41]: test udev: -----------------------]
autopkgtest [12:45:44]: test udev: - - - - - - - - - - results - - - - - - - - - -
udev FAIL non-zero exit status 77
rm: cannot remove '/tmp/autopkgtest.ocPFA6/autopkgtest_tmp/test/tmpfs': Device or resource busy
autopkgtest [12:46:22]: ERROR: "rm -rf /tmp/autopkgtest.ocPFA6/udev-artifacts /tmp/autopkgtest.ocPFA6/autopkgtest_tmp" failed with stderr "rm:
(cherry picked from commit
abb9cc50afb3949c442849f43301fb33578f3888)
Related: #
1642728
Yu Watanabe [Thu, 21 Feb 2019 09:04:12 +0000 (18:04 +0900)]
test-udev: fix alignment and drop unnecessary white spaces
(cherry picked from commit
3dd2d524141d09d57443ae339e1a77d7ce40f847)
Related: #
1642728
Yu Watanabe [Thu, 21 Feb 2019 09:03:32 +0000 (18:03 +0900)]
test-udev: add more tests for line continuation
(cherry picked from commit
84a0819c9d89a2ddb195a5d975ae1fd5c62fde3c)
Related: #
1642728
Yu Watanabe [Tue, 19 Feb 2019 00:22:45 +0000 (09:22 +0900)]
test-udev: add more tests for line continuations and comments
(cherry picked from commit
d35976c670b0e5c2d4081b781e5af88c0689ff00)
Related: #
1642728
Yu Watanabe [Tue, 19 Feb 2019 00:21:42 +0000 (09:21 +0900)]
test-udev: use proper semantics for too long line with continuation
Follow-up for
1e797cf596df50a6bdd8cbf8e9b2467a3a934171.
(cherry picked from commit
e37a5d90b0c624b95f8d0c3400288fec60417ec4)
Related: #
1642728
Yu Watanabe [Mon, 18 Feb 2019 01:38:29 +0000 (10:38 +0900)]
test-udev: add a testcase of too long line
(cherry picked from commit
1e797cf596df50a6bdd8cbf8e9b2467a3a934171)
Related: #
1642728
Alexey Bogdanenko [Tue, 11 Dec 2018 13:55:34 +0000 (16:55 +0300)]
udev-test: check if permitted to create block device nodes
(cherry picked from commit
dbfbc6c4e34366033cb340e8b0c3cbca683ff6f5)
Related: #
1642728
Alexey Bogdanenko [Sat, 8 Dec 2018 12:35:30 +0000 (15:35 +0300)]
udev-test: fix missing directory test/run
Fixes the following error:
Failed to mount test /run: No such file or directory
By the time command "./test-udev check" calls function "fake_filesystems",
directory "test/run" must be present.
(cherry picked from commit
1e5548c0e0962424b6ca5fdfd35c866b70760c8f)
Related: #
1642728
Alexey Bogdanenko [Sat, 8 Dec 2018 08:02:30 +0000 (11:02 +0300)]
udev-test: fix test skip condition
When there is a failure to setup the environment, the following happens:
1. Command "./test-udev check" exits with non-zero code.
2. Perl function "system" returns the code.
3. The code is evaluated as true by Perl.
Then we stop the test.
(cherry picked from commit
7935dae547caf164d807237f1009a9e9fa510337)
Related: #
1642728
Evgeny Vereshchagin [Fri, 9 Nov 2018 03:01:15 +0000 (04:01 +0100)]
udev-test: skip the test only if it can't setup its environment
This is basically a replacement for
0eb3cc88504b5d8f74.
(cherry picked from commit
110a13202eab6d92678abcde08372d4afac1cc45)
Related: #
1642728
Evgeny Vereshchagin [Fri, 9 Nov 2018 02:14:04 +0000 (03:14 +0100)]
udev-test: remove a check for whether the test is run in a container
It's too broad a check that prevents the test from running on Travis CI.
(cherry picked from commit
881886ef08d50951159633248b0f73977c5d6924)
Related: #
1642728
Yu Watanabe [Wed, 7 Nov 2018 05:56:20 +0000 (14:56 +0900)]
Yu Watanabe [Mon, 22 Oct 2018 22:23:01 +0000 (07:23 +0900)]
test: create /dev/null in test-udev.pl
(cherry picked from commit
a41ff38b0999fb83464309a29b8f39450b8d4b85)
Related: #
1642728
Michal Sekletar [Wed, 6 Jan 2021 10:43:50 +0000 (11:43 +0100)]
udev: make algorithm that selects highest priority devlink less susceptible to race conditions
Previously it was very likely, when multiple contenders for the symlink
appear in parallel, that algorithm would select wrong symlink (i.e. one
with lower-priority).
Now the algorithm is much more defensive and when we detect change in
set of contenders for the symlink we reevaluate the selection. Same
happens when new symlink replaces already existing symlink that points
to different device node.
Resolves: #
1642728
Michal Sekletár [Thu, 5 Nov 2020 16:55:25 +0000 (17:55 +0100)]
basic/stat-util: make mtime check stricter and use entire timestamp
Note that st_mtime member of struct stat is defined as follows,
#define st_mtime st_mtim.tv_sec
Hence we omitted checking nanosecond part of the timestamp (struct
timespec) and possibly would miss modifications that happened within the
same second.
(cherry picked from commit
a59b0a9f768f6e27b25f4f1bab6de08842e78d74)
Related: #
1642728
Michal Sekletar [Tue, 5 Jan 2021 11:30:15 +0000 (12:30 +0100)]
udev/net_id: give RHEL-8.4 naming scheme a name
Follow-up for
bb6114af097da0cd9c5081e42db718559130687f
Related: #
1827462
Christian Göttsche [Mon, 6 Jan 2020 14:27:23 +0000 (15:27 +0100)]
selinux: add trigger for policy reload to refresh internal selabel cache
Reload the internal selabel cache automatically on SELinux policy reloads so non pid-1 daemons are participating.
Run the reload function `mac_selinux_reload()` not manually on daemon-reload, but rather pass it as callback to libselinux.
Trigger the callback prior usage of the systemd internal selabel cache by depleting the selinux netlink socket via `avc_netlink_check_nb()`.
Improves:
a9dfac21ec85 ("core: reload SELinux label cache on daemon-reload")
Improves: #13363
(cherry picked from commit
61f3e897f13101f29fb8027e8839498a469ad58e)
Related: #
1888912
Franck Bui [Mon, 2 Jul 2018 08:22:56 +0000 (10:22 +0200)]
selinux: introduce mac_selinux_create_file_prepare_at()
(cherry picked from commit
7e531a5265687aef5177b070c36ca4ceab42e768)
Related: #
1888912
Christian Göttsche [Wed, 27 Nov 2019 18:43:47 +0000 (19:43 +0100)]
core: reload SELinux label cache on daemon-reload
Reloading the SELinux label cache here enables a light-wight follow-up of a SELinux policy change, e.g. adding a label for a RuntimeDirectory.
Closes: #13363
(cherry picked from commit
a9dfac21ec850eb5dcaf1ae9ef729389e4c12802)
Resolves: #
1888912
Franck Bui [Mon, 28 Jan 2019 11:07:37 +0000 (12:07 +0100)]
units: make sure initrd-cleanup.service terminates before switching to rootfs
A follow-up for commit
a8cb1dc3e0fa81aff.
Commit
a8cb1dc3e0fa81aff made sure that initrd-cleanup.service won't be stopped
when initrd-switch-root.target is isolated.
However even with this change, it might happen that initrd-cleanup.service
survives the switch to rootfs (since it has no ordering constraints against
initrd-switch-root.target) and is stopped right after when default.target is
isolated. This led to initrd-cleanup.service entering in failed state as it
happens when oneshot services are stopped.
This patch along with
a8cb1dc3e0fa81aff should fix issue #4343.
Fixes: #4343
(cherry picked from commit
e2c7c94ea35fe7e669afb51bfc2251158b522ea5)
Related: #
1657810
Pavel Hrdina [Wed, 25 Nov 2020 08:05:36 +0000 (09:05 +0100)]
cgroup: Also set blkio.bfq.weight
Commit [1] added a workaround when unified cgroups are used but missed
legacy cgroups where there is the same issue.
[1] <https://github.com/systemd/systemd/commit/
2dbc45aea747f25cc1c3848fded2ec0062f96bcf>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit
35e7a62ca32a30169a94693b831e53c832251984)
Resolves: #
1657810
David Tardon [Fri, 11 Dec 2020 08:34:19 +0000 (09:34 +0100)]
use link to RHEL-8 docs
RHEL-only
Related: #
1623116
Lennart Poettering [Thu, 8 Nov 2018 08:33:31 +0000 (09:33 +0100)]
unit: make UNIT() cast function deal with NULL pointers
Fixes: #10681
(cherry picked from commit
bbf11206230d1b089118971f98a047151cb5c4fa)
Related: #
1871827
Frantisek Sumsal [Fri, 15 Jan 2021 14:13:53 +0000 (15:13 +0100)]
ci: move jobs from Travis CI to GH Actions
The OSS version of Travis CI is going to be merged with the commercial
one soon, essentially dropping the free tier, so let's move the CI jobs
to GitHub Actions to keep them up.
rhel-only
Related: #
1871827
Frantisek Sumsal [Fri, 15 Jan 2021 12:00:33 +0000 (13:00 +0100)]
ci: use quay.io instead of Docker Hub to avoid rate limits
Docker Hub introduced rate limits for anonymous users (100 requests per
six hours), which break our CI in the busier periods. Let's try to use
the quay.io CentOS image to mitigate this.
rhel-only
Related: #
1871827
Frantisek Sumsal [Fri, 15 Jan 2021 11:51:02 +0000 (12:51 +0100)]
ci: PowerTools repo was renamed to powertools in RHEL 8.3
See: https://wiki.centos.org/Manuals/ReleaseNotes/CentOS8.2011#Yum_repo_file_and_repoid_changes
rhel-only
Related: #
1871827
Lennart Poettering [Wed, 27 May 2020 17:38:38 +0000 (19:38 +0200)]
resolved: tweak cmsg calculation
We ask for the TTL, then have enough space for it.
We probably can drop the extra cmsg space now, but let's figure that out
another time, since the extra cmsg space is used elsewhere in resolved
as well.
(cherry picked from commit
08ab18618ec59022582f1513c0718ba369f5ba85)
Related: #
1887181
Lennart Poettering [Wed, 27 May 2020 17:36:56 +0000 (19:36 +0200)]
core: add new PassPacketInfo= socket unit property
(cherry picked from commit
a3d19f5d99c44940831a33df8b5bece4aaf749f7)
Resolves: #
1887181
Lennart Poettering [Wed, 27 May 2020 17:27:51 +0000 (19:27 +0200)]
socket-util: add generic socket_pass_pktinfo() helper
The helper turns on the protocol specific "packet info" structure cmsg
for three relevant protocols we know.
(cherry picked from commit
35a3eb9bdc95d1e6ba25bc65c78959ea104e45a1)
Related: #
1887181
Lennart Poettering [Thu, 18 Oct 2018 17:48:18 +0000 (19:48 +0200)]
introduce setsockopt_int() helper
As suggested by @heftig:
https://github.com/systemd/systemd/commit/
6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-
30938667
(cherry picked from commit
2ff48e981e6cd1ccbfae49943274d9c8319a5e5d)
Related: #
1887181
Zbigniew Jędrzejewski-Szmek [Sat, 22 Aug 2020 09:58:15 +0000 (11:58 +0200)]
shared/install: fix preset operations for non-service instantiated units
Fixes https://github.com/coreos/ignition/issues/1064.
(cherry picked from commit
47ab95fe4315b3f7ee5a3694460a744bb88c52fd)
Related: #
1812972
Joerg Behrmann [Tue, 10 Mar 2020 15:34:13 +0000 (16:34 +0100)]
docs: Add syntax for templated units to systemd.preset man page
This documents the syntax
enable template@.service foo bar baz
that was introduced in #9901 to preset templated units.
(cherry picked from commit
1f667d8a7cff4355cd23ebebeb4d7179e3498eb8)
Related: #
1812972
Yu Watanabe [Wed, 29 Aug 2018 14:27:42 +0000 (23:27 +0900)]
test: fix a memleak
Follow-up for #9901.
Fixes #9968.
(cherry picked from commit
efa146369398fdb73f1cd177eb2522822ebf559c)
Related: #
1812972
Ruixin Bao [Sun, 26 Aug 2018 20:00:03 +0000 (20:00 +0000)]
install: small refactor to combine two function calls into one function
Combine consecutive function calls of install_info_discover and
install_info_may_process into one short helper function.
(cherry picked from commit
1e475a0ab4c46eb07f3df3fb24f5a7c3e1fa20b1)
Related: #
1812972
Ruixin Bao [Tue, 21 Aug 2018 20:40:56 +0000 (20:40 +0000)]
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.
(cherry picked from commit
4c9565eea534cd233a913c8c21f7920dba229743)
Resolves: #
1812972
Lennart Poettering [Thu, 30 Apr 2020 16:32:44 +0000 (18:32 +0200)]
tree-wide: port various bits over to locale_is_installed()
(cherry picked from commit
a00a78b84e2ab352b3144bfae8bc578d172303be)
Resolves: #
1755287
Lennart Poettering [Thu, 30 Apr 2020 16:32:55 +0000 (18:32 +0200)]
test: add test case for locale_is_installed()
(cherry picked from commit
b45b0a69bb7ef3e6e66d443eae366b6d1c387cab)
Related: #
1755287
Lennart Poettering [Thu, 30 Apr 2020 16:30:56 +0000 (18:30 +0200)]
locale-util: add new helper locale_is_installed()
This new helper checks whether the specified locale is installed. It's
distinct from locale_is_valid() which just superficially checks if a
string looks like something that could be a valid locale.
Heavily inspired by @jsynacek's #13964.
Replaces: #13964
(cherry picked from commit
23fa786ca67ed3a32930ff1a7b175ac823db187c)
Related: #
1755287
Daan De Meyer [Wed, 10 Jun 2020 18:19:41 +0000 (20:19 +0200)]
log: Prefer logging to CLI unless JOURNAL_STREAM is set
(cherry picked from commit
bc694c06e60505efeb09e5278a7b22cdfa23975e)
Resolves: #
1865840
David Tardon [Mon, 9 Nov 2020 08:27:02 +0000 (09:27 +0100)]
remove references of non-existent man pages
This is a follow-up to commit
8ad89170001c9aba8849630ddb5da81d9e24a1bc,
which introduced the man page change.
Resolves: #
1876807
David Tardon [Fri, 6 Nov 2020 09:13:19 +0000 (10:13 +0100)]
fix typo in ProtectSystem= option
This was introduced by commit
d9ae3222cfbd5d2a48e6dbade6617085cc76f1c1 .
Resolves: #
1871139
Michal Sekletár [Mon, 19 Oct 2020 09:10:31 +0000 (11:10 +0200)]
udev/net_id: don't generate slot based names if multiple devices might claim the same slot
(cherry picked from commit
2c8ec0095e6fd2e72879d4915ff8a9e5c0664d0b)
Resolves: #
1827462
Michal Sekletár [Mon, 19 Oct 2020 08:56:11 +0000 (10:56 +0200)]
udev/net_id: parse _SUN ACPI index as a signed integer
Negative value means there is no match between a PCI device and any of
the slots. In the following commit we will extend this and value of 0
will indicate that there is a match between some slot and PCI device,
but that device is a PCI bridge.
(cherry picked from commit
3e545ae5abcf258791eacbee60c829c100a33274)
Related: #
1827462
Zbigniew Jędrzejewski-Szmek [Thu, 9 May 2019 10:34:30 +0000 (12:34 +0200)]
man: describe naming schemes in a new man page
I decided to make this a separate man page because it is freakin' long.
This content could equally well go in systemd-udevd.service(8), systemd.link(5),
or a new man page for the net_id builtin.
v2:
- rename to systemd.net-naming-scheme
- add udevadm test-builtin net_id example
(cherry picked from commit
0b1e5b6ed8c6b9a2bc53709eb75e381d360f05bf)
Related: #
1827462
[msekleta: I've removed parts that describe features which are not
available in RHEL-8]
Zbigniew Jędrzejewski-Szmek [Tue, 11 Dec 2018 22:28:29 +0000 (23:28 +0100)]
meson: make net.naming-scheme= default configurable
This is useful for distributions, where the stability of interface names should
be preseved after an upgrade of systemd. So when some specific release of the
distro is made available, systemd defaults to the latest & greatest naming
scheme, and subsequent updates set the same default. This default may still
be overriden through the kernel and env var options.
A special value "latest" is also allowed. Without a specific name, it is harder
to verride from meson. In case of 'combo' options, meson reads the default
during the initial configuration, and "remembers" this choice. When systemd is
updated, old build/ directories could keep the old default, which would be
annoying. Hence, "latest" is introduced to make it explicit, yet follow the
upstream. This is actually useful for the user too, because it may be used
as an override, without having to actually specify a version.
(cherry picked from commit
06da5c63dd697ea4087e76c6d809b60b5780b87c)
Related: #
1827462
[msekleta: note that our default is not latest but rhel-8.0]
Michal Sekletár [Wed, 14 Oct 2020 14:57:44 +0000 (16:57 +0200)]
udev: introduce udev net_id "naming schemes"
With this we can stabilize how naming works for network interfaces. A
user can request through a kernel cmdline option or an env var which
scheme to follow. The idea is that installers use this to set into stone
(a very soft stone though) the scheme used during installation so that
interface naming doesn't change afterwards anymore.
Why use env vars and kernel cmdline options, and not a config file of
its own?
Well, first of all there's no obvious existing one to use. But more
importantly: I have the feeling that this logic is kind of an incomplete
hack, and I simply don't want to do advertise this as a perfectly
working solution. So far we used env vars for the non-so-official
options and proper config files for the official stuff. Given how
incomplete this logic is (i.e. the big variable for naming remains the
kernel, which might expose sysfs attributes in newer versions that we
check for and didn't exist in older versions — and other problems like
this), I am simply not confident in giving this first-class exposure in
a primary configuration file.
Fixes: #10448
(cherry-picked from commit
f7e81fd96fdfe0ac6dcdb72de43f7cb4720e363a)
Related: #
1827462
[msekleta: note that we are introducing our own naming schemes based on
RHEL-8 minor versions. Also we are not backporting all naming scheme
features that appeared in the original commit. We are backporting only
features relevant for v239 while original commit also converted
changes introduced in v240 into naming scheme flags.]
Lukas Nykryn [Thu, 28 Aug 2014 13:12:10 +0000 (15:12 +0200)]
man: mention System Administrator's Guide in systemctl manpage
(cherry picked from commit
d4582346f47064de24470b5f92e418966004925f)
Resolves: #
1623116
Lennart Poettering [Sat, 4 Apr 2020 10:23:02 +0000 (12:23 +0200)]
user-util: rework how we validate user names
This reworks the user validation infrastructure. There are now two
modes. In regular mode we are strict and test against a strict set of
valid chars. And in "relaxed" mode we just filter out some really
obvious, dangerous stuff. i.e. strict is whitelisting what is OK, but
"relaxed" is blacklisting what is really not OK.
The idea is that we use strict mode whenver we allocate a new user
(i.e. in sysusers.d or homed), while "relaxed" mode is when we process
users registered elsewhere, (i.e. userdb, logind, …)
The requirements on user name validity vary wildly. SSSD thinks its fine
to embedd "@" for example, while the suggested NAME_REGEX field on
Debian does not even allow uppercase chars…
This effectively liberaralizes a lot what we expect from usernames.
The code that warns about questionnable user names is now optional and
only used at places such as unit file parsing, so that it doesn't show
up on every userdb query, but only when processing configuration files
that know better.
Fixes: #15149 #15090
(cherry picked from commit
7a8867abfab10e5bbca10590ec2aa40c5b27d8fb)
Resolves: #
1848373
Lennart Poettering [Mon, 30 Mar 2020 19:46:01 +0000 (21:46 +0200)]
user-util: switch order of checks in valid_user_group_name_or_id_full()
When we are supposed to accept numeric UIDs formatted as string, then
let's check that first, before passing things on to
valid_user_group_name_full(), since that might log about, and not the
other way round.
See: #15201
Follow-up for:
93c23c9297e48e594785e0bb9c51504aae5fbe3e
(cherry picked from commit
a85daa0dfb3eb03be9845760e90e54b9af8fb00e)
Related: #
1848373
Zbigniew Jędrzejewski-Szmek [Thu, 1 Aug 2019 08:02:14 +0000 (10:02 +0200)]
shared/user-util: allow usernames with dots in specific fields
People do have usernames with dots, and it makes them very unhappy that systemd
doesn't like their that. It seems that there is no actual problem with allowing
dots in the username. In particular chown declares ":" as the official
separator, and internally in systemd we never rely on "." as the seperator
between user and group (nor do we call chown directly). Using dots in the name
is probably not a very good idea, but we don't need to care. Debian tools
(adduser) do not allow users with dots to be created.
This patch allows *existing* names with dots to be used in User, Group,
SupplementaryGroups, SocketUser, SocketGroup fields, both in unit files and on
the command line. DynamicUsers and sysusers still follow the strict policy.
user@.service and tmpfiles already allowed arbitrary user names, and this
remains unchanged.
Fixes #12754.
(cherry picked from commit
ae480f0b09aec815b64579bb1828ea935d8ee236)
Related: #
1848373
Balint Reczey [Wed, 18 Mar 2020 17:29:02 +0000 (18:29 +0100)]
user-util: Allow names starting with a digit
In
1a29610f5fa1bcb2eeb37d2c6b79d8d1a6dbb865 the change inadvertedly
disabled names with digit as the first character. This follow-up change
allows a digit as the first character in compat mode.
Fixes: #15141
(cherry picked from commit
93c23c9297e48e594785e0bb9c51504aae5fbe3e)
Related: #
1848373
Zbigniew Jędrzejewski-Szmek [Wed, 28 Aug 2019 10:05:52 +0000 (12:05 +0200)]
shared/user-util: emit a warning on names with dots
(cherry picked from commit
88e2ed0b5bf6f08f5a2d4d64b1fefdc7192b9aac)
Related: #
1848373
David Tardon [Tue, 27 Oct 2020 09:31:05 +0000 (10:31 +0100)]
shared/user-util: add compat forms of user name checking functions
New functions are called valid_user_group_name_compat() and
valid_user_group_name_or_id_compat() and accept dots in the user
or group name. No functional change except the tests.
(cherry picked from commit
1a29610f5fa1bcb2eeb37d2c6b79d8d1a6dbb865)
This completes previous partial cherry-pick of the same commit (commit
76176de0889c3e8b9b3a176da24e4f8dbbd380a3).
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:48:41 +0000 (17:48 +0200)]
tests: beef up integer parsing tests
(cherry picked from commit
53c6db99fa4b52f97e19977f21d3133f8ceb3dcd)
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:31:51 +0000 (17:31 +0200)]
parse-util: also parse integers prefixed with 0b and 0o
Let's adopt Python 3 style 0b and 0x syntaxes, because it makes a ton of
sense, in particular in bitmask settings.
(cherry picked from commit
fc80cabcf584a8b486bdff5be0c074fec4059cdc)
Related: #
1848373
Lennart Poettering [Fri, 23 Nov 2018 15:27:15 +0000 (16:27 +0100)]
strv: add new macro STARTSWITH_SET()
This is to startswith() what PATH_STARTSWITH_SET() is to
path_startswith().
Or in other words, checks if the specified string has any of the listed
prefixes, and if so, returns the remainder of the string.
(cherry picked from commit
52f1552073047195d51901f7e5a5a4fa3189034e)
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:16:46 +0000 (17:16 +0200)]
user-util: be stricter in parse_uid()
Let's refuse "+" and "-" prefixed UIDs. Let's refuse whitespace-prefixed
UIDS, Let's refuse zero-prefixed UIDs. Let's be safe than sorry.
(cherry picked from commit
f5979b63cc305ba217dfd174b1bf0583bcf75a73)
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:16:04 +0000 (17:16 +0200)]
parse-util: rewrite parse_mode() on top of safe_atou_full()
Parsing is hard, hence let's use our own careful wrappers wherever
possible.
(cherry picked from commit
c44702a8bd8cc8b7f2f1df21db9308d9af7dda5b)
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:10:27 +0000 (17:10 +0200)]
parse-util: make return parameter optional in safe_atou16_full()
All other safe_atoXYZ_full() functions have the parameter optional,
let's make it optoinal here, too.
(cherry picked from commit
aa85e4d3cef8ca8436e480bce9fa4ce72876b636)
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:08:38 +0000 (17:08 +0200)]
parse-util: allow '-0' as alternative to '0' and '+0'
Let's allow "-0" as alternative to "+0" and "0" when parsing integers,
unless the new SAFE_ATO_REFUSE_PLUS_MINUS flag is specified.
In cases where allowing the +/- syntax shall not be allowed
SAFE_ATO_REFUSE_PLUS_MINUS is the right flag to use, but this also means
that -0 as only negative integer that fits into an unsigned value should
be acceptable if the flag is not specified.
(cherry picked from commit
c78eefc13562a8fc0c22c00a6d3001af89860258)
Related: #
1848373
Lennart Poettering [Mon, 1 Jun 2020 15:06:19 +0000 (17:06 +0200)]
parse-util: allow tweaking how to parse integers
This allows disabling a few alternative ways to decode integers
formatted as strings, for safety reasons.
See: #15991
(cherry picked from commit
707e93aff8f358f8a62117e54b857530d6594e4b)
Related: #
1848373
Zbigniew Jędrzejewski-Szmek [Thu, 9 Apr 2020 09:18:26 +0000 (11:18 +0200)]
basic/parse-util: add safe_atoux64()
(cherry picked from commit
ce51632a357d347737bf40d3817df331cd8874cb)
Related: #
1848373
Lennart Poettering [Thu, 14 Nov 2019 13:49:40 +0000 (14:49 +0100)]
parse-util: sometimes it is useful to check if a string is a valid integer, but not actually parse it
(cherry picked from commit
22810041c2200fe72b0e0c985d0e404f8b80f9e2)
Related: #
1848373
Zbigniew Jędrzejewski-Szmek [Sun, 31 May 2020 16:21:09 +0000 (18:21 +0200)]
basic/user-util: always use base 10 for user/group numbers
We would parse numbers with base prefixes as user identifiers. For example,
"0x2b3bfa0" would be interpreted as UID==
45334432 and "01750" would be
interpreted as UID==1000. This parsing was used also in cases where either a
user/group name or number may be specified. This means that names like
0x2b3bfa0 would be ambiguous: they are a valid user name according to our
documented relaxed rules, but they would also be parsed as numeric uids.
This behaviour is definitely not expected by users, since tools generally only
accept decimal numbers (e.g. id, getent passwd), while other tools only accept
user names and thus will interpret such strings as user names without even
attempting to convert them to numbers (su, ssh). So let's follow suit and only
accept numbers in decimal notation. Effectively this means that we will reject
such strings as a username/uid/groupname/gid where strict mode is used, and try
to look up a user/group with such a name in relaxed mode.
Since the function changed is fairly low-level and fairly widely used, this
affects multiple tools: loginctl show-user/enable-linger/disable-linger foo',
the third argument in sysusers.d, fourth and fifth arguments in tmpfiles.d,
etc.
Fixes #15985.
(cherry picked from commit
156a5fd297b61bce31630d7a52c15614bf784843)
Resolves: #
1848373
Michal Sekletár [Mon, 17 Feb 2020 12:50:31 +0000 (13:50 +0100)]
core: add support for setting CPUAffinity= to special "numa" value
systemd will automatically derive CPU affinity mask from NUMA node
mask.
Fixes #13248
(cherry picked from commit
e2b2fb7f566d13a3de61952b5356cd4d2eaee917)
Resolves: #
1740657
Michal Sekletar [Fri, 31 May 2019 13:23:23 +0000 (15:23 +0200)]
dbus-execute: make transfer of CPUAffinity endian safe (#12711)
We store the affinity mask in the native endian. However, over D-Bus we
must transfer the mask in little endian byte order.
This is the second part of
c367f996f5f091a63f812f0140b304c649be77fc.
(cherry picked from commit
75e40119a471454516ad0acc96f6f4094e7fb652)
Related: #
1740657
Wen Yang [Tue, 30 Jun 2020 20:45:33 +0000 (04:45 +0800)]
mount-setup: fix segfault in mount_cgroup_controllers when using gcc9 compiler
According to the documentation:
https://gcc.gnu.org/gcc-9/porting_to.html#complit
The 'join_controllers' that relied on the extended lifetime needs
to be fixed, move the compound literals to the function scope it
need to accessible in.
Resolves: #
1868877
Alan Jenkins [Thu, 21 Jun 2018 13:12:30 +0000 (14:12 +0100)]
core: remove support for API bus "started outside our own logic"
Looking at a recent Bad Day, my log contains over 100 lines of
systemd[23895]: Failed to connect to API bus: Connection refused
It is due to "systemd --user" retrying to connect to an API bus.[*] I
would prefer to avoid spamming the logs. I don't think it is good for us
to retry so much like this.
systemd was mislead by something setting DBUS_SESSION_BUS_ADDRESS. My best
guess is an unfortunate series of events caused gdm to set this. gdm has
code to start a session dbus if there is not a bus available already (and
in this case it exports the environment variable). I believe it does not
normally do this when running under systemd, because "systemd --user" and
hence "dbus.service" would already have been started by pam_systemd.
I see two possibilities
1. Rip out the check for DBUS_SESSION_BUS_ADDRESS entirely.
2. Only check for DBUS_SESSION_BUS_ADDRESS on startup. Not in the
"recheck" logic.
The justification for 2), is that the recheck is called from unit_notify(),
this is used to check whether the service just started (or stopped) was
"dbus.service". This reason for rechecking does not apply if we think
the session bus was started outside our logic.
But I think we can justify 1). dbus-daemon ships a statically-enabled
/usr/lib/systemd/user/dbus.service, which would conflict with an attempt to
use an external dbus. Also "systemd --user" is started from user@.service;
if you try to start it manually so that it inherits an environment
variable, it will conflict if user@.service was started by pam_systemd
(or loginctl enable-linger).
(cherry picked from commit
d3243f55ca9b5f305306ba4105ab29768e372a78)
Resolves: #
1764282
Renaud Métrich [Thu, 20 Aug 2020 11:00:37 +0000 (13:00 +0200)]
socket: New option 'FlushPending' (boolean) to flush socket before entering listening state
Disabled by default. When Enabled, before listening on the socket, flush the content.
Applies when Accept=no only.
(cherry picked from commit
3e5f04bf6468fcb79c080f02b0eab08f258bff0c)
Resolves: #
1870638
Lennart Poettering [Tue, 26 Mar 2019 17:02:49 +0000 (18:02 +0100)]
man: document the new systemctl --show-transaction option
(cherry picked from commit
df4a7cb7323c8cf00553d766913312c5b7ccd508)
Related: #846319
Lennart Poettering [Tue, 26 Mar 2019 16:39:36 +0000 (17:39 +0100)]
test: add some basic testing that "systemctl start -T" does something
(cherry picked from commit
f087c7e072bb338d5c7c0781c9fbc900612efd18)
Related: #846319
Lennart Poettering [Fri, 22 Mar 2019 19:58:13 +0000 (20:58 +0100)]
systemctl: add new --show-transaction switch
This new switch uses the new method call EnqueueUnitJob() for enqueuing
a job and showing the jobs it enqueued.
Fixes: #2297
(cherry picked from commit
85d9b5981ba6b7ee3955f95fa6cf3bb8cdf3444d)
Resolves: #846319
Lennart Poettering [Tue, 26 Mar 2019 15:19:35 +0000 (16:19 +0100)]
systemctl: split out extra args generation into helper function of its own
(cherry picked from commit
94369fc0663255bbd327f97dba288ececf51a514)
Related: #846319
Lennart Poettering [Sat, 13 Oct 2018 12:38:46 +0000 (14:38 +0200)]
systemctl: clean up start_unit_one() error handling
Let's split exit code handling in two: "r" is only used for errno-style
errors, and "ret" is used for exit() codes. Then, let's use EXIT_SUCCESS
for checking whether the latter is already used.
This way it should always be clear what kind of error we are processing,
and when we propaate one into the other.
Moreover this allows us to drop "q" form all inner loops, avoiding
confusion when to use "q" and when "r" to store received errors.
Fixes: #9704
(cherry picked from commit
0e8d9c0c4d7e71487c486f626c59853cfb031d16)
Related: #846319
Filipe Brandenburger [Fri, 20 Jul 2018 18:32:55 +0000 (11:32 -0700)]
systemctl: Only wait when there's something to wait for.
Tested:
- `systemctl --wait start i-do-not-exist.service` does not wait.
- `systemctl --wait start i-do-not-exist.service valid-unit.service` does.
(cherry picked from commit
46f2579c2ac9f6780d5afec1000764defc6b581e)
Related: #846319
Lennart Poettering [Tue, 26 Mar 2019 14:49:52 +0000 (15:49 +0100)]
systemctl: reindent table
(cherry picked from commit
5fd77930ad9980af5257f9f871556d6973db736c)
Related: #846319
Lennart Poettering [Tue, 26 Mar 2019 14:20:26 +0000 (15:20 +0100)]
systemctl: replace switch statement by table of structures
(cherry picked from commit
c45e5fb877033c9e3f9b79121644ed71032af379)
Related: #846319
Lennart Poettering [Fri, 22 Mar 2019 19:57:30 +0000 (20:57 +0100)]
core: add new API for enqueing a job with returning the transaction data
(cherry picked from commit
50cbaba4fe5a32850998682699322d012e597e4a)
Related: #846319
Zbigniew Jędrzejewski-Szmek [Wed, 14 Oct 2020 12:03:13 +0000 (14:03 +0200)]
sd-bus: break the loop in bus_ensure_running() if the bus is not connecting
This might fix #17025:
> the call trace is
> bus_ensure_running -> sd_bus_process -> bus_process_internal -> process_closeing --> sd_bus_close
> |
> \-> process_match
We ended doing callouts to the Disconnected matches from bus_ensure_running()
and shouldn't. bus_ensure_running() should never do callouts. This change
should fix this however: once we notice that the connection is going down we
will now fail instantly with ENOTOCONN instead of calling any callbacks.
(cherry picked from commit
93a59b1ae5d3bcb0ec1488ebc13d0d1ff4d1729a)
Resolves: #
1885553
Lennart Poettering [Mon, 29 Apr 2019 14:10:51 +0000 (16:10 +0200)]
units: drop reference to sushell man page
sushell was a Fedoraism, and has been removed since. Hence our upstream
unit files shouldn't reference it either.
(cherry picked from commit
6dc14d73664390682d47d7e5bcbdbb362d04f623)
Resolves: #
1871827
Michael Biebl [Thu, 7 Mar 2019 11:02:53 +0000 (12:02 +0100)]
units: fix systemd.special man page reference in system-update-cleanup.service
(cherry picked from commit
faab72d16b310c17be4b908cfe15eca122d16ae4)
Resolves: #
1871827
Franck Bui [Thu, 16 Jul 2020 19:22:37 +0000 (21:22 +0200)]
vconsole-setup: downgrade log message when setting font fails on dummy console
Since commit
883eb9be985fd86d9cabe967eeeab91cdd396a81, vconsole-setup might be
called again to operate on dummy console where font operations are not
supported but where it's still important to have the correct keymap set [0][1].
vconsole-setup is mainly called by udev but can also be run via a dependency of
an early service. Both cases might end up calling vconsole-setup on the dummy
console.
The first case can happen during early boot even on systems that use (instead
of the dummy console) a "simple" video console driver supporting font
operations (such as vgacon) until a more specific driver (such as i915) takes
the console over. While this is happening vgacon is deactivated and temporarly
replaced by the dummy console [2].
There are also other cases where systemd-vconsole-setup might be called on
dummy console especially during (very) early boot. Indeed
systemd-vconsole-setup.service might be pulled in by early interactive services
such as 'dracut-cmdline-ask.service` which is run before udev.
If that happens on platforms with no grapical HWs (such as embedded ARM) or
with dummy console initially installed until a driver takes over (like Xen and
xen-fbfront) then setting font will fail.
Therefore this patch downgrades the log message emitted when setting font fails
to LOG_DEBUG and when font operations is not implemented like it's the case for
the dummy console.
Fixes: #16406.
[0] https://github.com/systemd/systemd/issues/10826
[1] https://bugzilla.redhat.com/show_bug.cgi?id=
1652473
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/vga/vgaarb.c?h=v5.7#n204
(cherry picked from commit
0ef1adf51274960358e852d3bc36ae6c288a70d9)
Resolves: #
1889996
Zbigniew Jędrzejewski-Szmek [Wed, 3 Apr 2019 11:11:00 +0000 (13:11 +0200)]
seccomp: rework how the S[UG]ID filter is installed
If we know that a syscall is undefined on the given architecture, don't
even try to add it.
Try to install the filter even if some syscalls fail. Also use a helper
function to make the whole a bit less magic.
This allows the S[UG]ID test to pass on arm64.
(cherry picked from commit
da4dc9a6748797e804b6bc92ad513d509abf581c)
Resolves: #
1860374
Zbigniew Jędrzejewski-Szmek [Fri, 26 Apr 2019 11:37:31 +0000 (13:37 +0200)]
basic/virt: try the /proc/1/sched hack also for PID1
If a container manager does not set $container, we could end up
in a strange situation when detect-virt returns container-other when
run as non-pid-1 and none when run as pid-1.
(cherry picked from commit
342bed02084c4396dd2f1054bd559bfb2699cfcb)
Resolves: #
1868877
Jan Synacek [Mon, 17 Aug 2020 12:29:04 +0000 (14:29 +0200)]
build: use simple project version in pkgconfig files
Loosely based on commit
a67c318df8800ba98d7361308937ed276dc73982.
Resolves: #
1862714
Michal Sekletar [Fri, 22 Feb 2019 14:50:55 +0000 (15:50 +0100)]
logind: don't print warning when user@.service template is masked
User instance of systemd is optional feature and if user@.service
template is masked then administrator most likely doesn't want --user
instances of systemd for logged in users. We don't need to be verbose
about it.
(cherry picked from commit
03b6fa0c5b51b0d39334ff6ba183a3391443bcf6)
Resolves: #
1880270
Michal Sekletár [Tue, 8 Sep 2020 12:51:39 +0000 (14:51 +0200)]
cgroup: freezer action must be NOP when cgroup v2 freezer is not available
Low-level cgroup freezer state manipulation is invoked directly from the
job engine when we are about to execute the job in order to make sure
the unit is not frozen and job execution is not blocked because of
that.
Currently with cgroup v1 we would needlessly do a bunch of work in the
function and even falsely update the freezer state. Don't do any of this
and skip the function silently when v2 freezer is not available.
Following bug is fixed by this commit,
$ systemd-run --unit foo.service /bin/sleep infinity
$ systemctl restart foo.service
$ systemctl show -p FreezerState foo.service
Before (cgroup v1, i.e. full "legacy" mode):
FreezerState=thawing
After:
FreezerState=running
(cherry picked from commit
9a1e90aee556b7a30d87553a891a4175ae77ed68)
Resolves: #
1868831
Lennart Poettering [Wed, 22 Apr 2020 18:34:02 +0000 (20:34 +0200)]
core: make sure to restore the control command id, too
Fixes: #15356
(cherry picked from commit
e9da62b18af647bfa73807e1c7fc3bfa4bb4b2ac)
Resolves: #
1829867
Lennart Poettering [Mon, 25 Jun 2018 15:21:34 +0000 (17:21 +0200)]
man: document new "boot-complete.target" unit
(cherry picked from commit
82ea38258c0f4964c2f3ad3691c6e4554c4f0bb0)
Related: #
1872243
Lennart Poettering [Fri, 22 Jun 2018 10:52:28 +0000 (12:52 +0200)]
units: add generic boot-complete.target
(cherry picked from commit
329d20db3cb02d789473b8f7e4a59526fcbf5728)
Resolves: #
1872243
Michal Sekletár [Thu, 26 Mar 2020 12:35:11 +0000 (13:35 +0100)]
device: don't emit PropetiesChanged needlessly
Functions called from device_setup_unit() already make sure that unit is
enqueued in case it is a new unit or properties exported on the bus have
changed.
This should prevent unnecessary DBus wakeups and associated DBus traffic
when device_setup_unit() was called while reparsing /proc/self/mountinfo
due to the mountinfo notifications. Note that we parse
/proc/self/mountinfo quite often on the busy systems (e.g. k8s container
hosts) but majority of the time mounts didn't change, only some mount
got added. Thus we don't need to generate PropertiesChanged for devices
associated with the mounts that didn't change.
Thanks to Renaud Métrich <rmetrich@redhat.com> for debugging the
problem and providing draft version of the patch.
(cherry picked from commit
2e129d5d6bd6bd8be4b5359e81a880cbf72a44b8)
Resolves: #
1793533
Michal Sekletár [Thu, 26 Mar 2020 12:34:20 +0000 (13:34 +0100)]
device: make sure we emit PropertiesChanged signal once we set sysfs
(cherry picked from commit
7c4d139485139eae95b17a1d54cb51ae958abd70)
Related: #
1793533