systemd/.git
4 years agosd-device: make TAGS= property prefixed and suffixed with ":"
Yu Watanabe [Thu, 10 Dec 2020 23:34:13 +0000 (08:34 +0900)]
sd-device: make TAGS= property prefixed and suffixed with ":"

The commit 6f3ac0d51766b0b9101676cefe5c4ba81feba436 drops the prefix and
suffix in TAGS= property. But there exists several rules that have like
`TAGS=="*:tag:*"`. So, the property must be always prefixed and suffixed
with ":".

Fixes #17930.

(cherry picked from commit 8d80f275303385eb9e2452f97f9c11be5c196862)

4 years agosd-device: keep escaped strings in DEVLINK= property
Yu Watanabe [Sun, 6 Dec 2020 12:10:34 +0000 (21:10 +0900)]
sd-device: keep escaped strings in DEVLINK= property

This fixes a bug introduced by 87a4d416e5126b6fb2528ae192a6a6a8033539ce.

Fixes #17772.

(cherry picked from commit 31063db0b4842a452c6eadde5b969aaee2a0516a)

4 years agosd-device: use set_strjoin()
Yu Watanabe [Sun, 6 Dec 2020 11:11:37 +0000 (20:11 +0900)]
sd-device: use set_strjoin()

This slightly changes TAGS= and CURRENT_TAGS= properties:

Before
E: TAGS=:aaa:bbb:

After
E: TAGS=aaa:bbb

(cherry picked from commit 6f3ac0d51766b0b9101676cefe5c4ba81feba436)

4 years agoset: introduce set_strjoin()
Yu Watanabe [Sun, 6 Dec 2020 11:10:48 +0000 (20:10 +0900)]
set: introduce set_strjoin()

(cherry picked from commit 4dbce717873000cff7b56f89266d1d2fe53f9284)

4 years agotools: make update-dbus-docs compatible with Python 3.6
Anita Zhang [Mon, 1 Feb 2021 03:04:34 +0000 (19:04 -0800)]
tools: make update-dbus-docs compatible with Python 3.6

668b3a42fe9e250912bd3efa4460ed691452d9bf allowed update-dbus-docs.py to start
running on Cent OS 8 (instead of skipping). But subprocess.check_output()'s
text argument didn't exist until Python 3.7 and C8 is still running
Python 3.6. Use universal_newlines instead for backwards compatibility.

(cherry picked from commit 934d0d023e33aa38c56e1e12118be8ddbd839284)

4 years agoman: fix small issue in AllowedMemoryNodes description
Pavel Hrdina [Sat, 30 Jan 2021 17:03:40 +0000 (18:03 +0100)]
man: fix small issue in AllowedMemoryNodes description

It should not mention "CPU" but "NUMA nodes".

(cherry picked from commit 16455ee2b1853238cf0e936735ff92e690a20253)

4 years agoman: make it clear how systemd calculate the DefaultTasksMax.
Einsler Lee [Sat, 30 Jan 2021 03:14:35 +0000 (11:14 +0800)]
man: make it clear how systemd calculate the DefaultTasksMax.

Actually, systemd takes the minimum of
* a) the maximum tasks value the kernel allows on this architecture
* b) the cgroups pids_max attribute for the system
* c) the kernel's configured maximum PID value
to calculate the DefaultTasksMax. Here, kernel.thread-max should also be methioned.

(cherry picked from commit 9c587d66187976de49e2d2028cebe1aef5b77b9c)

4 years agoresolved: use reference counting for DnsQueryCandidate objects
Zbigniew Jędrzejewski-Szmek [Fri, 29 Jan 2021 15:21:08 +0000 (16:21 +0100)]
resolved: use reference counting for DnsQueryCandidate objects

Follow-up for 4ea8b443de. The logic that manages DnsQueryCandidate is rather
complicated: a calls to dns_query_complete() that wants to destroy a
DnsQueryCandidate can be nested inside a deep chain of calls. Using reference
counts seems like the simplest approach.

DnsSearchDomain already uses reference counting.

This patch effectively brings dns_query_candidate_go() to the state before
4ea8b443de, but wraps the iteration over DnsQueryCandidate.transactions in
dns_query_candidate_ref+dns_query_candidate_unref.

(cherry picked from commit 0e0fd08fc832b8f42e567d722d388eba086da5ff)

4 years agoresolved: minor cleanups
Zbigniew Jędrzejewski-Szmek [Fri, 29 Jan 2021 15:18:12 +0000 (16:18 +0100)]
resolved: minor cleanups

(cherry picked from commit c805014a350da7c32eb2bdb408a9fa643c191dee)

4 years agotools: make update-dbus-docs compatible with Python 3.7
Luca Boccassi [Tue, 19 Jan 2021 11:57:46 +0000 (11:57 +0000)]
tools: make update-dbus-docs compatible with Python 3.7

Debian Stable uses Python 3.7, but there are a couple of 3.8 features used
in the script. Add fallbacks.

(cherry picked from commit 668b3a42fe9e250912bd3efa4460ed691452d9bf)

4 years agonetwork: drop wrong flag for neighbor entry
Yu Watanabe [Tue, 26 Jan 2021 16:19:24 +0000 (01:19 +0900)]
network: drop wrong flag for neighbor entry

NLM_F_REQUEST is a nlmsg flag, not a neighbor flag.

(cherry picked from commit 4816e7bb75cc573d188f325f14eb59a90357eec2)

4 years agosysusers: flush nscd's caches whenever /etc/{passwd,group} are modified
Franck Bui [Mon, 25 Jan 2021 15:32:44 +0000 (16:32 +0100)]
sysusers: flush nscd's caches whenever /etc/{passwd,group} are modified

(cherry picked from commit d481b8305280cc7780fcd1ce2c391f12ff31786f)

4 years agotree-wide: ignore messages with too long control data
Lennart Poettering [Tue, 19 Jan 2021 20:34:20 +0000 (21:34 +0100)]
tree-wide: ignore messages with too long control data

Apparently SELinux inserts control data into AF_UNIX datagrams where we
don't expect it, thus miscalculating the control data. This looks like
something to fix in SELinux, but we still should handle this gracefully
and just drop the offending datagram and continue.

recvmsg_safe() actually already drops the datagram, it's just a matter
of actually ignoring EXFULL (which it generates if control data is too
large) in the right places.

This does this wherever an AF_UNIX/SOCK_DGRAM socket is used with
recvmsg_safe() that is not just internal communication.

Fixes: #17795
Follow-up for: 3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1

(cherry picked from commit 741bfd7f4e60fdc07ecaadbd93f1196dbee657ca)

4 years agosystemctl: warn when importing environment variables with control characters
Zbigniew Jędrzejewski-Szmek [Tue, 19 Jan 2021 13:20:16 +0000 (14:20 +0100)]
systemctl: warn when importing environment variables with control characters

I don't think it is useful to warn about about environemnt variables where the user
explicitly configured some value. If they went through the effort of escaping the cc
to include it in the setting (e.g. Environment="VAR=\efoo"), and we pass this through,
there isn't anything to warn about. This also applies to 'systemctl set-environment',
where the variable name and value are passed as arguments.

The only case where the warning *might* be useful is where the user might be
surprised by the value. This occurs when importing variables from the inherited
environment, i.e. in 'systemctl import-environment'. In not convinced that this is
useful, since the user better control their shell environment anyway.

$ systemctl import-environment
Calling import-environment without a list of variable names is deprecated.
Environment variable $LESS_TERMCAP_mb contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_md contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_me contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_se contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_so contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_ue contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_us contains control characters, importing anyway.
Environment variable $ZZZ contains control characters, importing anyway.

(cherry picked from commit e9155cd0778499a7e20edd2af8429247bbb1daa9)

4 years agoAllow control characters in environment variable values
Zbigniew Jędrzejewski-Szmek [Sun, 3 Jan 2021 21:26:52 +0000 (22:26 +0100)]
Allow control characters in environment variable values

So far, we would allow certain control characters (NL since
b4346b9a77bc6129dd3e, TAB since 6294aa76d818e831de45), but not others. Having
other control characters in environment variable *value* is expected and widely
used, for various prompts like $LESS, $LESS_TERMCAP_*, and other similar
variables. The typical environment exported by bash already contains a dozen or
so such variables, so programs need to handle them.

We handle then correctly too, for example in 'systemctl show-environment',
since 804ee07c1370d49aa9a. But we would still disallow setting such variables
by the user, in unit file Environment= and in set-environment/import-environment
operations. This is unexpected and confusing and doesn't help with anything
because such variables are present in the environment through other means.

When printing such variables, 'show-environment' escapes all special
characters, so variables with control characters are plainly visible.
In other uses, e.g. 'cat -v' can be used in similar fashion. This would already
need to be done to suppress color codes starting with \[.

Note that we still forbid invalid utf-8 with this patch. (Control characters
are valid, since they are valid 7-bit ascii.) I'm not sure if we should do
that, but since people haven't been actually asking for invalid utf-8, and only
for control characters, and invalid utf-8 causes other issues, I think it's OK
to leave this unchanged.

Fixes #4446, https://gitlab.gnome.org/GNOME/gnome-session/-/issues/45.

(cherry picked from commit 30927a24848c4d727f7619cc74b878f098cdd724)

4 years agosystemctl: print a warning when trying to import a nonexistent variable
Zbigniew Jędrzejewski-Szmek [Sun, 3 Jan 2021 20:53:38 +0000 (21:53 +0100)]
systemctl: print a warning when trying to import a nonexistent variable

I was quite confused what is happening:
$ XXX=xxx
$ systemctl --user import-environment XXX
$ systemctl --user show-environment | grep XXX
(nothing)

Obviously, 'export XXX' was missing. Without any indication why the
export is not happening, this can be hard to figure out.

Another option would be to error out. But so far we didn't, and doing
that could break some script which optimistically tries to export some
variables, if present.

(cherry picked from commit c4899ea427fe93b5b2beac8ab10bfee7dfbf2021)

4 years agoresolved: fix use-after-free with queries hitting the cache
Zbigniew Jędrzejewski-Szmek [Sun, 17 Jan 2021 18:51:28 +0000 (19:51 +0100)]
resolved: fix use-after-free with queries hitting the cache

When dns_transaction_complete() manages to resolve a query, it invalidates the
query candidate object. It shall not be accessed afterwards.

We have the following chain of calls:
dns_query_candidate_go → dns_transaction_go → dns_transaction_prepare → dns_cache_lookup (success: 1)
                                                                      → dns_transaction_complete
After returning back to dns_query_candidate_go(), we'd attempt to continue
iteration over the list of transactions attached to the query candidate,
accessing already freed (and overwritten) memory:

(gdb) bt
0  0x00007f637297cf47 in hashmap_iterate_entry (i=0x7ffe7e15cc90, h=0x706f746b73656465) at ../src/basic/hashmap.c:703
1  _hashmap_iterate (h=0x706f746b73656465, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88,
    key=key@entry=0x0) at ../src/basic/hashmap.c:712
2  0x00007f637297d01b in set_iterate (s=<optimized out>, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88)
    at ../src/basic/hashmap.c:733
hence we crash

3  0x0000557bc99eb80f in dns_query_candidate_go (c=c@entry=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:139
...but c is not valid here in the second iteration of the loop

4  0x0000557bc99eb720 in dns_query_candidate_notify (c=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:271
c was valid here at entry...

5  0x0000557bc99efe28 in dns_transaction_complete (t=0x557bcac072f0, state=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:350
t is a valid transaction (11481 in the backtrace below)

6  0x0000557bc99f1efb in dns_transaction_process_reply (t=0x557bcac072f0, p=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:1171
7  0x0000557bc99f2d41 in on_dns_packet (s=<optimized out>, fd=<optimized out>, revents=<optimized out>,
    userdata=0x557bcac072f0) at ../src/resolve/resolved-dns-transaction.c:1223
8  0x00007f6372a25217 in source_dispatch (s=s@entry=0x557bcb162c50) at ../src/libsystemd/sd-event/sd-event.c:3181
9  0x00007f6372a254fd in sd_event_dispatch (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3620
10 0x00007f6372a267c8 in sd_event_run (e=e@entry=0x557bcb15b050, timeout=timeout@entry=18446744073709551615)
    at ../src/libsystemd/sd-event/sd-event.c:3678
11 0x00007f6372a269ef in sd_event_loop (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3700
12 0x0000557bc99ddc14 in run (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:92
13 0x0000557bc99d260a in main (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:99

xxx.name.net systemd-resolved[31705]: Got message type=method_call sender=:1.3644 destination=org.freedesktop.resolve1 path=/org/freedesktop/resolve1 interface=org.freedesktop.resolve1.Manager member=ResolveHostname cookie=2 reply_cookie=0 signature=isit error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: idn2_lookup_u8: xxx → xxx
xxx.name.net systemd-resolved[31705]: Looking up RR for xxx IN A.
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=1102 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetNameOwner cookie=1103 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1103 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Cache miss for xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> scope dns on enp42s0/*.
xxx.name.net systemd-resolved[31705]: Using feature level UDP for transaction 11481.
xxx.name.net systemd-resolved[31705]: Using DNS server 192.168.1.1 for transaction 11481.
xxx.name.net systemd-resolved[31705]: Sending query packet with id 11481 of size 35.
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1102 signature= error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Match type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.3644' successfully installed.
xxx.name.net systemd-resolved[31705]: Processing incoming packet on transaction 11481 (rcode=NXDOMAIN).
xxx.name.net systemd-resolved[31705]: Not caching negative entry without a SOA record: xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> on scope dns on enp42s0/* now complete with <rcode-failure> from network (unsigned).
xxx.name.net systemd-resolved[31705]: Positive cache hit for xxx.lan IN A
xxx.name.net systemd-resolved[31705]: Transaction 64364 for <xxx.lan IN A> on scope dns on enp42s0/* now complete with <success> from cache (unsigned).
xxx.name.net systemd-resolved[31705]: Sent message type=method_return sender=n/a destination=:1.3644 path=n/a interface=n/a member=n/a cookie=1104 reply_cookie=2 signature=a(iiay)st error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=1105 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Freeing transaction 64364.
xxx.name.net systemd[1]: systemd-resolved.service: Main process exited, code=dumped, status=11/SEGV
xxx.name.net systemd[1]: systemd-resolved.service: Failed with result 'core-dump'.

Fixes #16168, https://bugzilla.redhat.com/show_bug.cgi?id=1895937.

(cherry picked from commit 4ea8b443de8be0f7a932f325dfafa1ee2a843795)

4 years agoman: clarify what network scopes are
Adam Nielsen [Sun, 17 Jan 2021 01:10:57 +0000 (11:10 +1000)]
man: clarify what network scopes are

(cherry picked from commit e64652f70c1cb1a2fd86915a8d806491cf73b162)

4 years agorpm: expose $systemd_util_dir also as rpm macro
Zbigniew Jędrzejewski-Szmek [Fri, 15 Jan 2021 09:31:00 +0000 (10:31 +0100)]
rpm: expose $systemd_util_dir also as rpm macro

This variable (a.k.a. rootlibexecdir), was exposed through the .pc file, but
not as rpm macro.

The .pc file must be located in the package that provides libraries, which
pulls in a lot of dependencies. In Fedora, the macros are split out to a
separate package so that other packages which need to refer to some systemd
path but don't otherwise require it, can only pull in the (much smaller and
dependency-less) macros package. zram-generator uses the path to specify the
location of systemd-makefs, so by using the rpm macro we'll be able to use
a much smaller buildroot.

(cherry picked from commit 3bc66bfa0136e370a8f7b06c3b69a52f5636ef82)

4 years agosystemctl-edit: Add missing ret_dropin_paths argument in retry path
Anita Zhang [Thu, 14 Jan 2021 08:17:41 +0000 (00:17 -0800)]
systemctl-edit: Add missing ret_dropin_paths argument in retry path

find_paths_to_edit() makes 2 calls to unit_find_paths(), one of which is
a retry client-side. ret_dropin_paths should be passed the same in
both cases.

(cherry picked from commit e4d22a9f321e3d7c4a3e3bc1783c5204d79d80e3)

4 years agosystemctl-edit: fix abort in find_paths_to_edit()
Anita Zhang [Thu, 14 Jan 2021 08:02:09 +0000 (00:02 -0800)]
systemctl-edit: fix abort in find_paths_to_edit()

After 85c5d313b5c92115f5c77663e736bcf21e99f02f, if you, for example,
create a drop-in for -.slice without a corresponding -.slice file, you will
get the following:

  # put some valid stuff in /etc/systemd/system/-.slice.d/override.conf

  [root@image ~]# systemctl daemon-reload
  [root@image ~]# systemctl edit -- -.slice
  Assertion 'path' failed at src/systemctl/systemctl-edit.c:425, function
  find_paths_to_edit(). Aborting.
  Aborted

The aforementioned commit sets the ret_dropin_paths argument for
unit_find_paths(). Thus, unit_find_paths() returns 1 in the example above
because it finds a relevant drop-in. However find_paths_to_edit() was written
to expect 1 only if the unit file itself exists (it does not in this example).

To make this behave more like the version of `systemctl edit` prior to
this commit, add an additional check so the code enters the
"unit file not found" code branch.

(cherry picked from commit 98199724cb9fdad910e8f4b222d39d9d1e77f1c4)

4 years agoimport: mangle untarred OS images after pull-tar, too
Lennart Poettering [Tue, 12 Jan 2021 17:49:11 +0000 (18:49 +0100)]
import: mangle untarred OS images after pull-tar, too

We do this for import-tar and import-fs, we should do it for pull-tar,
too.

Fixes: #17563
(cherry picked from commit c33e405f20631ab5bbb9d3b326e805c57dc4fac5)

4 years agodhcp6: refuse zero length vendor class
Yu Watanabe [Tue, 12 Jan 2021 13:38:29 +0000 (22:38 +0900)]
dhcp6: refuse zero length vendor class

Also, fixes the maximum length of the vendor class to UINT16_MAX.
Moreover, a memory leak in sd_dhcp6_client_set_request_vendor_class().

(cherry picked from commit 019951ec97a98775063271e5f36096ac3ba0b510)

4 years agodhcp6: refuse zero length dhcp user class
Yu Watanabe [Tue, 12 Jan 2021 13:03:43 +0000 (22:03 +0900)]
dhcp6: refuse zero length dhcp user class

This also fixes a memory leak when
sd_dhcp6_client_set_request_user_class() is called multiple times.

(cherry picked from commit 5a99444e4fe80c2ed416ca402b437e780a9de4b8)

4 years agonetwork: refuse zero length dhcp user class
Yu Watanabe [Tue, 12 Jan 2021 12:55:15 +0000 (21:55 +0900)]
network: refuse zero length dhcp user class

(cherry picked from commit b79951fa328f60577082a5710852e1d020d60b65)

4 years agodhcp: length of each user class field must be positive
Yu Watanabe [Tue, 12 Jan 2021 12:47:23 +0000 (21:47 +0900)]
dhcp: length of each user class field must be positive

This also fixes an memory leak when sd_dhcp_client_set_user_class()
is called multiple times.

(cherry picked from commit e4336c0a5df42f4c88ed31c4bad743b93b69718f)

4 years agojournal: send journald logs to kmsg again
Franck Bui [Fri, 4 Dec 2020 08:48:52 +0000 (09:48 +0100)]
journal: send journald logs to kmsg again

This was broken by commit bc694c06e60505efeb09e5278a7b22cdfa23975e.

(cherry picked from commit b3d6eb01653f249cd8df898525c4565dcaf082bf)

4 years agotimedate: actually reset system time with new timezone
Yu Watanabe [Tue, 12 Jan 2021 12:00:27 +0000 (21:00 +0900)]
timedate: actually reset system time with new timezone

Fix a bug introduced by 56b0ef2fc283425df6ae6f1dc198e0c408f70471.

Closes CID#1436943.

(cherry picked from commit df49792e01c2f6e49f21271e4d0abe0723b854b3)

4 years agowifi-util: do not ignore wifi iftype when SSID is not set
Yu Watanabe [Mon, 11 Jan 2021 14:36:42 +0000 (23:36 +0900)]
wifi-util: do not ignore wifi iftype when SSID is not set

Previously, if an interface does not have SSID, e.g. run in mesh-point
type, then the wifi iftype obtained by the netlink call was ignored.

Fixes #18059.

(cherry picked from commit a66a402da471f6230ab8674fd2c1df6d918773b5)

4 years agowifi-util: cleanup header inclusion
Yu Watanabe [Mon, 11 Jan 2021 14:26:54 +0000 (23:26 +0900)]
wifi-util: cleanup header inclusion

(cherry picked from commit a5330078158cbd5070e42fd3f91ecb570e210359)

4 years agodocs: `mesonconf` is not a valid command, `meson configure` is
igo95862 [Mon, 11 Jan 2021 13:04:33 +0000 (16:04 +0300)]
docs: `mesonconf` is not a valid command, `meson configure` is

Meson documentation for `meson configure`
https://mesonbuild.com/Commands.html#configure

(cherry picked from commit 5adfb06d5582adf09421d189b5e2fc6b93fa23e8)

4 years agobpf: do not use structured initialization for bpf_attr
Luca Boccassi [Sun, 10 Jan 2021 15:36:31 +0000 (15:36 +0000)]
bpf: do not use structured initialization for bpf_attr

It looks like zero'ing the struct is not enough, and with some level
of optimizations there is still non-zero padding left over.
Switch to member-by-member initialization. Also convert all remaining
bpf_attr variables in other files.

(cherry picked from commit 9ca600e2bfacc52a65c89f3485723b2c27394e55)

4 years agotest-xattr-util: don't insist that /usr supports xattrs
Lennart Poettering [Sat, 9 Jan 2021 15:32:55 +0000 (16:32 +0100)]
test-xattr-util: don't insist that /usr supports xattrs

(apparently overlayfs has issues with xattrs, hence don't require that
/usr supports xattrs)

(cherry picked from commit 84319c5c07e7283f31930c799dfd948d251d9b73)

4 years agobpf: zero bpf_attr before initialization
Luca Boccassi [Fri, 8 Jan 2021 23:47:03 +0000 (23:47 +0000)]
bpf: zero bpf_attr before initialization

When building with Clang and using structured initialization, the
bpf_attr union is not zero-padded, so the kernel misdetects it as
an unsupported extension.
zero it until Clang's behaviour matches GCC. Do not skip the test
on Github Actions anymore.

(cherry picked from commit 28abf5ad3483a417d3d4de561533d282493a7f2a)

4 years agoshell-completion: fix systemctl set/unset/import-environment
Zbigniew Jędrzejewski-Szmek [Tue, 5 Jan 2021 11:34:28 +0000 (12:34 +0100)]
shell-completion: fix systemctl set/unset/import-environment

unset-environment is completed with variable names in the environment block.
set-environment the same, but suffixed with "=".
import-environment is completed with variable names in the client environment.

(cherry picked from commit 341992081b6ece1adba270e239f96c9840884885)

4 years agoman: improve description of environment block creation
Zbigniew Jędrzejewski-Szmek [Tue, 5 Jan 2021 10:17:14 +0000 (11:17 +0100)]
man: improve description of environment block creation

This adds a general description of "philosphy" of keeping the environemnt
block small and hints about systemd-run -P env.

The list of generated variables is split out to a subsection. Viewing
the patch with ignoring whitespace changes is recommended.

We don't ignore invalid assignments (except in import-environment to some
extent), previous description was wrong.

For https://bugzilla.redhat.com/show_bug.cgi?id=1912046#c17.

(cherry picked from commit 82651d5b6b20ef959252e0a6845b906788235c70)

4 years agostat-util: don't try to open path on path_is_temporary_fs()
Lennart Poettering [Wed, 6 Jan 2021 17:05:56 +0000 (18:05 +0100)]
stat-util: don't try to open path on path_is_temporary_fs()

I mean, the old code at least used O_PATH, but still, we shouldn't
allocate/close an fd if we don't have to.

(cherry picked from commit 15308e5083391f6a1b9ce25c5b7323f37544eab8)

4 years agosystemctl: have is-enabled return success for aliases when calling into pid1 too
Luca Boccassi [Tue, 5 Jan 2021 13:44:26 +0000 (13:44 +0000)]
systemctl: have is-enabled return success for aliases when calling into pid1 too

commit 15d7ab87c4e5917f5788f1f8dce327a1e272bea3 introduced the
change to add an 'alias' state, but it was wired to systemctl
only when running in 'client-side' mode. Return success as
expected and documented also when running in 'server-mode'.

Fixes https://github.com/systemd/systemd/issues/18134

(cherry picked from commit bf3b428f73eb51f4abb64a80ea5be346b9eeb2fe)

4 years agoman: fix path reference to unit file
Gaël PORTAY [Thu, 5 Mar 2020 17:38:31 +0000 (12:38 -0500)]
man: fix path reference to unit file

The unit files are located at path /usr/lib/systemd/system.

This fixes the path reference to the unit file by adding the missing
path component system.

(cherry picked from commit 0215f04a7ebd1ab1da4b4279d5057953ae1ebcaa)

4 years agodocs: fix the link to boot loader specification
Gaël PORTAY [Wed, 30 Dec 2020 14:29:36 +0000 (09:29 -0500)]
docs: fix the link to boot loader specification

The boot loader specification link points to the boot loader interface
documentation.

This fixes the link to point to BOOT_LOADER_SPECIFICATION instead of
BOOTLOADER_INTERFACE which is itself.

(cherry picked from commit 7745379ea8c1d08ecde9ccd15af1a76cdac91cc5)

4 years agonetwork: fix possible memory leak
Yu Watanabe [Tue, 29 Dec 2020 17:11:32 +0000 (02:11 +0900)]
network: fix possible memory leak

When set_put() returns 0, then already stored rule will be unref()ed
from Manager.

(cherry picked from commit fdce9324c7132a9a6d3b2fe9f8449dcfc8309114)

4 years agoresolve: field size in dns resource record may be zero
Yu Watanabe [Tue, 29 Dec 2020 16:48:35 +0000 (01:48 +0900)]
resolve: field size in dns resource record may be zero

(cherry picked from commit b652cccab9ed4091ec347f6e924be131105279e9)

4 years agosiphash: introduce siphash24_compress_safe()
Yu Watanabe [Tue, 29 Dec 2020 16:44:04 +0000 (01:44 +0900)]
siphash: introduce siphash24_compress_safe()

(cherry picked from commit 0b71a7e01d8d04a3668c349e2320c42c786f2382)

4 years agofuzzers: set maximum length for several fuzzers
Yu Watanabe [Tue, 29 Dec 2020 08:26:43 +0000 (17:26 +0900)]
fuzzers: set maximum length for several fuzzers

Hopefully fixes oss-fuzz#19081, oss-fuzz#21731, oss-fuzz#21755.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19081
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21731
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21755

(cherry picked from commit 57dda0de3896e57f6d3f0625b2d5e13bbdb48d79)

4 years agoshared/dns: fix dlopen_idn return code check
Luca Boccassi [Mon, 28 Dec 2020 00:23:14 +0000 (00:23 +0000)]
shared/dns: fix dlopen_idn return code check

Fixes https://github.com/systemd/systemd/issues/18078

(cherry picked from commit 5def1f11f84fd4000a0f7c9ed1294b04f0cea703)

4 years agoman/systemd-nspawn: document hashing machine name for uid base
Dmitry Borodaenko [Wed, 23 Dec 2020 01:54:04 +0000 (17:54 -0800)]
man/systemd-nspawn: document hashing machine name for uid base

Explicitly document the behavior introduced in #7437: when picking a new
UID shift base with "-U", a hash of the machine name will be tried
before falling back to fully random UID base candidates.

(cherry picked from commit 68709a636c838e0754b49caa6ff2d4168e3c99c8)

4 years agoudev: fix memleak
Yu Watanabe [Mon, 21 Dec 2020 06:28:19 +0000 (15:28 +0900)]
udev: fix memleak

Fixes #18039.

(cherry picked from commit 9df1e11e31588c5df39aa7efed05414273f93f69)

4 years agojournal-importer: ignore invalid field at one more place
Yu Watanabe [Mon, 21 Dec 2020 07:33:20 +0000 (16:33 +0900)]
journal-importer: ignore invalid field at one more place

Fixes oss-fuzz#28817.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28817

(cherry picked from commit 8786d4bbe43b5f6493982bcb5211e010f99deb57)

4 years agoman/localtime: document default timezone
Luca BRUNO [Mon, 21 Dec 2020 09:55:04 +0000 (09:55 +0000)]
man/localtime: document default timezone

This explicitly documents the default `UTC` timezone which is used
by systemd and (other softwares) when `/etc/localtime` is not present.

Ref: https://github.com/systemd/systemd/blob/v247/src/basic/time-util.c#L1460-L1469
(cherry picked from commit 3d909037e3bb86bb14ceef98325b2759b938a4b3)

4 years agoman/systemd.netdev: clarify the wireguard AllowedIPs= setting
Florian Klink [Sun, 20 Dec 2020 17:24:05 +0000 (18:24 +0100)]
man/systemd.netdev: clarify the wireguard AllowedIPs= setting

`AllowedIPs=` only affects "routing inside the network interface
itself", as in, which wireguard peer packets with a specific destination
address are sent to, and what source addresses are accepted from which
peer.

To cause packets to be sent via wireguard in first place, a route via
that interface needs to be added - either in the `[Routes]` section on
the `.network` matching the wireguard interface, or outside of networkd.

This is a common cause of misunderstanding, because tools like wg-quick
also add routes to the interface. However, those tools are meant as a
"extremely simple script for easily bringing up a WireGuard interface,
suitable for a few common use cases (from their manpage).

Networkd also should support other usecases - like setting AllowedIPs to
0.0.0.0/0 and ::/0 and having a dynamic routing protocol setting more
specific routes (or the user manually setting them).

Reported-In: https://github.com/systemd/systemd/issues/14176
(cherry picked from commit c6b90e5c5e54e98b6aed38677f77d8491f2e49c8)

4 years agologs-show: refuse data which contain invalid fields
Yu Watanabe [Tue, 15 Dec 2020 19:50:39 +0000 (04:50 +0900)]
logs-show: refuse data which contain invalid fields

(cherry picked from commit 805d67c565d57e0915162164f7e5e3026a29a2c5)

4 years agojournal: refuse data which contain invalid fields
Yu Watanabe [Tue, 15 Dec 2020 19:44:31 +0000 (04:44 +0900)]
journal: refuse data which contain invalid fields

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25353.

(cherry picked from commit f2bd032044ca3cd4b454dd0ba86719effcf34dc0)

4 years agojournal: move journal_field_valid() to journal_file.c
Yu Watanabe [Tue, 15 Dec 2020 19:36:14 +0000 (04:36 +0900)]
journal: move journal_field_valid() to journal_file.c

(cherry picked from commit adce225a104d0b7503aa7322db15d1c6dd8b8093)

4 years agotest: use modern qemu numa arguments
Christian Ehrhardt [Tue, 15 Dec 2020 11:05:14 +0000 (12:05 +0100)]
test: use modern qemu numa arguments

Upgrading to qemu 5.2 breaks TEST-36-NUMAPOLICY like:
  qemu-system-x86_64: total memory for NUMA nodes (0x0) should
  equal RAM size (0x20000000)

Use the new (as in >=2014) form of memdev in test 36:
 -object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0

Since some target systems are as old as qemu 1.5.3 (CentOS7) but the new
kind to specify was added in qemu 2.1 this needs to add version parsing and
add the argument only when qemu is >=5.2.

Fixes #17986.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
(cherry picked from commit 43b49470d1f2808555c07f64cd0a1529b7ddd559)

4 years agobus-util: improve logging when we can't connect to the bus
Lennart Poettering [Mon, 14 Dec 2020 15:36:00 +0000 (16:36 +0100)]
bus-util: improve logging when we can't connect to the bus

Previously, we'd already have explicit logging for the case where
$XDG_RUNTIME_DIR is not set. Let's also add some explicit logging for
the EPERM/ACCESS case. Let's also in both cases suggest the
--machine=<user>@.host syntax.

And while we are at it, let's remove side-effects from the macro.

By checking for both the EPERM/EACCES case and the $XDG_RUNTIME_DIR case
we will now catch both the cases where people use "su" to issue a
"systemctl --user" operation, and those where they (more correctly, but
still not good enough) call "su -".

Fixes: #17901
(cherry picked from commit 1ecb46724cae151606bc825f0e39f14d4dfe1a0e)

4 years agosd-bus: make credential acquisition more graceful
Lennart Poettering [Mon, 14 Dec 2020 12:16:39 +0000 (13:16 +0100)]
sd-bus: make credential acquisition more graceful

So far when asked for augmented bus credentials and the process was
already gone we'd fail fatally. Let's make this graceful instead, and
never allow augmenting fail due to PID having vanished — unless the
augmenting is the explicit and only purpose of the requested operation.

This should be safe as clients have to explicitly query the acquired
creds anyway and handle if they couldn't be acquired. Moreover we
already handle permission problems gracefully, thus clients must be
ready to deal with missing creds.

This is useful to make selinux authorization work for short-lived client
proceses. PReviously we'd augment creds to have more info to log about
(the selinux decision would not be based on augmented data however,
because that'd be unsafe), and would fail if we couldn't get it. Now,
we'll try to acquire the data, but if we cannot acquire it, we'll still
do the selinux check, except that logging will be more limited.

(cherry picked from commit f8ecc2c00df7bd810557f3056ec12f6a0730812d)

4 years agosd-bus: 'ret' parameter to sd_bus_query_sender_creds() is not optional, check for it
Lennart Poettering [Mon, 14 Dec 2020 12:20:28 +0000 (13:20 +0100)]
sd-bus: 'ret' parameter to sd_bus_query_sender_creds() is not optional, check for it

(cherry picked from commit 1ca37419b13b836d7fb2b9815d5efb6dccc62134)

4 years agonetwork: fix IPv6PrivacyExtensions=kernel handling
Florian Klink [Wed, 23 Dec 2020 11:57:47 +0000 (12:57 +0100)]
network: fix IPv6PrivacyExtensions=kernel handling

When set to "kernel", systemd is not supposed to touch that sysctl.

5e0534f1c13cd50ec2b143a8b18156cd37e502f7, part of
https://github.com/systemd/systemd/pull/17240 forgot to handle that
case.

Fixes https://github.com/systemd/systemd/issues/18003

(cherry picked from commit d3ccb1b4ba71b7bdf263aab8b1b17d1274d27a47)

4 years agonetwork: fix typo
Florian Klink [Wed, 23 Dec 2020 11:56:45 +0000 (12:56 +0100)]
network: fix typo

IPv6 privacy extensions are plural, not singular.

(cherry picked from commit 7eeaf72b88e43cb100763cec1db1b750928f2a1b)

4 years agodissect: fix root hash signature autodiscovery
Luca Boccassi [Sun, 10 Jan 2021 15:06:04 +0000 (15:06 +0000)]
dissect: fix root hash signature autodiscovery

The root hash signature is auto discovered only if the root hash was specified
manually. Ensure that an auto discovered root hash is also enough.

(cherry picked from commit 90f989861e1f7fd4465a8dddd1721b54ecb3f273)

4 years agocryptsetup: add support for workqueue options
Jonathan G. Underwood [Tue, 22 Dec 2020 20:04:52 +0000 (20:04 +0000)]
cryptsetup: add support for workqueue options

This commit adds support for disabling the read and write
workqueues with the new crypttab options no-read-workqueue
and no-write-workqueue. These correspond to the cryptsetup
options --perf-no_read_workqueue and --perf-no_write_workqueue
respectively.

(cherry picked from commit 227acf0009bde2cd7f8bc371615b05e84137847d)

4 years agotest-login: skip consistency checks when logind is not active
Zbigniew Jędrzejewski-Szmek [Wed, 16 Dec 2020 14:56:44 +0000 (15:56 +0100)]
test-login: skip consistency checks when logind is not active

There are two ways in swich sd_login_* functions acquire data:
some are derived from the cgroup path, but others use the data serialized
by logind.

When the tests are executed under Fedora's mock, without systemd-spawn
but instead in a traditional chroot, test-login gets confused:
the "outside" cgroup path is visible, so sd_pid_get_unit() and
sd_pid_get_session() work, but sd_session_is_active() and other functions
that need logind data fail.

Such a buildroot setup is fairly bad, but it can be encountered in the wild, so
let's just skip the tests in that case.

/* Information printed is from the live system */
sd_pid_get_unit(0, …) → "session-237.scope"
sd_pid_get_user_unit(0, …) → "n/a"
sd_pid_get_slice(0, …) → "user-1000.slice"
sd_pid_get_session(0, …) → "237"
sd_pid_get_owner_uid(0, …) → 1000
sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-237.scope"
sd_uid_get_display(1000, …) → "(null)"
sd_uid_get_sessions(1000, …) → [0] ""
sd_uid_get_seats(1000, …) → [0] ""
Assertion 'r >= 0' failed at src/libsystemd/sd-login/test-login.c:104, function test_login(). Aborting.

(cherry picked from commit ac5644635dba54ce5eb0ff394fc0bc772a984849)

4 years agojournalctl: don't skip the entries that have the same seqnum v247.2
shenyangyang4 [Thu, 10 Dec 2020 11:44:31 +0000 (06:44 -0500)]
journalctl: don't skip the entries that have the same seqnum

These two judgement can't judge that two entries are repeating fully.
So i think seqnum is needed to make full judgement.

(cherry picked from commit b17f651a17cd6ec0ceac7835f2f8607fbd9ddb95)

4 years agosd-bus: use SOCK_CLOEXEC on one more socket
Lennart Poettering [Fri, 11 Dec 2020 11:04:11 +0000 (12:04 +0100)]
sd-bus: use SOCK_CLOEXEC on one more socket

(cherry picked from commit 68a3d9153883b90c99ea2aec20075146ce58beaa)

4 years agoresolved: create stub-resolv.conf symlink with correct security label
Ondrej Mosnacek [Mon, 14 Dec 2020 15:36:27 +0000 (16:36 +0100)]
resolved: create stub-resolv.conf symlink with correct security label

Use symlink_atomic_label() instead of symlink_atomic() as the symlink
may need a different label than the parent directory.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
(cherry picked from commit 7b87bece5ded3e8f068df8402901198c069ab5cf)

4 years agoefi: Only use arm flags if supported
Andrew Balmos [Fri, 11 Dec 2020 03:15:24 +0000 (22:15 -0500)]
efi: Only use arm flags if supported

Support gcc 8 on arm

(cherry picked from commit 361f41645cdf920d431e2d68dcfa3f98088c2e03)

4 years agocore: detect_container() may return negative errno
Yu Watanabe [Mon, 14 Dec 2020 16:13:32 +0000 (01:13 +0900)]
core: detect_container() may return negative errno

(cherry picked from commit bcdb3b7d5076cf6ad17cb70df8db22d876880ada)

4 years agomeson: Fix reallocarray check
Khem Raj [Sun, 13 Dec 2020 00:15:57 +0000 (16:15 -0800)]
meson: Fix reallocarray check

reallocarray() is defined in stdlib.h, so that would be right header to
check for its presense.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
(cherry picked from commit 5bb20fd3d33f7e866a0845f15c1ab5b595147f1e)

4 years agonetwork: do not assume address ready callback is always set to static addresses
Yu Watanabe [Fri, 11 Dec 2020 05:22:35 +0000 (14:22 +0900)]
network: do not assume address ready callback is always set to static addresses

(cherry picked from commit b788a429d19acda8acb1c4b543da1adc2e49f4a9)

4 years agonetwork: drop assertions to check link state in netlink callback handlers
Yu Watanabe [Thu, 10 Dec 2020 05:16:22 +0000 (14:16 +0900)]
network: drop assertions to check link state in netlink callback handlers

As, the link may be dropped while configuring addresses or routes.

Fixes #17920.

(cherry picked from commit b2219cc4b6a2832c29eb82e90625d9c6ac61e73c)

4 years agonetwork: do not reconfigure interface when the link gains carrier but udev not initia...
Yu Watanabe [Fri, 11 Dec 2020 03:15:45 +0000 (12:15 +0900)]
network: do not reconfigure interface when the link gains carrier but udev not initialized it yet

When an interface gains carrier but udev have not initialized the
interface or link_initialized_handler() has not been called yet,
then link_configure will be called twice. Thus LLDP client will be
configured twice, and triggers assertion.

Fixes #17929.

(cherry picked from commit 8bceafa7771800c8bdfc1b74ef39824103f5c129)

4 years agoveritysetup: also place udev socket dep
Lennart Poettering [Thu, 10 Dec 2020 10:48:37 +0000 (11:48 +0100)]
veritysetup: also place udev socket dep

In light of #17848, also place udev socket dep in veritysetup, it's the
same issue after all.

(cherry picked from commit 8374bf4fa2663b19f329801abfd8b29e66897380)

4 years agocryptsetup: Fix crypto device missing issue after bootup
Jinyuan Si [Fri, 4 Dec 2020 02:38:28 +0000 (10:38 +0800)]
cryptsetup: Fix crypto device missing issue after bootup

Normally, the udev rules operate on "change" events. But when
coldplugging, there's an "add" event present. The udev rules have to
recognize this and do some actions in this particular situation, too.
Also, we don't want the nodes to be created prematurely on "add"
events while not coldplugging. The udev rules will check
DM_UDEV_PRIMARY_SOURCE_FLAG to see if the device was activated
correctly before and if not, it ignore the "add" event totally.
This way the udev rules can support udev triggers generating "add"
events (e.g. "udevadm trigger --action=add" or
"echo add > /sys/block/<dm_device>/uevent").

In this case, the udevd service is started after
systemd-cryptsetup@config.service, is started, which will cause udevd
service to miss the "change" uevent with DM_UDEV_PRIMARY_SOURCE_FLAG
flag generated by systemd-cryptsetup@config.service. To solve this
issue, we let the cryptsetup service be started after the udevd
service.

(cherry picked from commit 239952e890fd4b53859f84bbc43d910e68a8f6bc)

4 years agonetwork: fix SIGABRT related to unreachable route with DHCP6
Yu Watanabe [Fri, 4 Dec 2020 11:50:34 +0000 (20:50 +0900)]
network: fix SIGABRT related to unreachable route with DHCP6

After #17834, unreachable routes generated through DHCP6 are managed by
Manager. But they are referrenced by the DHCP6 uplink. So, the routes
managed by Manager must be freed after all Link objects are freed.

Follow-up for 575f14eef010101c60e9d4d970e542c815be1994.

Fixes SIGABRT reproted in #17831.

(cherry picked from commit 450fa34bd0315f2ca4728050b37c3a3d9e0f1b78)

4 years agonetwork: revert previous changes to address_compare_func()
Yu Watanabe [Fri, 4 Dec 2020 07:41:08 +0000 (16:41 +0900)]
network: revert previous changes to address_compare_func()

This partially reverts fe841414ef157f7f01d339c5d5730126e7b5fe0a and
2a236f9fc0ff8fb2152032551436fde74da7217a.

For IPv4, kernel compares the local address, prefix, and prefixlen.
For IPv6, kernel compares only the local address.
Let's follow the kernel's comparison way.

Fixes #17831.

(cherry picked from commit 1d30fc5cb64ecba2f03fe42aa0d8c65c3decad82)

4 years agoudev: Fix sound.target dependency
Takashi Iwai [Wed, 9 Dec 2020 09:56:51 +0000 (10:56 +0100)]
udev: Fix sound.target dependency

The recent bug report indicated a race at device creation and the
sound.target dependencies, and the cause turned out to be the condition
of the sound.target trigger.  Currently it's set for "card*", but this
is actually the parent object; i.e. the sound.target is triggered before
the sound devices are created.

For assuring the whole sound device creations beforehand, we need to use
"controlC*" instead of "card*"; as already described in
78-sound-card.rules, this is guaranteed to be the last device, and can
be used as a synchronization point.

BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1179363
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 5926e592fa5e6290b9f4588939945869adb5c55f)

4 years agomeson: specify correct libqrencode version in meson dep
Luca Boccassi [Wed, 9 Dec 2020 12:33:54 +0000 (13:33 +0100)]
meson: specify correct libqrencode version in meson dep

(cherry picked from commit a6c7811f0d3888e2fa545cd80d7815049b5cb084)

4 years agoudev: link_update() should fail if the entry in symlink dir couldn't have been created
Franck Bui [Wed, 9 Dec 2020 08:46:08 +0000 (09:46 +0100)]
udev: link_update() should fail if the entry in symlink dir couldn't have been created

Follow-up for 30f6dce62cb3a738b20253f2192270607c31b55b

(cherry picked from commit 4e1db59274c4b31ba5369270a489420245616eb4)

4 years agoman: document that automount units are privileged
Lennart Poettering [Wed, 9 Dec 2020 13:04:21 +0000 (14:04 +0100)]
man: document that automount units are privileged

Fixes: #17886
(cherry picked from commit eef34a1d8fe5ca44bdab189b682642096c53e661)

4 years agologind: fix closing of button input devices
Lennart Poettering [Mon, 7 Dec 2020 09:51:15 +0000 (10:51 +0100)]
logind: fix closing of button input devices

This is a fix of #17751. Specifically:

1. Sort #include headers again

2. Remove tabs, as per coding style

3. Don't install fds in half-initialized objects

4. Use asynchronous_close() everywhere

That all said:

Quit frankly, I am not convinced we should do all this at all. If
close()ing of these input devices is really that slow, then this should
probably be fixed in the kernel, not worked around in userspace like
this.

(cherry picked from commit c74d5fe25d53263c143f0a9c2698d8bb483e398c)

4 years agoUpdate logind-button.c
nihilix-melix [Fri, 27 Nov 2020 10:21:22 +0000 (11:21 +0100)]
Update logind-button.c

(cherry picked from commit eee582e7951fa8e328d1fcdfcff940254070ccba)

4 years agoasync: add trivial cleanup wrapper for asynchronous_close()
Lennart Poettering [Wed, 9 Dec 2020 09:07:12 +0000 (10:07 +0100)]
async: add trivial cleanup wrapper for asynchronous_close()

(cherry picked from commit 1d9aa4d572b661fd6500c55ab524141332f76230)

4 years agoSilence cgroups v1 read-only filesystem warning
Daan De Meyer [Mon, 7 Dec 2020 22:18:28 +0000 (22:18 +0000)]
Silence cgroups v1 read-only filesystem warning

Avoid warning messages when booting systemd-nspawn containers and using
hybrid or legacy cgroups. systemd-nspawn mounts the cgroups v1 controller
tree as read-only so these errors are expected and not problematic.
Partially fixes #17862.

Test plan:

- Before: `mkosi --default .mkosi/mkosi.fedora boot`

```
‣ Processing default...
Spawning container image on /home/daan/projects/systemd/image.raw.
Press ^] three times within 1s to kill container.
systemd 247 running in system mode. (+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
Detected virtualization systemd-nspawn.
Detected architecture x86-64.

Welcome to Fedora 33 (Thirty Three)!

Queued start job for default target Graphical Interface.
-.slice: Failed to migrate controller cgroups from , ignoring: Read-only file system
system.slice: Failed to delete controller cgroups /system.slice, ignoring: Read-only file system
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-modprobe.slice.
user.slice: Failed to delete controller cgroups /user.slice, ignoring: Read-only file system
[  OK  ] Created slice User and Session Slice.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Reached target Local Encrypted Volumes.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target Slices.
[  OK  ] Reached target Swap.
[  OK  ] Listening on Process Core Dump Socket.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on User Database Manager Socket.
dev-hugepages.mount: Failed to delete controller cgroups /dev-hugepages.mount, ignoring: Read-only file system
         Mounting Huge Pages File System...
sys-fs-fuse-connections.mount: Failed to delete controller cgroups /sys-fs-fuse-connections.mount, ignoring: Read-only file system
         Mounting FUSE Control File System...
         Starting Journal Service...
         Starting Remount Root and Kernel File Systems...
system.slice: Failed to delete controller cgroups /system.slice, ignoring: Read-only file system
```

After: `mkosi --default .mkosi/mkosi.fedora boot`

```
‣ Processing default...
Spawning container image on /home/daan/projects/systemd/mkosi.output/image.raw.
Press ^] three times within 1s to kill container.
systemd 247 running in system mode. (+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
Detected virtualization systemd-nspawn.
Detected architecture x86-64.

Welcome to Fedora 33 (Thirty Three)!

Queued start job for default target Graphical Interface.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-modprobe.slice.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Reached target Local Encrypted Volumes.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target Slices.
[  OK  ] Reached target Swap.
[  OK  ] Listening on Process Core Dump Socket.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on User Database Manager Socket.
         Mounting Huge Pages File System...
         Mounting FUSE Control File System...
         Starting Journal Service...
         Starting Remount Root and Kernel File Systems...
[  OK  ] Mounted Huge Pages File System.
[  OK  ] Mounted FUSE Control File System.
[  OK  ] Finished Remount Root and Kernel File Systems.
         Starting Create Static Device Nodes in /dev...
[  OK  ] Finished Create Static Device Nodes in /dev.
[  OK  ] Reached target Local File Systems (Pre).
[  OK  ] Reached target Local File Systems.
         Starting Restore /run/initramfs on shutdown...
[  OK  ] Finished Restore /run/initramfs on shutdown.
[  OK  ] Started Journal Service.
         Starting Flush Journal to Persistent Storage...
[  OK  ] Finished Flush Journal to Persistent Storage.
         Starting Create Volatile Files and Directories...
[  OK  ] Finished Create Volatile Files and Directories.
         Starting Network Name Resolution...
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Finished Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Timers.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
         Starting Home Area Manager...
         Starting User Login Management...
         Starting Permit User Sessions...
[  OK  ] Finished Permit User Sessions.
[  OK  ] Started Console Getty.
[  OK  ] Reached target Login Prompts.
         Starting D-Bus System Message Bus...
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Started Home Area Manager.
[  OK  ] Started User Login Management.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Finished Update UTMP about System Runlevel Changes.
[  OK  ] Started Network Name Resolution.
[  OK  ] Reached target Host and Network Name Lookups.

Fedora 33 (Thirty Three) (built from systemd tree)
Kernel 5.9.11-arch2-1 on an x86_64 (console)
```

(cherry picked from commit ecd3c86b60655d892f5ec68549226cc5fa4be818)

4 years agomanager: Fix HW watchdog when systemd starts before driver loaded
Michael Marley [Tue, 8 Dec 2020 02:27:38 +0000 (21:27 -0500)]
manager: Fix HW watchdog when systemd starts before driver loaded

When manager_{set|override}_watchdog is called, set the watchdog timeout
regardless of whether the hardware watchdog was successfully initialized.  If
the watchdog was requested but could not be initialized, then instead of
pinging it, attempt to initialize it again.  This ensures that the hardware
watchdog is initialized even if the kernel module for it isn't loaded when
systemd starts (which is quite likely, unless it is compiled in).

This builds on work by @danc86 in https://github.com/systemd/systemd/pull/17460,
but fixes the issue of not updating the watchdog timeout with the actual value
from the hardware.

Fixes https://github.com/systemd/systemd/issues/17838

Co-authored-by: Dan Callaghan <djc@djc.id.au>
Co-authored-by: Michael Marley <michael@michaelmarley.com>
(cherry picked from commit 61927b9f116bf45bfdbf19dc2981d4a4f527ae5f)

4 years agocgroup: Also set blkio.bfq.weight
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)

4 years agonss-resolve: varlink_call() set error_id only when r >= 0
Yu Watanabe [Sun, 6 Dec 2020 13:41:35 +0000 (22:41 +0900)]
nss-resolve: varlink_call() set error_id only when r >= 0

Fixes #17870.

(cherry picked from commit 3c229a9afb670025a3c1792bf5ac233b5a566ec5)

4 years agomissing: Define several syscall numbers for Alpha arch
Matt Turner [Sun, 6 Dec 2020 23:45:49 +0000 (18:45 -0500)]
missing: Define several syscall numbers for Alpha arch

(cherry picked from commit d6c0fdf4923420bd808094d02df9f05d739f4b17)

4 years agoDon't assume /run/systemd exists when creating unit-root
Daan De Meyer [Thu, 3 Dec 2020 23:08:21 +0000 (23:08 +0000)]
Don't assume /run/systemd exists when creating unit-root

When running tests in a mkosi container, /run/systemd might not
exist yet in the container which causes test-execute to fail.

Fixes #17842.

(cherry picked from commit 77f16dbd6d93f2b4a96984254cca25cab03479af)

4 years agomkosi: Add findutils to Fedora config
Daan De Meyer [Fri, 4 Dec 2020 22:23:11 +0000 (22:23 +0000)]
mkosi: Add findutils to Fedora config

find is needed by test_exec_dynamicuser.

(cherry picked from commit 8f2c4c5e93718ac6d6f790de61fced5ed143de5d)

4 years agomkosi: Add rpm to Fedora BuildPackages as it's needed by pkg-config
Daan De Meyer [Fri, 4 Dec 2020 20:05:19 +0000 (20:05 +0000)]
mkosi: Add rpm to Fedora BuildPackages as it's needed by pkg-config

(cherry picked from commit 8d036c446adc4dd8f9f1919916462752209c29a4)

4 years agomkosi: Replace iptables-dev with libiptc-dev in debian config
Daan De Meyer [Mon, 30 Nov 2020 23:03:52 +0000 (23:03 +0000)]
mkosi: Replace iptables-dev with libiptc-dev in debian config

Latest debian unstable doesn't have iptables-dev anymore. Instead,
let's use libiptc-dev.

(cherry picked from commit aef61dc888056454c543535e1410c3b299d623a5)

4 years agodissect: don't declare unused variables on archs that have no GPT discovery
Lennart Poettering [Thu, 3 Dec 2020 19:58:00 +0000 (20:58 +0100)]
dissect: don't declare unused variables on archs that have no GPT discovery

Fixes: #17839
(cherry picked from commit 62ea0ed08d0fba0bcf0a7fbde2d2ec1d317b66c7)

4 years agoresolved: synthesize NODATA instead of NXDOMAIN if gateway exists, but of other protocol
Lennart Poettering [Fri, 6 Nov 2020 09:26:44 +0000 (10:26 +0100)]
resolved: synthesize NODATA instead of NXDOMAIN if gateway exists, but of other protocol

Fixes: #11192
(cherry picked from commit 877884fc0da76170dce5abe7b3883eee334156b1)

4 years agolocal-addresses: make returning accumulated list optional
Lennart Poettering [Fri, 6 Nov 2020 09:26:40 +0000 (10:26 +0100)]
local-addresses: make returning accumulated list optional

(cherry picked from commit c3a8c6aa42092d87b73a3653d96258bbfe32fd28)

4 years agoresolved: improve log message when we use TCP a bit
Lennart Poettering [Tue, 10 Nov 2020 17:45:59 +0000 (18:45 +0100)]
resolved: improve log message when we use TCP a bit

DNS-over-TLS being in use isn't precisely the same as "UDP not
supported". Let's make this clearer.

(cherry picked from commit 6c0bacc146f1eea16f3b177a02fadf28901f9302)

4 years agonetwork: ignore broadcast address for /31 or /32 addresses
Yu Watanabe [Thu, 3 Dec 2020 01:19:35 +0000 (10:19 +0900)]
network: ignore broadcast address for /31 or /32 addresses

As they do not have broadcast address.
See https://tools.ietf.org/html/rfc3021

(cherry picked from commit 2a236f9fc0ff8fb2152032551436fde74da7217a)

4 years agonetwork: fix verification for broadcast address
Yu Watanabe [Wed, 2 Dec 2020 10:26:41 +0000 (19:26 +0900)]
network: fix verification for broadcast address

Fixes a bug caused by fe841414ef157f7f01d339c5d5730126e7b5fe0a.

(cherry picked from commit 05a7023d242b9012216c661f253df1c9c3d45b39)

4 years agonetwork: do not set broadcast if prefixlen is 31 or 32
Yu Watanabe [Wed, 2 Dec 2020 10:19:06 +0000 (19:19 +0900)]
network: do not set broadcast if prefixlen is 31 or 32

After fe841414ef157f7f01d339c5d5730126e7b5fe0a, broadcast address is
also compared with existing one to determine whether the address is
foregin or not. So, the address object should not contain unnecessary
information.

Fixes #17803.

(cherry picked from commit df8aa086420e6ce61e32898b2bb7c88b87fd1c43)

4 years agostub: don't ever respond to datagrams coming in on non-localhost addreses, on the...
Lennart Poettering [Thu, 5 Nov 2020 14:51:12 +0000 (15:51 +0100)]
stub: don't ever respond to datagrams coming in on non-localhost addreses, on the stub

(cherry picked from commit 565147b7bb2156277a2efaccd920d3ca9c21f8a8)

4 years agoresolved: never allow _gateway lookups to go to the network
Lennart Poettering [Wed, 11 Nov 2020 16:38:21 +0000 (17:38 +0100)]
resolved: never allow _gateway lookups to go to the network

Make them rather fail than go to the network.

Previously we'd filter them on LLMNR (explicitly) and MDNS (implicitly,
because it doesn't have .local suffix), but not on DNS.

In order to make _gateway truly reliable, let's not allow it to go to
DNS either, and keep it local.

This is particular relevant, as clients can now request lookups without
local RR synthesis, where we'd rather have NXDOMAIN returned for
_gateway than have it hit the network.

(cherry picked from commit fbbc72189f7844df8500bb10a58988f70bf90c99)