1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00
Commit Graph

50401 Commits

Author SHA1 Message Date
Yu Watanabe
bcfe746ba7 sd-device-enumerator: also move match_parent() to device-util.[ch] 2021-04-02 15:10:09 +09:00
Yu Watanabe
d9b030b673 sd-device-monitor: introduce sd_device_monitor_filter_add_match_sysattr() 2021-04-02 15:10:09 +09:00
Yu Watanabe
ac790e8bfc sd-device-enumerator: move match_sysattr() to device-util.[ch]
It will be used by sd-device-monitor in later commits.
2021-04-02 15:10:07 +09:00
Yu Watanabe
112e6dd106 sd-device-monitor: split passes_filter() into two parts 2021-04-02 15:09:03 +09:00
Joerg Behrmann
8ab34a49db systemd-notify: Fix return value of --booted 2021-04-01 20:42:22 +01:00
Luca Boccassi
28a9744673
Merge pull request #19175 from keszybz/maybe-unitialized-warning-2
Third batch of fixes and suppressions for maybe-unitialized warnings
2021-04-01 19:45:08 +01:00
Luca Boccassi
677ba9d062 resolved: use _cleanup_(gcry_md_closep) in one more place
Documentation says gcry_md_close will ignore a NULL input so should be safe:

https://gnupg.org/documentation/manuals/gcrypt/Working-with-hash-algorithms.html

Makes Coverity happy, follow-up for 248b1e0aa4

CID #1451555
2021-04-01 15:00:51 +01:00
Zbigniew Jędrzejewski-Szmek
0f4b6e59bd libudev: fix return of udev_monitor_filter_add_match_subsystem_devtype()
Follow-up for 7117842657.

sd_device_monitor_filter_add_match_subsystem_devtype() now returns 1 to signify
that something was done, and 0 to signify that nothing was done, but
udev_monitor_filter_add_match_subsystem_devtype() needs to return 0 as documented.

udev_monitor_filter_add_match_tag() is adjusted to match.

This makes gdm start successfully here again.
Before, it would just not boot, with nothing very obvious in the logs:
gdm[1756]: Gdm: GdmDisplay: Session never registered, failing

Replaces #19171.
2021-04-01 14:59:58 +01:00
Zbigniew Jędrzejewski-Szmek
e7d48709ed resolved: avoid passing unitialized variable
The issue was introduced in the refactoring in 775ae35403.
We would pass an initialized value to a helper function. We would only *use*
it if it was initialized. But the mere passing of an unitialized variable is
UB, so let's not do that. This silences a gcc warning.
2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
aff81b1851 various: silence gcc warnings
AFAICT, gcc is just being stupid in all those cases.
2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
1f8fb21c42 shared/dissect-image: silence gcc warning 2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
04ab97a829 sd-netlink: drop unnecessary forward declaration 2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
c03916164d backlight: refactor get_max_brightness() to appease gcc
The old code was just fine, but gcc doesn't understand that max_brightness is
initialized. Let's rework it a bit to move some logic to the main function. Now
get_max_brightness() just retrieves and parses the attribute, and the main
function decides what to do with it.
2021-04-01 12:01:58 +02:00
Zbigniew Jędrzejewski-Szmek
0246f42980 test-device-util: let's verify that we return proper error from log_device_* 2021-04-01 11:44:42 +02:00
Zbigniew Jędrzejewski-Szmek
023e75df4c sd-device: header needs an include because it uses sd_device type 2021-04-01 11:30:25 +02:00
Luca Boccassi
4cf1b41568
Merge pull request #19168 from keszybz/nss-resolve-unfoobar
Fix nss-resolve reverse alias lookups
2021-04-01 10:07:46 +01:00
Luca Boccassi
bd506dfb5e
Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warning
Fix a bunch of maybe-unitialized warnings but don't enable the warning yet
2021-04-01 09:36:46 +01:00
Deepak Rawat
1d8a16f1f4 logind: Rename kexec reboot flag
Also change error message to be more meanigful. No change in
functionality.

Fixes: 0d96caa5c0
2021-03-31 21:43:45 +02:00
Zbigniew Jędrzejewski-Szmek
1dbd0bdb3a basic/env-util: silence two gcc warnings 2021-03-31 18:24:54 +02:00
Zbigniew Jędrzejewski-Szmek
c26f7dd9f0 cryptsetup: silence gcc maybe-unused warning
Simplify one debug stmt while at it.
2021-03-31 18:24:54 +02:00
Zbigniew Jędrzejewski-Szmek
703e2870b1 systemctl: silence gcc maybe-unused warning 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
1c93632ead shared/pretty-print: silence gcc warning
gcc was very unhappy for some reason:

[988/1664] Compiling C object systemd-oomd.p/src_oom_oomd.c.o
In file included from ../src/basic/path-util.h:10,
                 from ../src/shared/pretty-print.c:14,
                 from ../src/oom/oomd.c:15:
../src/shared/pretty-print.c: In function ‘conf_files_cat’:
../src/basic/strv.h:123:32: warning: ‘prefixes’ may be used uninitialized [-Wmaybe-uninitialized]
  123 |         for ((s) = (l); (s) && *(s); (s)++)
      |                                ^
In file included from ../src/oom/oomd.c:15:
../src/shared/pretty-print.c:283:16: note: ‘prefixes’ was declared here
  283 |         char **prefixes, **prefix;
      |                ^~~~~~~~
../src/shared/pretty-print.c:305:12: warning: ‘is_collection’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  305 |         if (!is_collection) {
      |            ^
../src/shared/pretty-print.c:301:13: warning: ‘extension’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  301 |         r = conf_files_list_strv(&files, extension, root, 0, (const char* const*) dirs);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe this is caused by the statis char** variables?
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
1a2948fece core: silence gcc warning 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
487c123a32 shared/bus-message-util: silence gcc warning
[1/429] Compiling C object src/shared/libsystemd-shared-248.a.p/bus-message-util.c.o
../src/shared/bus-message-util.c: In function ‘bus_message_read_dns_servers’:
../src/shared/bus-message-util.c:165:21: warning: ‘family’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  165 |                 r = in_addr_full_new(family, &a, port, 0, server_name, dns + n);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/shared/bus-message-util.c:165:21: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../src/shared/bus-message-util.c:165:21: warning: ‘server_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]

The warning would be there despite all the asserts in bus_error_setfv() and
sd_bus_error_set(). So let's add an explicit assert.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
9fd8d678ba shared/conf-parser: fix unitialized variable
Introduced in 4f9ff96a55.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
0a94e77ed4 test-capability: silence gcc warning
[2/3] Compiling C object test-capability.p/src_test_test-capability.c.o
../src/test/test-capability.c: In function ‘main’:
../src/test/test-capability.c:270:12: warning: ‘run_ambient’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  270 |         if (run_ambient)
      |            ^

gcc-11.0.1-0.3.fc34.x86_64
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
bc20c31bbc basic/cgroup-util: silence gcc warning about unitialized variable 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
bfd9bfccce sd-event: silence gcc's maybe-unitialized warning
[91/180] Compiling C object libsystemd.a.p/src_libsystemd_sd-event_sd-event.c.o
In file included from ../src/basic/macro.h:12,
                 from ../src/basic/alloc-util.h:9,
                 from ../src/libsystemd/sd-event/sd-event.c:11:
../src/libsystemd/sd-event/sd-event.c: In function ‘sd_event_wait’:
../src/fundamental/macro-fundamental.h:86:63: warning: ‘child_min_priority’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   86 |                 UNIQ_T(A, aq) < UNIQ_T(B, bq) ? UNIQ_T(A, aq) : UNIQ_T(B, bq); \
      |                                                               ^
../src/libsystemd/sd-event/sd-event.c:3983:45: note: ‘child_min_priority’ was declared here
 3983 |                 int64_t epoll_min_priority, child_min_priority;
      |                                             ^~~~~~~~~~~~~~~~~~

Alternative to #19159.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
4990d4b8ff varlink: use two local flag variables to silence gcc warning
[59/655] Compiling C object src/shared/libsystemd-shared-248.a.p/varlink.c.o
../src/shared/varlink.c: In function ‘varlink_write’:
../src/shared/varlink.c:459:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  459 |         if (n < 0) {
      |            ^
../src/shared/varlink.c: In function ‘varlink_process’:
../src/shared/varlink.c:541:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  541 |         if (n < 0) {
      |            ^
../src/shared/varlink.c:486:17: note: ‘n’ was declared here
  486 |         ssize_t n;
      |                 ^
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
af46237ea1 man: split the description of sd_bus_error_set()
It was one giant all of text in pseudo-random order. Let's split it into
paragraphs talk about one subject each.

And unfortunately, the description of what happens when the error is not
set was not correct. In general, various functions treat 0/NULL as
not-an-error, and return 0.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
b9c19bc384 sd-bus: add asserts showing that sd_bus_error_setf() returns negative
(when name is specified).
2021-03-31 18:24:44 +02:00
Zbigniew Jędrzejewski-Szmek
c7e964c944 sd-bus: add assert to tell the compiler that the error code is positive
I was hoping it would help with the following gcc warning:
[35/657] Compiling C object src/shared/libsystemd-shared-248.a.p/bus-message-util.c.o
../src/shared/bus-message-util.c: In function ‘bus_message_read_dns_servers’:
../src/shared/bus-message-util.c:165:21: warning: ‘family’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  165 |                 r = in_addr_full_new(family, &a, port, 0, server_name, dns + n);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/shared/bus-message-util.c:165:21: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../src/shared/bus-message-util.c:165:21: warning: ‘server_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]

It actually doesn't, but the compiler has a point here: the code is specified
in sd_bus_error_map[], and it has no way of knowning that we want it to be a
positive value.

I think this should be an assert, because if this assumption fails, a
programming error has occured, something that'd want to catch.
2021-03-31 18:22:53 +02:00
Zbigniew Jędrzejewski-Szmek
55e2cfc938 basic/fileio: silence gcc's maybe-unitialized warning
[11/657] Compiling C object src/basic/libbasic.a.p/fileio.c.o
../src/basic/fileio.c: In function ‘write_string_stream_ts’:
../src/basic/fileio.c:167:21: warning: ‘fd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  167 |                 if (futimens(fd, twice) < 0)
      |                     ^~~~~~~~~~~~~~~~~~~
2021-03-31 18:22:53 +02:00
Zbigniew Jędrzejewski-Szmek
befab2c40c basic/socket-util: add hint to silence gcc's maybe-unitialized warning
[59/1551] Compiling C object src/basic/libbasic.a.p/socket-util.c.o
../src/basic/socket-util.c: In function ‘socket_get_mtu’:
../src/basic/socket-util.c:1393:16: warning: ‘mtu’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1393 |         *ret = (size_t) mtu;
      |                ^~~~~~~~~~~~
2021-03-31 18:22:53 +02:00
Zbigniew Jędrzejewski-Szmek
adf6d848df resolved: drop unnecessary {} 2021-03-31 18:22:53 +02:00
Zbigniew Jędrzejewski-Szmek
75d2f0a0c4 nss-resolve: define variables in the body
Same motivation as in the parent commit: let's define variables later, ideally
right when they are first initialized, so it's easier to figure out that they
are properly initialized.

error_id and r_tuple* were previously initialized, but I don't see why they
would need to be.

No functional change intended.
2021-03-31 17:19:03 +02:00
Zbigniew Jędrzejewski-Szmek
77fac974fe nss-resolve: fix parsing of io.systemd.Resolve.ResolveAddress reply
Since the switch to varlink in 0c73f4f075, the
code wasn't functional. The JSON_VARIANT_UNSIGNED/JSON_VARIANT_STRING mismatch
meant that we'd reject any reply. Once past that, the code would use
unitialized 'c' and 'n' variables, so it's lucky we never got that far ;)

With -Wmaybe-unitialized, gcc would warn.

I think that declaring the huge list of local variables with very short names
at the top of the function was making it harder to understand what is going on
in the function. So let's rename the variables a bit, and initialize them upon
declaration if possible.

$ build/test-nss-hosts resolve 1.1.1.1 1.0.0.1 10.38.5.41
======== resolve ========
_nss_resolve_gethostbyaddr2_r("1.1.1.1") → status=NSS_STATUS_SUCCESS
                   errno=999/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "one.one.one.one"
        AF_INET 1.1.1.1

_nss_resolve_gethostbyaddr_r("1.1.1.1") → status=NSS_STATUS_SUCCESS
                   errno=999/--- h_errno=0/Resolver Error 0 (no error)
        "one.one.one.one"
        AF_INET 1.1.1.1

_nss_resolve_gethostbyaddr2_r("1.0.0.1") → status=NSS_STATUS_SUCCESS
                   errno=999/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "one.one.one.one"
        AF_INET 1.0.0.1

_nss_resolve_gethostbyaddr_r("1.0.0.1") → status=NSS_STATUS_SUCCESS
                   errno=999/--- h_errno=0/Resolver Error 0 (no error)
        "one.one.one.one"
        AF_INET 1.0.0.1

_nss_resolve_gethostbyaddr2_r("10.38.5.41") → status=NSS_STATUS_SUCCESS
                   errno=999/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "squid.redhat.com"
        alias "squid.corp.redhat.com"
        alias "squid2.corp.redhat.com"
        alias "squid3.corp.redhat.com"
        alias "squid4.corp.redhat.com"
        alias "squid5.corp.redhat.com"
        AF_INET 10.38.5.41

_nss_resolve_gethostbyaddr_r("10.38.5.41") → status=NSS_STATUS_SUCCESS
                   errno=999/--- h_errno=0/Resolver Error 0 (no error)
        "squid.redhat.com"
        alias "squid.corp.redhat.com"
        alias "squid2.corp.redhat.com"
        alias "squid3.corp.redhat.com"
        alias "squid4.corp.redhat.com"
        alias "squid5.corp.redhat.com"
        AF_INET 10.38.5.41

(I have 10.38.5.41 squid.redhat.com squid.corp.redhat.com squid2.corp.redhat.com squid3.corp.redhat.com squid4.corp.redhat.com squid5.corp.redhat.com
in /etc/hosts for testing.)
2021-03-31 16:28:14 +02:00
Luca Boccassi
907952bbc9 portabled: add --extension parameter for layered images support
Add an --extension parameter to portablectl, and new DBUS methods
to attach/detach/reattach/inspect.
Allows to append separate images on top of the root directory (os-release
will be searched in there) and mount the images using an overlay-like
setup (unit files will be searched in there) using the new ExtensionImages
service option.
2021-03-31 09:56:44 +01:00
Luca Boccassi
248b1e0aa4 gcrypt: do not ignore return values
Check the return code from gcrypt's functions. In some
cases just log, as it shoulnd't really happen.

Fixes various Coverity issues:

CID #1444702
CID #1444704
CID #1444706
CID #1444711
CID #1444712
CID #1444713
2021-03-31 10:51:35 +02:00
Zbigniew Jędrzejewski-Szmek
a59eb7d78f rpm: when disabling a unit, do not complain if systemd is not running
$ sudo dnf remove --installroot=/var/tmp/img1 systemd-networkd
...
  Running scriptlet: systemd-networkd-248~rc4-4.fc32.x86_64      1/1
Removed /etc/systemd/system/multi-user.target.wants/systemd-networkd.service.
Removed /etc/systemd/system/sockets.target.wants/systemd-networkd.socket.
Removed /etc/systemd/system/dbus-org.freedesktop.network1.service.
Removed /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service.
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

(Another option would be make --now do nothing if systemd is not running.
But I think that's not too good. 'disable --now' doing nothing would be OK,
since if systemd is not running, the service is not running either, so we are
in the desired state. But that argument doesn't work for 'enable --now'. And
accepting 'disable --now' but not 'enable --now' seems overly complex. So I
think it is better to make the scriptlet handle this case explicitly.)

Also, let's reindent the file to 4 spaces. Very deeply nested scriptlets are
harder to read, and the triggers file is indented to 4 spaces already.
2021-03-31 10:50:07 +02:00
Jan Janssen
a83ddc08d6 resolved.conf: Add hostnames for default DNS servers 2021-03-31 10:49:36 +02:00
Deepak Rawat
0d96caa5c0 logind: Add new flag for kexec reboot
Add new flag to allow kexec reboot if kernel is already loaded.
2021-03-31 10:48:48 +02:00
Zbigniew Jędrzejewski-Szmek
a93af34a40
Merge pull request #19109 from poettering/resolved-transaction-log-tweaks
resolved: minor tweaks to transaction logic and logging
2021-03-31 10:47:12 +02:00
Lennart Poettering
9a515f0a55 shared: add new IMAGE_VERSION=/IMAGE_ID= field to /etc/os-release
This specifes two new optional fields for /etc/os-release:
IMAGE_VERSION= and IMAGE_ID= that are supposed to identify the image of
the current booted system by name and version.

This is inspired by the versioning stuff in
https://github.com/systemd/mkosi/pull/683.

In environments where pre-built images are installed and updated as a
whole the existing os-release version/distro identifier are not
sufficient to describe the system's version, as they describe only the
distro an image is built from, but not the image itself, even if that
image is deployed many times on many systems, and even if that image
contains more resources than just the RPMs/DEBs.

In particular, "mkosi" is a tool for building disk images based on
distro RPMs with additional resources dropped in. The combination of all
of these together with their versions should also carry an identifier
and version, and that's what IMAGE_VERSION= and IMAGE_ID= is supposed to
be.
2021-03-31 10:46:22 +02:00
Zbigniew Jędrzejewski-Szmek
e872679629
Merge pull request #19064 from yuwata/resolve-fix-cache-19049
resolve: several trivial cleanups
2021-03-31 10:42:21 +02:00
gaoyi
f257a8fc13 udevd: don't kill worker in manager_kill_workers when it's running
If worker is running, kill worker may lead uevent unprocessed.
2021-03-31 10:41:44 +02:00
Zbigniew Jędrzejewski-Szmek
a2dc3adef2
Merge pull request #18990 from yuwata/network-dhcpv6-use-domains
network: also introduce UseDomains= for [DHCPv6] section
2021-03-31 10:38:37 +02:00
Lennart Poettering
16ede1d75a
Merge pull request #19101 from poettering/mount-util-fixes
Make recursive bind remounting handle failures gracefully
2021-03-31 10:37:49 +02:00
Lennart Poettering
27ec815eb4 dissect: make the --image= switch of our various tools honour Verity data
This adds simple Verity support to
mount_image_privately_interactively(): we dicover the verity metadata
and use it.
2021-03-31 10:36:14 +02:00
Zbigniew Jędrzejewski-Szmek
224e6c844d
Merge pull request #18989 from yuwata/ordered-set-put-strdup
ordered-set: make ordered_set_put_strdup() allocate OrderedSet object
2021-03-31 10:36:03 +02:00