]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agotree-wide: sd_bus_error_setf → set_bus_error_set
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 13:59:27 +0000 (15:59 +0200)] 
tree-wide: sd_bus_error_setf → set_bus_error_set

strdup() is more efficient than asprintf().

3 years agotree-wide: use the same comment for work-around initializations
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 12:22:30 +0000 (14:22 +0200)] 
tree-wide: use the same comment for work-around initializations

This should make it easier to remove those warnings when the compiler
gets smarter. Not sure if I got them all...

Double space before the comment start to make it easier to separate from the
preceding line.

3 years agosd-device: small modernization
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 12:33:25 +0000 (14:33 +0200)] 
sd-device: small modernization

3 years agoshared/base-filesystem: modernization
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 11:15:28 +0000 (13:15 +0200)] 
shared/base-filesystem: modernization

3 years agoBump test-random-util timeout
Luca Boccassi [Tue, 6 Apr 2021 19:24:17 +0000 (20:24 +0100)] 
Bump test-random-util timeout

It is using log_trace, which we enabled in the CI, so now it's
slower and it is timing out. Bump the timeout from 30s to 120s.

3 years agoMerge pull request #19135 from bluca/coredump_decode
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 05:41:16 +0000 (07:41 +0200)] 
Merge pull request #19135 from bluca/coredump_decode

coredump: parse build-id and .note.package

3 years agoAdd markdown doc about coredump package metadata 19135/head
Luca Boccassi [Tue, 6 Apr 2021 14:48:52 +0000 (15:48 +0100)] 
Add markdown doc about coredump package metadata

3 years agocoredumpctl: parse and print package metadata
Luca Boccassi [Tue, 6 Apr 2021 17:02:41 +0000 (18:02 +0100)] 
coredumpctl: parse and print package metadata

3 years agocoredump: parse and append package metadata to journal message
Luca Boccassi [Tue, 6 Apr 2021 17:24:01 +0000 (18:24 +0100)] 
coredump: parse and append package metadata to journal message

Append 'package' and 'packageVersion' to the journal as discrete fields
COREDUMP_PKGMETA_PACKAGE and COREDUMP_PKGMETA_PACKAGEVERSION respectively,
and the full json blurb as COREDUMP_PKGMETA_JSON.

3 years agocoredump: parse .note.package ELF section
Luca Boccassi [Tue, 6 Apr 2021 17:21:48 +0000 (18:21 +0100)] 
coredump: parse .note.package ELF section

Parse the .note.package ELF section for each ELF object
contained in a core file, if present.

3 years agocoredump: parse build-id out of core file
Luca Boccassi [Thu, 18 Mar 2021 11:19:09 +0000 (11:19 +0000)] 
coredump: parse build-id out of core file

Parse the build-id of each ELF object contained in the core file
using the elfutils' libdwfl interface.
Add it to the journal.

3 years agoMerge pull request #19215 from braewoods/main
Luca Boccassi [Tue, 6 Apr 2021 17:52:11 +0000 (18:52 +0100)] 
Merge pull request #19215 from braewoods/main

hwdb: 60-keyboard:: Add quirks for 2 new HP laptops

3 years agotpm2-util: properly load tpm2 libraries befre unsealing
Lennart Poettering [Tue, 6 Apr 2021 09:46:19 +0000 (11:46 +0200)] 
tpm2-util: properly load tpm2 libraries befre unsealing

We forgot a call to dlopen_tpm2() in the unseal codepaths. As long as
automatic TPM2 device discovery was used that didn't matter, since in
that codepaths we'd have another call dlopen_tpm2(). But with an
explicitly configured TPM2 device things should work too, hence add the
missing call.

Fixes: #19206
3 years agorecovery-key: add some extra asserts
Lennart Poettering [Tue, 6 Apr 2021 09:45:54 +0000 (11:45 +0200)] 
recovery-key: add some extra asserts

Let's ensure our key sizes calculations are correct.

This doesn't actually change anything, just adds more safety checks.
Inspired by #19203, but not a fix.

3 years agoresolve: copy rd flag from the query to response
KoyamaSohei [Sat, 3 Apr 2021 16:13:37 +0000 (01:13 +0900)] 
resolve: copy rd flag from the query to response

3 years agobash-completion: localize words and cword variables
Sibo Dong [Sat, 3 Apr 2021 03:33:59 +0000 (23:33 -0400)] 
bash-completion: localize words and cword variables

The words and cword variables are not localized in all Bash completion
scripts that call _init_completion.

cur, prev, words, and cword (and split if using the -s flag) are all
variables that should be localized in Bash completion scripts before
calling _init_completion (even if they don't otherwise appear in the
calling script). This is done for cur and prev, but not for words and
cword. Letting words and cword remain unlocalized may clobber variables
the user is using for other purposes, which is bad.

This issue can be resolved by declaring words and cword as local
variables.

Resolves #19188.

3 years agosysusers/firstboot: temporarily disable LoadCredential
Luca Boccassi [Fri, 2 Apr 2021 15:30:43 +0000 (16:30 +0100)] 
sysusers/firstboot: temporarily disable LoadCredential

Single-param LoadCredential= in units causes systemd v247/v248 to
assert when parsing. Disable it for now, until the fix is merged
in the stable trees, released and available (eg: in Debian
for the CI)

See: https://github.com/systemd/systemd/issues/19178

3 years agoupdate
Lennart Poettering [Tue, 6 Apr 2021 09:45:27 +0000 (11:45 +0200)] 
update

3 years agohwdb: 60-keyboard:: Add HP ProBook 455 G5 hotkey quirks 19215/head
James Buren [Tue, 6 Apr 2021 07:18:26 +0000 (02:18 -0500)] 
hwdb: 60-keyboard:: Add HP ProBook 455 G5 hotkey quirks

This enables all of the known hotkeys that were not working out of the
box on my test unit.

3 years agohwdb: 60-keyboard:: Add HP mt44 Mobile Thin Client hotkey quirks
James Buren [Tue, 6 Apr 2021 06:32:37 +0000 (01:32 -0500)] 
hwdb: 60-keyboard:: Add HP mt44 Mobile Thin Client hotkey quirks

This enables all of the known hotkeys that were not working out of the
box on my test unit.

3 years agoqrcode-util: set case-sensitive for generating QR codes
Gibeom Gwon [Mon, 5 Apr 2021 14:11:23 +0000 (23:11 +0900)] 
qrcode-util: set case-sensitive for generating QR codes

Until now, string treated case-insensitive, always converted to
uppercase. This can cause confusion such as user enter uppercased
recovery key.

3 years agotest-firewall-util: skip if iptables nat table does not exist
Anita Zhang [Fri, 2 Apr 2021 09:49:37 +0000 (02:49 -0700)] 
test-firewall-util: skip if iptables nat table does not exist

3 years agoMerge pull request #19126 from anitazha/oomdimprovements
Zbigniew Jędrzejewski-Szmek [Tue, 6 Apr 2021 05:59:59 +0000 (07:59 +0200)] 
Merge pull request #19126 from anitazha/oomdimprovements

systemd-oomd post-test week improvements

3 years agotest: check if the unit file fuzzer corpora is up to date
Frantisek Sumsal [Fri, 2 Apr 2021 17:51:44 +0000 (19:51 +0200)] 
test: check if the unit file fuzzer corpora is up to date

This follows a similar pattern we already have in place for
networkd-related directives.

3 years agooomd: threshold swap kill candidates to usages of more than 5% 19126/head
Anita Zhang [Fri, 26 Mar 2021 09:37:01 +0000 (02:37 -0700)] 
oomd: threshold swap kill candidates to usages of more than 5%

In some instances, particularly with swap on zram, swap used will be high
while there is still a lot of memory available. FB OOMD handles this by
thresholding kills to X% of total swap usage. Let's do the same thing here.

Anecdotally with these thresholds and my laptop which is exclusively swap
on zram I can sit at 0K / 4G swap free with most of memory free and
systemd-oomd doesn't kill anything.

Partially addresses aggressive kill behavior from
https://bugzilla.redhat.com/show_bug.cgi?id=1941170

3 years agooomd: don't get pressure candidates on every interval
Anita Zhang [Fri, 26 Mar 2021 08:53:15 +0000 (01:53 -0700)] 
oomd: don't get pressure candidates on every interval

Only start collecting candidates for a memory pressure kill when we're
hitting the limit (but before the duration hitting that limit is
exceeded). This brings CPU util from ~1% to 0.3%.

Addresses CPU util from
https://bugzilla.redhat.com/show_bug.cgi?id=1941340
and
https://bugzilla.redhat.com/show_bug.cgi?id=1944646

3 years agofuzzer: add a test case for #19178
Frantisek Sumsal [Fri, 2 Apr 2021 16:07:26 +0000 (18:07 +0200)] 
fuzzer: add a test case for #19178

3 years agoMerge pull request #19179 from anitazha/buildandtest
Luca Boccassi [Fri, 2 Apr 2021 16:56:13 +0000 (17:56 +0100)] 
Merge pull request #19179 from anitazha/buildandtest

test-oomd-util: fix running in mkosi

3 years agoudev: fix slot based network names on s390
Viktor Mihajlovski [Thu, 18 Mar 2021 10:03:34 +0000 (11:03 +0100)] 
udev: fix slot based network names on s390

The s390 PCI driver assigns the hotplug slot name from the
function_id attribute of the PCI device using a 8 char hexadecimal
format to match the underlying firmware/hypervisor notation.

Further, there's always a one-to-one mapping between a PCI
function and a hotplug slot, as individual functions can
hot plugged even for multi-function devices.

As the generic matching code will always try to parse the slot
name in /sys/bus/pci/slots as a positive decimal number, either
a wrong value might be produced for ID_NET_NAME_SLOT if
the slot name consists of decimal numbers only, or none at all
if a character in the range from 'a' to 'f' is encountered.

Additionally, the generic code assumes that two interfaces
share a hotplug slot, if they differ only in the function part
of the PCI address. E.g., for an interface with the PCI address
dddd:bb:aa.f, it will match the device to the first slot with
an address dddd:bb:aa. As more than one slot may have this address
for the s390 PCI driver, the wrong slot may be selected.

To resolve this we're adding a new naming schema version with the
flag NAMING_SLOT_FUNCTION_ID, which enables the correct matching
of hotplug slots if the device has an attribute named function_id.
The ID_NET_NAME_SLOT property will only be produced if there's
a file /sys/bus/pci/slots/<slotname> where <slotname> matches
the value of /sys/bus/pci/devices/.../function_id in 8 char
hex notation.

Fixes #19016
See also #19078

3 years agoMerge pull request #18717 from yuwata/sd-device-monitor-introduce-more-filters
Zbigniew Jędrzejewski-Szmek [Fri, 2 Apr 2021 13:53:16 +0000 (15:53 +0200)] 
Merge pull request #18717 from yuwata/sd-device-monitor-introduce-more-filters

sd-device-monitor: introduce two new filters and use them in dissect-image.c

3 years agodocs: use current spelling "macOS" not "OS X" etc.
Carlo Teubner [Fri, 2 Apr 2021 08:03:02 +0000 (09:03 +0100)] 
docs: use current spelling "macOS" not "OS X" etc.

3 years agodissect-image: move parent device check into device_is_partition() 18717/head
Yu Watanabe [Sun, 21 Feb 2021 02:11:28 +0000 (11:11 +0900)] 
dissect-image: move parent device check into device_is_partition()

Checking parent for enumerated devices is mostly redundant. Just for
safety.

3 years agodissect-image: also check devtype in device_is_partition()
Yu Watanabe [Sun, 21 Feb 2021 02:16:18 +0000 (11:16 +0900)] 
dissect-image: also check devtype in device_is_partition()

This should be mostly redundant. Just for safety.

3 years agodissect-image: filter out enumerated or triggered devices without "partition" sysattr
Yu Watanabe [Sun, 21 Feb 2021 02:00:19 +0000 (11:00 +0900)] 
dissect-image: filter out enumerated or triggered devices without "partition" sysattr

This also adds more filters for device enumerator and monitor.
These newly added filters should be mostly redundant. But this hides
spurious error in sd_device_get_sysattr_value(). See,
https://github.com/systemd/systemd/pull/18684#discussion_r579700977

3 years agotest: add tests for filters of sd-device-monitor
Yu Watanabe [Wed, 24 Feb 2021 05:05:03 +0000 (14:05 +0900)] 
test: add tests for filters of sd-device-monitor

3 years agosd-device-monitor: introduce sd_device_monitor_filter_add_match_parent()
Yu Watanabe [Sun, 21 Feb 2021 00:54:55 +0000 (09:54 +0900)] 
sd-device-monitor: introduce sd_device_monitor_filter_add_match_parent()

3 years agosd-device-enumerator: also move match_parent() to device-util.[ch]
Yu Watanabe [Sun, 21 Feb 2021 00:53:50 +0000 (09:53 +0900)] 
sd-device-enumerator: also move match_parent() to device-util.[ch]

3 years agosd-device-monitor: introduce sd_device_monitor_filter_add_match_sysattr()
Yu Watanabe [Sun, 21 Feb 2021 00:33:04 +0000 (09:33 +0900)] 
sd-device-monitor: introduce sd_device_monitor_filter_add_match_sysattr()

3 years agosd-device-enumerator: move match_sysattr() to device-util.[ch]
Yu Watanabe [Sun, 21 Feb 2021 00:32:39 +0000 (09:32 +0900)] 
sd-device-enumerator: move match_sysattr() to device-util.[ch]

It will be used by sd-device-monitor in later commits.

3 years agosd-device-monitor: split passes_filter() into two parts
Yu Watanabe [Sat, 20 Feb 2021 22:53:31 +0000 (07:53 +0900)] 
sd-device-monitor: split passes_filter() into two parts

3 years agotest-oomd-util: fix running in mkosi 19179/head
Anita Zhang [Fri, 2 Apr 2021 02:06:26 +0000 (19:06 -0700)] 
test-oomd-util: fix running in mkosi

When this test is run in mkosi, the previously tested cgroup that we write
xattrs into and the root cgroup are the same.

Since the root cgroup is a live cgroup anyways (vs. the test cgroups which are
remade each time) let's generate the expected preference values from reading
the xattrs instead of assuming it will be NONE.

3 years agooomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec
Anita Zhang [Fri, 26 Mar 2021 08:19:10 +0000 (01:19 -0700)] 
oomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec

3 years agooomd: delete unused variables
Anita Zhang [Fri, 26 Mar 2021 07:54:46 +0000 (00:54 -0700)] 
oomd: delete unused variables

3 years agooomd: rename last_hit_mem_pressure_limit -> mem_pressure_limit_hit_start
Anita Zhang [Sat, 27 Mar 2021 09:02:00 +0000 (02:02 -0700)] 
oomd: rename last_hit_mem_pressure_limit -> mem_pressure_limit_hit_start

Since this is only changed the first time the limit is hit (and remains
set as long as the pressure remains over), I changed the name to better
reflect that.

Keeps consistent with "last_had_mem_reclaim" which is actually updated
every time there is reclaim activity.

3 years agooomd: rework memory reclaim detection logic
Anita Zhang [Fri, 26 Mar 2021 07:39:25 +0000 (00:39 -0700)] 
oomd: rework memory reclaim detection logic

systemd-oomd only monitors and kills within a selected cgroup subtree
For memory pressure kills, this means it's unnecessary to get the
pgscan rate across all the monitored memory pressure cgroups.
The increase will show up whether we do a total sum or not, but since
we only care about the increase in the subtree we're about to target
for a kill, we can simplify the code a bit by not doing this total sum.

3 years agooomd: refactor pgscan_rate calculation into helper
Anita Zhang [Fri, 26 Mar 2021 06:54:22 +0000 (23:54 -0700)] 
oomd: refactor pgscan_rate calculation into helper

3 years agooomd: split swap and mem pressure event timers
Anita Zhang [Wed, 24 Mar 2021 09:17:04 +0000 (02:17 -0700)] 
oomd: split swap and mem pressure event timers

One thing that came out of the test week is that systoomd needs to poll
more frequently so as not to race with the kernel oom killer in
situations where memory is eaten quickly. Memory pressure counters are
lagging so it isn't worthwhile to change the current read rate; however swap
is not lagging and can be checked more frequently.

So let's split these into 2 different timer events. As a result, swap
now also doesn't have to be subject to the post-action (post-kill) delay
that we need for memory pressure events.

Addresses some of slowness to kill discussed in
https://bugzilla.redhat.com/show_bug.cgi?id=1941340

3 years agomeson: link with libm for math functions
Anita Zhang [Fri, 2 Apr 2021 01:44:26 +0000 (18:44 -0700)] 
meson: link with libm for math functions

Fixes this error I got building on F33:
  /usr/bin/ld: test-random-util.p/src_test_test-random-util.c.o: undefined
  reference to symbol 'sqrt@@GLIBC_2.2.5'
  /usr/bin/ld: /usr/lib64/libm.so.6: error adding symbols: DSO missing
  from command line

3 years agosystemd-notify: Fix return value of --booted
Joerg Behrmann [Tue, 30 Mar 2021 14:29:59 +0000 (16:29 +0200)] 
systemd-notify: Fix return value of --booted

3 years agoMerge pull request #19175 from keszybz/maybe-unitialized-warning-2
Luca Boccassi [Thu, 1 Apr 2021 18:45:08 +0000 (19:45 +0100)] 
Merge pull request #19175 from keszybz/maybe-unitialized-warning-2

Third batch of fixes and suppressions for maybe-unitialized warnings

3 years agoresolved: use _cleanup_(gcry_md_closep) in one more place
Luca Boccassi [Thu, 1 Apr 2021 08:48:36 +0000 (09:48 +0100)] 
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

3 years agolibudev: fix return of udev_monitor_filter_add_match_subsystem_devtype()
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 19:28:11 +0000 (21:28 +0200)] 
libudev: fix return of udev_monitor_filter_add_match_subsystem_devtype()

Follow-up for 7117842657c0fc5a3446b6fe158615279cf2d650.

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.

3 years agoresolved: avoid passing unitialized variable 19175/head
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 09:12:57 +0000 (11:12 +0200)] 
resolved: avoid passing unitialized variable

The issue was introduced in the refactoring in 775ae35403f8f3c01b7ac13387fe8aac1759993f.
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.

3 years agovarious: silence gcc warnings
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:37:11 +0000 (10:37 +0200)] 
various: silence gcc warnings

AFAICT, gcc is just being stupid in all those cases.

3 years agoshared/dissect-image: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:53:42 +0000 (10:53 +0200)] 
shared/dissect-image: silence gcc warning

3 years agosd-netlink: drop unnecessary forward declaration
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:22:50 +0000 (10:22 +0200)] 
sd-netlink: drop unnecessary forward declaration

3 years agobacklight: refactor get_max_brightness() to appease gcc
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:19:07 +0000 (10:19 +0200)] 
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.

3 years agotest-device-util: let's verify that we return proper error from log_device_*
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:11:30 +0000 (10:11 +0200)] 
test-device-util: let's verify that we return proper error from log_device_*

3 years agosd-device: header needs an include because it uses sd_device type
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:09:11 +0000 (10:09 +0200)] 
sd-device: header needs an include because it uses sd_device type

3 years agoMerge pull request #19168 from keszybz/nss-resolve-unfoobar
Luca Boccassi [Thu, 1 Apr 2021 09:07:46 +0000 (10:07 +0100)] 
Merge pull request #19168 from keszybz/nss-resolve-unfoobar

Fix nss-resolve reverse alias lookups

3 years agoMerge pull request #19169 from keszybz/reenable-maybe-unitialized-warning
Luca Boccassi [Thu, 1 Apr 2021 08:36:46 +0000 (09:36 +0100)] 
Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warning

Fix a bunch of maybe-unitialized warnings but don't enable the warning yet

3 years agologind: Rename kexec reboot flag
Deepak Rawat [Wed, 31 Mar 2021 16:44:07 +0000 (09:44 -0700)] 
logind: Rename kexec reboot flag

Also change error message to be more meanigful. No change in
functionality.

Fixes: 0d96caa5c0
3 years agobasic/env-util: silence two gcc warnings 19169/head
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 16:13:00 +0000 (18:13 +0200)] 
basic/env-util: silence two gcc warnings

3 years agocryptsetup: silence gcc maybe-unused warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 16:07:57 +0000 (18:07 +0200)] 
cryptsetup: silence gcc maybe-unused warning

Simplify one debug stmt while at it.

3 years agosystemctl: silence gcc maybe-unused warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 16:07:25 +0000 (18:07 +0200)] 
systemctl: silence gcc maybe-unused warning

3 years agoshared/pretty-print: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:46:04 +0000 (17:46 +0200)] 
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?

3 years agocore: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:37:25 +0000 (17:37 +0200)] 
core: silence gcc warning

3 years agoshared/bus-message-util: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:32:04 +0000 (17:32 +0200)] 
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.

3 years agoshared/conf-parser: fix unitialized variable
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:24:26 +0000 (17:24 +0200)] 
shared/conf-parser: fix unitialized variable

Introduced in 4f9ff96a55187927a4164a19df580329f4c6522b.

3 years agotest-capability: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:13:24 +0000 (17:13 +0200)] 
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

3 years agobasic/cgroup-util: silence gcc warning about unitialized variable
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 12:21:21 +0000 (14:21 +0200)] 
basic/cgroup-util: silence gcc warning about unitialized variable

3 years agosd-event: silence gcc's maybe-unitialized warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 12:06:39 +0000 (14:06 +0200)] 
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.

3 years agovarlink: use two local flag variables to silence gcc warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 10:43:00 +0000 (12:43 +0200)] 
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;
      |                 ^

3 years agoman: split the description of sd_bus_error_set()
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:46:31 +0000 (11:46 +0200)] 
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.

3 years agosd-bus: add asserts showing that sd_bus_error_setf() returns negative
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:45:15 +0000 (11:45 +0200)] 
sd-bus: add asserts showing that sd_bus_error_setf() returns negative

(when name is specified).

3 years agosd-bus: add assert to tell the compiler that the error code is positive
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:27:15 +0000 (11:27 +0200)] 
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.

3 years agobasic/fileio: silence gcc's maybe-unitialized warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:09:39 +0000 (11:09 +0200)] 
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)
      |                     ^~~~~~~~~~~~~~~~~~~

3 years agobasic/socket-util: add hint to silence gcc's maybe-unitialized warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:06:41 +0000 (11:06 +0200)] 
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;
      |                ^~~~~~~~~~~~

3 years agoresolved: drop unnecessary {}
Zbigniew Jędrzejewski-Szmek [Mon, 29 Mar 2021 18:58:44 +0000 (20:58 +0200)] 
resolved: drop unnecessary {}

3 years agonss-resolve: define variables in the body 19168/head
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 14:48:04 +0000 (16:48 +0200)] 
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.

3 years agonss-resolve: fix parsing of io.systemd.Resolve.ResolveAddress reply
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 14:20:30 +0000 (16:20 +0200)] 
nss-resolve: fix parsing of io.systemd.Resolve.ResolveAddress reply

Since the switch to varlink in 0c73f4f075a2d23f7cabe708b589f19f4bbbec37, 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.)

3 years agoportabled: add --extension parameter for layered images support
Luca Boccassi [Tue, 23 Jun 2020 12:09:42 +0000 (13:09 +0100)] 
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.

3 years agogcrypt: do not ignore return values
Luca Boccassi [Sat, 27 Mar 2021 19:11:08 +0000 (19:11 +0000)] 
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

3 years agorpm: when disabling a unit, do not complain if systemd is not running
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 16:09:13 +0000 (17:09 +0100)] 
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.

3 years agoresolved.conf: Add hostnames for default DNS servers
Jan Janssen [Fri, 26 Mar 2021 15:37:33 +0000 (16:37 +0100)] 
resolved.conf: Add hostnames for default DNS servers

3 years agologind: Add new flag for kexec reboot
Deepak Rawat [Tue, 30 Mar 2021 03:22:16 +0000 (20:22 -0700)] 
logind: Add new flag for kexec reboot

Add new flag to allow kexec reboot if kernel is already loaded.

3 years agoMerge pull request #19109 from poettering/resolved-transaction-log-tweaks
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:47:12 +0000 (10:47 +0200)] 
Merge pull request #19109 from poettering/resolved-transaction-log-tweaks

resolved: minor tweaks to transaction logic and logging

3 years agoshared: add new IMAGE_VERSION=/IMAGE_ID= field to /etc/os-release
Lennart Poettering [Tue, 23 Mar 2021 15:10:31 +0000 (16:10 +0100)] 
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.

3 years agoMerge pull request #19064 from yuwata/resolve-fix-cache-19049
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:42:21 +0000 (10:42 +0200)] 
Merge pull request #19064 from yuwata/resolve-fix-cache-19049

resolve: several trivial cleanups

3 years agoudevd: don't kill worker in manager_kill_workers when it's running
gaoyi [Fri, 19 Mar 2021 07:16:56 +0000 (15:16 +0800)] 
udevd: don't kill worker in manager_kill_workers when it's running

If worker is running, kill worker may lead uevent unprocessed.

3 years agoMerge pull request #18990 from yuwata/network-dhcpv6-use-domains
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:38:37 +0000 (10:38 +0200)] 
Merge pull request #18990 from yuwata/network-dhcpv6-use-domains

network: also introduce UseDomains= for [DHCPv6] section

3 years agoMerge pull request #19101 from poettering/mount-util-fixes
Lennart Poettering [Wed, 31 Mar 2021 08:37:49 +0000 (10:37 +0200)] 
Merge pull request #19101 from poettering/mount-util-fixes

Make recursive bind remounting handle failures gracefully

3 years agodissect: make the --image= switch of our various tools honour Verity data
Lennart Poettering [Tue, 23 Mar 2021 13:07:53 +0000 (14:07 +0100)] 
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.

3 years agoMerge pull request #18989 from yuwata/ordered-set-put-strdup
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:36:03 +0000 (10:36 +0200)] 
Merge pull request #18989 from yuwata/ordered-set-put-strdup

ordered-set: make ordered_set_put_strdup() allocate OrderedSet object

3 years agorepart: make sure CopyFiles= works with a / suffixed path
Lennart Poettering [Tue, 23 Mar 2021 13:05:56 +0000 (14:05 +0100)] 
repart: make sure CopyFiles= works with a / suffixed path

If we define a partition with CopyFiles=/efi/ this should just work.
However it previously didn't because basename() would return the
trailing slash.

Let's fix this by moving things to path_extract_{directory|filename}()

3 years agomachine-id-setup: support --image= mode
Lennart Poettering [Fri, 19 Mar 2021 17:34:06 +0000 (18:34 +0100)] 
machine-id-setup: support --image= mode

3 years agoMerge pull request #18971 from poettering/sysusers-creds
Lennart Poettering [Wed, 31 Mar 2021 08:35:17 +0000 (10:35 +0200)] 
Merge pull request #18971 from poettering/sysusers-creds

let's read LoadCredentials=/SetCredentials= style cred in sysusers/firstboot and when asking for passwords

3 years agoMerge pull request #18982 from keszybz/test-nss-users
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:32:09 +0000 (10:32 +0200)] 
Merge pull request #18982 from keszybz/test-nss-users

Add a new test for user/group resolution in nss modules

3 years agoMerge pull request #18958 from poettering/dissect-no-root
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:31:32 +0000 (10:31 +0200)] 
Merge pull request #18958 from poettering/dissect-no-root

dissect-image: support images without rootfs but with /usr partition + support simple partition versioning via strverscmp() on part label

3 years agocompress: support streaming lz4 without full input mmap
Luca Boccassi [Tue, 9 Mar 2021 14:57:44 +0000 (14:57 +0000)] 
compress: support streaming lz4 without full input mmap

The advantage of stream compression is keeping a low memory profile,
but the lz4 stream compressor usage mmaps the whole file in memory.

Change it to read bits by bits, like the other stream compression
helpers.