systemd/.git
4 years agorepart: fix incorrect error code propagation
Lennart Poettering [Mon, 19 Apr 2021 15:35:54 +0000 (17:35 +0200)]
repart: fix incorrect error code propagation

(cherry picked from commit a0ff9971802b664aaa12481c46cec11eae77ea51)

4 years agoshell-completion: use base.lst, not xorg.lst
Peter Hutterer [Tue, 20 Apr 2021 07:09:48 +0000 (17:09 +1000)]
shell-completion: use base.lst, not xorg.lst

Since 2005 xorg.lst has been the legacy symlink to the real file base.lst.

(cherry picked from commit 7a4afd3a15f201a2230dce1f640fc37d18bc39ac)

4 years agosd-login: fix wrong constructor used in sd_login_monitor manpage example
Jason Francis [Mon, 19 Apr 2021 16:16:26 +0000 (12:16 -0400)]
sd-login: fix wrong constructor used in sd_login_monitor manpage example

(cherry picked from commit 941c5275eaaf8d22915eb876045d2173bdbb7d4c)

4 years agosd-login: correct prototype of sd_peer_get_cgroup
Jason Francis [Mon, 19 Apr 2021 16:13:03 +0000 (12:13 -0400)]
sd-login: correct prototype of sd_peer_get_cgroup

(cherry picked from commit a8310e39e996b9b5f63d897879aecf8988261bdb)

4 years agofileio: use take_fdopen_unlocked()
Yu Watanabe [Fri, 16 Apr 2021 01:08:36 +0000 (10:08 +0900)]
fileio: use take_fdopen_unlocked()

This fixes maybe-uninitialized warning:
```
../src/basic/fileio.c: In function ‘chase_symlinks_and_fopen_unlocked’:
../src/basic/fileio.c:1026:19: warning: ‘f’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1026 |         *ret_file = f;
      |         ~~~~~~~~~~^~~

```

(cherry picked from commit 6604fb0207ee10e8dc05d67f6fe45de0b193b5c4)

4 years agoman: correct requirements for systemd-oomd.service
Anita Zhang [Fri, 16 Apr 2021 07:42:44 +0000 (00:42 -0700)]
man: correct requirements for systemd-oomd.service

Fixes: #19331
(cherry picked from commit 169be51f94b7017fea1394dcb412d3afdfd7cea5)

4 years agojournald: fix %m usage
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 20:06:02 +0000 (22:06 +0200)]
journald: fix %m usage

(cherry picked from commit cf5a2ee82517429a34d9f5bef853cabe055e3e59)

4 years agoshared/module-util: fix errno value passed to log function
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 15:10:36 +0000 (17:10 +0200)]
shared/module-util: fix errno value passed to log function

If r == 0, no harm done. But if r > 0, this would be interpreted as an
errno value, wrongly.

(cherry picked from commit a2eb2267e44580446ecad37e7206e729cfd78155)

4 years agopartition, random-seed, logind: fix log messages with %m
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 10:14:01 +0000 (06:14 -0400)]
partition, random-seed, logind: fix log messages with %m

We would print "...: Success", which is not too terrible, but not pretty
either.

(cherry picked from commit 111a3aae71fa019710216cc5b7aa95b7c8db0937)

4 years agosd-device: improve log message and tweak style
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 09:54:17 +0000 (05:54 -0400)]
sd-device: improve log message and tweak style

We shouldn't say the attribute is missing right after ruling out ENOENT.

(cherry picked from commit aca591ac55e5ee364905aec975388c5e30d0476c)

4 years agocore: drop pointless assert()
Lennart Poettering [Wed, 14 Apr 2021 14:02:35 +0000 (16:02 +0200)]
core: drop pointless assert()

We checked this literally two lines earlier, no point in checking so
quickly again.

(cherry picked from commit 5c9f1c68f032287da3fa7f5c4c08dfb0bf340c0b)

4 years agotest: use systemd-run --wait in TEST-44-LOG-NAMESPACE
Luca Boccassi [Wed, 14 Apr 2021 20:26:50 +0000 (21:26 +0100)]
test: use systemd-run --wait in TEST-44-LOG-NAMESPACE

The test appears to be occasionally failing. It uses systemd-run to echo
'hello world' into a namespaced journal and then uses journalctl to look for it,
but it doesn't wait.
In the failed runs it can't find it, but the automated journal dump shows
the message at the end.

Use --wait to avoid races.

(cherry picked from commit cf9844ffabd7fd51f22e729692b79d55cd7bdd76)

4 years agolibsystemd-network: fix dhcp option buffer confusion
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 08:55:09 +0000 (04:55 -0400)]
libsystemd-network: fix dhcp option buffer confusion

We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a306fd2ba454d3ee333d63df71aa3873.

(cherry picked from commit 828b603a791edd04a5c3603456aa8caca44ce67e)

4 years agomeson.build: typo
Sevan Janiyan [Wed, 14 Apr 2021 23:01:53 +0000 (00:01 +0100)]
meson.build: typo

(cherry picked from commit d5b3e5104448ebfecd334c26dbdd3a8274440b1e)

4 years agotree-wide: avoid uninitialized warning on _cleanup_ variables
Luca Boccassi [Mon, 12 Apr 2021 22:10:21 +0000 (23:10 +0100)]
tree-wide: avoid uninitialized warning on _cleanup_ variables

With some versions of the compiler, the _cleanup_ attr makes it think
the variable might be freed/closed when uninitialized, even though it
cannot happen. The added cost is small enough to be worth the benefit,
and optimized builds will help reduce it even further.

(cherry picked from commit c2b2df604b845b4e1697d0911935e6644323c5a6)

4 years agorfkill: add some casts to silence -Werror=sign-compare
Luca Boccassi [Tue, 13 Apr 2021 12:17:53 +0000 (13:17 +0100)]
rfkill: add some casts to silence -Werror=sign-compare

(cherry picked from commit ab1aa6368a883bce88e3162fee2bea14aacedf23)

Fixes https://github.com/systemd/systemd-stable/issues/101.

4 years agonetwork: add missing default setting in networkd.conf
Yu Watanabe [Sun, 11 Apr 2021 12:25:16 +0000 (21:25 +0900)]
network: add missing default setting in networkd.conf

(cherry picked from commit 6bfadad9bb6eaf614da92eba0a9b6243e8645018)

4 years agoudev: delete useless codes
gaoyi [Tue, 13 Apr 2021 10:59:46 +0000 (18:59 +0800)]
udev: delete useless codes

It seems no one will touch queue.bin

(cherry picked from commit 993eb00016a75cf085eed85cf626a6995e96ab3d)

4 years agoload-fragment: parse specifiers in CPUAffinity= (#19281)
Francois Gervais [Mon, 12 Apr 2021 22:25:29 +0000 (18:25 -0400)]
load-fragment: parse specifiers in CPUAffinity= (#19281)

(cherry picked from commit 54cfe9a75f0e84d0604d39b87b1d919542336809)

4 years agomeson: do not fail if rsync is not installed with meson 0.57.2
Zbigniew Jędrzejewski-Szmek [Mon, 12 Apr 2021 12:03:32 +0000 (14:03 +0200)]
meson: do not fail if rsync is not installed with meson 0.57.2

https://github.com/mesonbuild/meson/issues/8641

Our CI started to fail. Even if the change is reverted in meson,
we need a quick workaround here.

(cherry picked from commit 7c5fd25119a495009ea62f79e5daec34cc464628)

4 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

(cherry picked from commit 023e75df4c2904e493c4c8ff62df9fa99709d408)

4 years agoresolved: reply using unicast mDNS when appropriate
Sergey Bugaev [Mon, 15 Feb 2021 17:18:34 +0000 (20:18 +0300)]
resolved: reply using unicast mDNS when appropriate

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

(cherry picked from commit 84b0ff0e327a4cf873791c74efc312c81400be70)

4 years agoresolved: fix mistaking QU bit for cache-flush bit
Sergey Bugaev [Fri, 19 Feb 2021 13:50:23 +0000 (16:50 +0300)]
resolved: fix mistaking QU bit for cache-flush bit

RFC 6762 defines the top bit in RRs to mean cache flush (section 10.2),
and the top bit in questions to mean that a unicast reply is wanted
(section 5.4).

dns_packet_read_key() is used for parsing both questions and RRs.
When called from dns_packet_extract_question(), the top bit being set
should not result in the packet being rejected as invalid.

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

(cherry picked from commit 82d39576462ba66a4316307ce1ded97272e1245f)

4 years agoresolved: add flags to DnsQuestion items
Sergey Bugaev [Sat, 20 Feb 2021 14:32:24 +0000 (17:32 +0300)]
resolved: add flags to DnsQuestion items

This adds DnsQuestionItem, which is to DnsQuestion what DnsAnswerItem is to
DnsAnswer.

No functional change.

(cherry picked from commit ab715ddbaf9f45f352c4c018a648454df60b468b)

4 years agobpf-firewall: attach with BPF_F_ALLOW_MULTI if kernel supports
Julia Kartseva [Thu, 4 Feb 2021 06:15:27 +0000 (22:15 -0800)]
bpf-firewall: attach with BPF_F_ALLOW_MULTI if kernel supports

Reduced version of [0].
Use BPF_F_ALLOW_MULTI attach flag for bpf-firewall if kernel supports
it.

Aside from addressing security issue in [0] attaching with 'multi'
allows further attaching of cgroup egress, ingress hooks specified by
BPFProgram=.

[0] https://github.com/systemd/systemd/pull/17495/commits/4e42210d40f96e185a55d43041dd6b962ea830dd

(cherry picked from commit a442ccb4ebdbc3a9ff9d4504eb9724092149fd42)

4 years agoman: fix discriptions for --exec-delay
gaoyi [Mon, 12 Apr 2021 08:09:47 +0000 (16:09 +0800)]
man: fix discriptions for --exec-delay

There are two ambiguity in the original description:
1. It will delay all RUN instructions, include builtin.
2. It will delay before running RUN, not each of RUN{program} instructions.

(cherry picked from commit 45f5efdea7e5e94bd47fc24b9bd404c77b5771a0)

4 years agotest-repart: use cryptsetup and losetup autoclose
Luca Boccassi [Fri, 9 Apr 2021 09:56:13 +0000 (10:56 +0100)]
test-repart: use cryptsetup and losetup autoclose

The test occasionally fails as the umount is not yet completed when
cryptsetup close is invoked.
Both cryptsetup and losetup have supported deferred cleanup for some
time now, so use it instead to avoid races.

++ losetup -P --show --find /tmp/test-repart.dMOfYQ8UUF/zzz
+ LOOP=/dev/loop6
+ VOLUME=test-repart-11882
+ touch /tmp/test-repart.dMOfYQ8UUF/empty-password
+ cryptsetup open --type=luks2 --key-file=/tmp/test-repart.dMOfYQ8UUF/empty*** test-repart-11882
+ mkdir /tmp/test-repart.dMOfYQ8UUF/mount
+ mount -t ext4 /dev/mapper/test-repart-11882 /tmp/test-repart.dMOfYQ8UUF/mount
+ diff -r /tmp/test-repart.dMOfYQ8UUF/mount/def /tmp/test-repart.dMOfYQ8UUF/definitions
+ umount /tmp/test-repart.dMOfYQ8UUF/mount
+ cryptsetup close test-repart-11882
Device test-repart-11882 is still in use.
+ rm -rf /tmp/test-repart.dMOfYQ8UUF

(cherry picked from commit 0efcbecd8b266526bf4a8fd06b9b7e7c5c43566d)

4 years agoTEST-22-TMPFILES: add reproducer for bug with X
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 20:35:19 +0000 (22:35 +0200)]
TEST-22-TMPFILES: add reproducer for bug with X

(cherry picked from commit 1672be86021b5ae8e80d095409a4fffcba7cbb75)

4 years agoman: fix quickhelp listing in tmpfiles.d(5)
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 16:26:15 +0000 (18:26 +0200)]
man: fix quickhelp listing in tmpfiles.d(5)

Unlike many other small/big letter combos, this one has the recursive
version attached to the lowercase letter.

(cherry picked from commit 3dd61ee5be0291380d341571e138713d2f89125a)

4 years agotmpfiles: use a entry in hashmap as ItemArray in read_config_file()
Masahiro Matsuya [Wed, 31 Mar 2021 02:44:24 +0000 (11:44 +0900)]
tmpfiles: use a entry in hashmap as ItemArray in read_config_file()

[zjs: squash commits and use size_t as appropriate.

Bug seems to have been introduced in 811a15877825da9e53f9a2a8603da34589af6bbb.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1944468.]

(cherry picked from commit bec890e3cd6dac249cb12ce9430fdb78b6cf546b)

4 years agomkosi.arch: add rsync build dependency
Luca Boccassi [Sat, 10 Apr 2021 19:13:02 +0000 (20:13 +0100)]
mkosi.arch: add rsync build dependency

Program rsync found: NO

man/meson.build:187:0: ERROR: Program 'rsync' not found

(cherry picked from commit a7b7cab66df8c0a701bc6da3a309fa80c90a880b)

4 years agoExtend characters set for PKCS11 URI
Oleg Popov [Sat, 10 Apr 2021 14:21:25 +0000 (17:21 +0300)]
Extend characters set for PKCS11 URI

There are tokens with dots (and other symbols) in PKCS11 URI:

pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=3xxxxxxb;token=livelace
pkcs11:model=PRO;manufacturer=Aladdin%20R.D.;serial=CC62FB25;token=val%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00;id=%33%32%31%30%33%61%36%37%36%65%32%34%35%62%32%31;type=private
(cherry picked from commit b204bdd4ccae2c76422e7383bd51b664d7e2cfd3)

4 years agoresolved: add RFC 8375 "home.arpa" to list of default NTA
Lennart Poettering [Sat, 10 Apr 2021 12:58:54 +0000 (14:58 +0200)]
resolved: add RFC 8375 "home.arpa" to list of default NTA

RFC 8375 introduced "home.arpa" as special TLD for home networks. Let's
hence add it to our default list of NTAs.

(cherry picked from commit 1065501406d6ca608444c3bd19db546e82009450)

4 years agoopenssl: make RSA struct const
Lennart Poettering [Sat, 10 Apr 2021 12:59:40 +0000 (14:59 +0200)]
openssl: make RSA struct const

OpenSSL 3.0 broke API there, but it doesn't hurt to add the "const",
hence add it.

Fixes: #19267
(cherry picked from commit a8fd92b5a303ddd47af44286525e8e4a0fe6e9ae)

4 years agonetwork: adjust log message
Yu Watanabe [Sat, 10 Apr 2021 04:28:11 +0000 (13:28 +0900)]
network: adjust log message

(cherry picked from commit 942cf4b8d1e24ee56bd50f198f4bba2878c307df)

4 years agonetwork: drop unnecessary bitfield specifier
Yu Watanabe [Fri, 9 Apr 2021 10:53:40 +0000 (19:53 +0900)]
network: drop unnecessary bitfield specifier

Manager is allocated only once. It is not necessary to optimize its
size.

(cherry picked from commit a78f938aaf14f285206cb648d6c6d80277ae3568)

4 years agounits: install dbus-org.freedesktop.oom1.service alias
Anita Zhang [Sat, 10 Apr 2021 07:50:50 +0000 (00:50 -0700)]
units: install dbus-org.freedesktop.oom1.service alias

Fixes: #18469
(cherry picked from commit b5a80aa9d89cd82e53181cfd3288bba694622786)

4 years agosd-device: fix error code returned by sd_device_get_sysattr_value() for non-existing...
Lennart Poettering [Fri, 9 Apr 2021 13:00:16 +0000 (15:00 +0200)]
sd-device: fix error code returned by sd_device_get_sysattr_value() for non-existing attributes

lstat() returns the error in errno, not as return value. Let's propagate
this correctly.

This broke the bolt test suite, as @gicmo discovered.

Follow-up for acfc2a1d15560084e077ffb3be472cd117e9020a.

(cherry picked from commit e2e40e9a9e4074eaca7984b70a5d1cd7a7f0cbe0)

4 years agogpt-auto-generator: don't generate systemd-cryptsetup@.service when --Dlibcryptsetup...
gaoyi [Tue, 6 Apr 2021 02:44:33 +0000 (10:44 +0800)]
gpt-auto-generator: don't generate systemd-cryptsetup@.service when --Dlibcryptsetup=false

(cherry picked from commit 5b1375035b617bbee8b22a997be527d1b7a392f8)

4 years agoman: document system-systemd\x2dcryptsetup.slice
Zbigniew Jędrzejewski-Szmek [Fri, 9 Apr 2021 07:27:42 +0000 (09:27 +0200)]
man: document system-systemd\x2dcryptsetup.slice

As discussed in
https://github.com/systemd/systemd/pull/14235/commits/1dc85eff1d0dff18aaeaae530c91bf53f34b726e#r606821495,
follow-up for commit 1dc85eff1d0dff18aaeaae530c91bf53f34b726e.

(cherry picked from commit 5c91fdf3f832a45db35b207da650c4aa12fafa75)

4 years agonetwork: do not require DHCPv6 addresses when UseAddress=no
Yu Watanabe [Wed, 7 Apr 2021 17:29:52 +0000 (02:29 +0900)]
network: do not require DHCPv6 addresses when UseAddress=no

Follow-up for 1536b7b2d00819615bf8eba194de7ccd20c3689f.

Fixes #19196.

(cherry picked from commit 8cd37e4354a5993c8bc600f481c4c0cc6c61eb91)

4 years agohomectl,TEST-46: fix test and fix homectl return value, update docs
Zbigniew Jędrzejewski-Szmek [Thu, 8 Apr 2021 08:34:28 +0000 (10:34 +0200)]
homectl,TEST-46: fix test and fix homectl return value, update docs

The usual: the test wasn't testing, so we didn't notice that the
command wasn't returning as expected.

(cherry picked from commit b9bfa250f2c04caeecd49e54cdbadee3986d64b3)

4 years agotmpfiles: make handling of existing-but-different targets more consistent
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 22:48:35 +0000 (00:48 +0200)]
tmpfiles: make handling of existing-but-different targets more consistent

create_fifo() was added in a2fc2f8dd30c17ad1e23a31fc6ff2aeba4c6fa27, and
would always ignore failure. The test was trying to fail in this case, but
we actually don't fail, which seems to be correct. We didn't notice before
because the test was ineffective.

To make things consistent, generally log at warning level, but don't propagate
the error. For symlinks, log at debug level, as before.

For 'e', failure is not propagated now. The test is adjusted to match.

I think warning is appropriate in most cases: we do not expect a device node to
be replaced by a different device node or even a non-device file. This would
most likely be an error somewhere. An exception is made for symlinks, which are
mismatched on purpose, for example /etc/resolv.conf. With this patch, we don't
get any warnings with the any of the 74 tmpfiles.d files, which suggests that
increasing the warning levels will not cause too many unexpected warnings. If
it turns out that there are valid cases where people have expected mismatches
for non-symlink types, we can always decrease the log levels again.

(cherry picked from commit b88ba6c76116b6e03e202b1bdffd37933f748f03)

4 years agotests: allow for os-release quote variability in TEST-50-DISSECT
Luca Boccassi [Thu, 8 Apr 2021 10:30:33 +0000 (11:30 +0100)]
tests: allow for os-release quote variability in TEST-50-DISSECT

Quoting of values differs between distros: Fedora doesn't quote the ID_
fields, but CentOS does.
Adjust the test checks to account for this.

Fixes #19242

(cherry picked from commit 9f519e491fb2dddeaf39237587191c25b3797a7d)

4 years agocore: fix memleak of ipc_namespace_path
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 14:18:53 +0000 (16:18 +0200)]
core: fix memleak of ipc_namespace_path

Fixup for a70581ffb5c13c91c76ff73ba6f5f3ff59c5a915.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32991

(cherry picked from commit 71d1e58309bb70bb2a014f33c5f9503dcbed020c)

4 years agoproc-cmdline: allow backslash escapes when parsing /proc/cmdline
Lennart Poettering [Tue, 6 Apr 2021 09:45:47 +0000 (11:45 +0200)]
proc-cmdline: allow backslash escapes when parsing /proc/cmdline

So far when parsing /proc/cmdline we'd consider backslashes as
mechanisms for escaping whitepace or quotes. This changes things so that
they are retained as they are instead. The kernel itself doesn't allow such
escaping, and hence we shouldn't do so either (see lib/cmdline.c in the
kernel sources; it does support "" quotes btw).

This fix is useful to allow specifying backslash escapes in the "root="
cmdline option to be passed through to systemd-fstab-generator. Example:

    root=/dev/disk/by-partlabel/Root\x20Partition

Previously we'd eat up the "\" so that we'd then look for a device
/dev/disk/by-partlabel/Rootx20Partition which never shows up.

(cherry picked from commit d997861ea7dae633174cd80ab55552c020526b62)

4 years agoman/systemd-cryptenroll: Fix sd-boot manvolnum from 8 to 7
Morten Linderud [Wed, 7 Apr 2021 10:10:10 +0000 (12:10 +0200)]
man/systemd-cryptenroll: Fix sd-boot manvolnum from 8 to 7

Off-by-one error in the documentation index. The volume number for
systemd-boot/sd-boot is 7.

Signed-off-by: Morten Linderud <morten@linderud.pw>
(cherry picked from commit 29d898cc7be4b2e91f13bba83fef46bbe995f08e)

4 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.

(cherry picked from commit 65d09d575cf74c34098ff4f3ab53fc7587805811)

4 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
(cherry picked from commit 1b30720c1b22df75e147cc201f240db23881672d)

4 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

(cherry picked from commit da846b30312863cc30b32c1d43988a44673c5b8f)

4 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.

(cherry picked from commit f34173a048061b3f7e551e9a7c04f00e5a106fac)

4 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.

(cherry picked from commit fd11201b93c1f3c32831873b746236202f500e91)

4 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

(cherry picked from commit afbcd905526111e3a1bd55b0d6d5ee4413734735)

4 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

(cherry picked from commit 080a602771ef51230a51f247b8b728d0483e2f28)

4 years agotest-oomd-util: fix running in mkosi
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.

(cherry picked from commit 080ca0d830d69dea5fb2b07aace54a4402bf7294)

4 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

(cherry picked from commit ea460d79644560bcb1ed2adb4cf30413f285492a)

4 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.

(cherry picked from commit 6d3831cee58dcbdb7ea8a86ca621fec38f5b279b)

4 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

(cherry picked from commit 8ab34a49dbf75fd731973359a6f24c212682f479)

4 years agoresolved: avoid passing unitialized variable
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.

(cherry picked from commit e7d48709ed6c8569286463552f3df36bbdce8824)

4 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_*

(cherry picked from commit 0246f42980ed87dfca79fd4a8ec67a81d824e427)

4 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.)

(cherry picked from commit 77fac974fe396dbe4fb679b748bfa89db1136e0c)

4 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.

(cherry picked from commit 9fd8d678ba41ad39348758d5d329fe8d4451813f)

4 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.

(cherry picked from commit a59eb7d78f2f7aea0524b4f16cbb0fe3ef1b9aac)

4 years agoresolved: reset initial_jitter_elapsed properly
Lennart Poettering [Wed, 24 Mar 2021 17:45:35 +0000 (18:45 +0100)]
resolved: reset initial_jitter_elapsed properly

This fixes resetting of initial_jitter_elapsed: the first time the timer
hits after initial_jitter_scheduled is set we need to mark things as
elapsed.

(Also improve log messages around this while we are at it)

(cherry picked from commit 213cb4f7e443241ef942cfbd0263cde33b4672c1)

4 years agoresolved: don't mention confusing server switch on server-less protocols
Lennart Poettering [Wed, 24 Mar 2021 16:15:55 +0000 (17:15 +0100)]
resolved: don't mention confusing server switch on server-less protocols

(cherry picked from commit ca55fb8840858b86d1b026f9c020e92e8350af78)

4 years agoresolve: drop meaningless bitfield specifier
Yu Watanabe [Sat, 20 Mar 2021 17:33:36 +0000 (02:33 +0900)]
resolve: drop meaningless bitfield specifier

This also rearrange the members to remove holes in the struct.

(cherry picked from commit 8e95506a2216729093639f5646bd1003cd16a422)

4 years agoshutdown: log on container exit
Anita Zhang [Fri, 5 Mar 2021 04:00:05 +0000 (20:00 -0800)]
shutdown: log on container exit

(cherry picked from commit 016f36ae72611210d6517b37429bfbdc26c5e31c)

4 years agoshutdown: set always_reopen_console
Anita Zhang [Fri, 5 Mar 2021 03:56:16 +0000 (19:56 -0800)]
shutdown: set always_reopen_console

Back in v232 systemd-shutdown would log to /dev/console. However after
the addition of always_reopen_console (v233) it would log to STDERR.
This caused some debugging issues as container systemd-shutdown logs
weren't being logged to console as the arg `--log-target=console` suggested.

Since it appears that always_reopen_console was intended for pid1, set
it in systemd-shutdown as well so logs will go to /dev/console.

(cherry picked from commit f975f1cc748929942188ae1490cf8480f8a64877)

4 years agokernel-insteall: do not remove the first slash in $ENTRY_DIR
Yu Watanabe [Wed, 28 Apr 2021 18:07:47 +0000 (03:07 +0900)]
kernel-insteall: do not remove the first slash in $ENTRY_DIR

Follow-up for cd0d230e7bf87f979722de7e364619dfa71bd6a2.

Fixes #19456.

(cherry picked from commit 2ff739a6ac4adb44f7ea0f534087ee7276302eee)

4 years agohostnamectl: fix hyperlink in "Operating System" field
Yu Watanabe [Tue, 4 May 2021 09:00:12 +0000 (18:00 +0900)]
hostnamectl: fix hyperlink in "Operating System" field

This fixes a bug introduced by 822be62fb23ed0ec1062ffd18057e53f6c2f8c01.

Before this, if terminal width is not enough, the all subsequent lines
are included in the hyperlink.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1955475.

(cherry picked from commit 8fc1efa88fb935ab4357fa39ed71ccb70df55d7e)

4 years agoLoadCredentials: do not assert on invalid syntax
Luca Boccassi [Thu, 1 Apr 2021 21:18:29 +0000 (22:18 +0100)]
LoadCredentials: do not assert on invalid syntax

LoadCredentials=foo causes an assertion to be triggered, as we
are not checking that the rvalue's right hand side part is non-empty
before using it in unit_full_printf.

Fixes #19178

# printf [Service]nLoadCredential=passwd.hashed-password.rootn > hello.service
# systemd-analyze verify ./hello.service
...
Assertion 'format' failed at src/core/unit-printf.c:232, function unit_full_printf(). Aborting.
Aborted (core dumped)

4 years agoMerge pull request #19157 from keszybz/read-medium-sized-virtual-file v248 v248-2
Lennart Poettering [Tue, 30 Mar 2021 20:59:02 +0000 (22:59 +0200)]
Merge pull request #19157 from keszybz/read-medium-sized-virtual-file

basic/fileio: fix reading of not-too-small virtual files

4 years agoNEWS: prep release date
Lennart Poettering [Tue, 30 Mar 2021 20:00:11 +0000 (22:00 +0200)]
NEWS: prep release date

4 years agotest-fileio: test for read_full_virtual_file()
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 19:58:59 +0000 (21:58 +0200)]
test-fileio: test for read_full_virtual_file()

It was already called through other places, but indirectly.
Let's add some direct invocations.

4 years agobasic/fileio: fix reading of not-too-small virtual files
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 15:29:44 +0000 (17:29 +0200)]
basic/fileio: fix reading of not-too-small virtual files

This code is trying to do two things: when reading a file with working
st.st_size, detect when the file size changes between the fstat() and our
allocation of the buffer based on the returned size, and the subsequent read().
When reading a file without st.st_size, read up to READ_FULL_BYTES_MAX.

But this second scenario was partially broken: we'd start with size = 4095, and
double the size up to three times, i.e. up to 32767. But we want to read up to
READ_FULL_BYTES_MAX.

So let's listentangle the two cases a bit: if a file returns non-zero st._size,
proceed as before. But if we don't know the size, let's immediately allocate
the buffer of maximum size of READ_FULL_BYTES_MAX. I think that allocating 4MB
and 1MB is going to take pretty much the same time as long as the memory is not
written to, so by allocating 1MB, 2MB, and 4MB, we wouldn't really be saving
anything internally, but wasting time on repeated reads, if the file is long
enough.

Also, don't do the seek if we know we're going to return an error immediately
after.

This should fix reading of any files in /proc, which all have size == 0. In
particular, various files read by coredump might be larger than 32767.

What about /sys? The file there return a fake value, usually 4096. So we'll
allocate a small buffer and read that.

4 years agoMerge pull request #19149 from anitazha/oomdlogging
Luca Boccassi [Tue, 30 Mar 2021 18:01:01 +0000 (19:01 +0100)]
Merge pull request #19149 from anitazha/oomdlogging

oomd: make it more clear when a kill happens

4 years agoMerge pull request #19155 from keszybz/hwdb-contrib-v248
Luca Boccassi [Tue, 30 Mar 2021 17:13:16 +0000 (18:13 +0100)]
Merge pull request #19155 from keszybz/hwdb-contrib-v248

hwdb update + contrib list

4 years agooomd: fix iteration over candidates to kill
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 12:45:22 +0000 (14:45 +0200)]
oomd: fix iteration over candidates to kill

4 years agooomd: make it more clear when a kill happens
Anita Zhang [Fri, 26 Mar 2021 10:01:38 +0000 (03:01 -0700)]
oomd: make it more clear when a kill happens

Improve the logging to only print if systemd-oomd killed something. And
also print which cgroup was targeted.
Demote general swap above/pressure above messages to debug.

[zjs: fix some issuelets found in review]

4 years agoMerge pull request #19131 from keszybz/resolvectl-warn-less
Lennart Poettering [Tue, 30 Mar 2021 11:29:55 +0000 (13:29 +0200)]
Merge pull request #19131 from keszybz/resolvectl-warn-less

Suppress warnings in resolvectl about --type=

4 years agoselinux: do not crash if policy becomes unavailable after reload
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 08:01:12 +0000 (10:01 +0200)]
selinux: do not crash if policy becomes unavailable after reload

https://bugzilla.redhat.com/show_bug.cgi?id=1944171
This was in F33, systemd-246.13, but the logic in the code didn't change.

Thread 1 (Thread 0x7fb5f0341b80 (LWP 1974)):
№0  selabel_lookup_common (rec=0x0, translating=0, key=0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service", type=40960) at label.c:167

'rec' is the handle that we passed.

№1  0x00007fb5f13ae87f in selabel_lookup_raw (rec=<optimized out>, con=con@entry=0x7fffef307380, key=key@entry=0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service", type=type@entry=40960) at label.c:256
        lr = <optimized out>

'rec' is passed through as is to selabel_lookup_common().

№2  0x00007fb5f1561b2d in selinux_create_file_prepare_abspath (abspath=0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service", mode=40960) at ../src/basic/selinux-util.c:368
        filecon = 0x0
        r = <optimized out>
        __PRETTY_FUNCTION__ = "selinux_create_file_prepare_abspath"
        __func__ = "selinux_create_file_prepare_abspath"

№3  0x00007fb5f1561ec3 in mac_selinux_create_file_prepare (path=<optimized out>, mode=40960) at ../src/basic/selinux-util.c:431
        r = 0
        abspath = 0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service"
        __PRETTY_FUNCTION__ = "mac_selinux_create_file_prepare"

We checked label_hnd != NULL, but then we apparently called
avc_netlink_check_nb(), which reset label_hnd. Yay for global state!

№4  0x00007fb5f1549950 in symlink_atomic_label (from=0x55f6169d8b50 "69a8dcf7a7ac46b29306f2fddbed3edc", to=0x55f616ab8380 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service") at ../src/basic/label.c:55
        r = <optimized out>
        __PRETTY_FUNCTION__ = "symlink_atomic_label"

In the logs:

Mar 29 14:48:44 fedorapad.home systemd[1974]: selinux: avc:  received policyload notice (seqno=2)
Mar 29 14:48:44 fedorapad.home systemd[1974]: Failed to initialize SELinux labeling handle: No such file or directory
Mar 29 14:48:44 fedorapad.home systemd[1974]: selinux: avc:  received policyload notice (seqno=3)
Mar 29 14:48:44 fedorapad.home systemd[1974]: selinux: avc:  received setenforce notice (enforcing=0)

4 years agohwdb: update fingerprint autosuspend rules
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 11:17:42 +0000 (13:17 +0200)]
hwdb: update fingerprint autosuspend rules

4 years agohwdb: update for v248
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 11:16:30 +0000 (13:16 +0200)]
hwdb: update for v248

As usual, it seems to be additions and updates, no major removals.

4 years agoNEWS: update contributor list for v248 final
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:49:41 +0000 (12:49 +0200)]
NEWS: update contributor list for v248 final

4 years agogit-contrib: use non-breaking spaces in names
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:45:14 +0000 (12:45 +0200)]
git-contrib: use non-breaking spaces in names

Some people have initials or abbreviated parts in the name and looks strange
when a line break occurs in the middle. Let's keep each name in one line.

4 years agomailmap: two more names
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:43:23 +0000 (12:43 +0200)]
mailmap: two more names

4 years agoRevert "fix wrong statement JOURNAL_FILE_FORMAT.md doc"
Luca Boccassi [Mon, 29 Mar 2021 21:31:21 +0000 (22:31 +0100)]
Revert "fix wrong statement JOURNAL_FILE_FORMAT.md doc"

This reverts commit 119063d2b149667a91e0e08e4bdf82a0eb6a7efd.

4 years agofix wrong statement JOURNAL_FILE_FORMAT.md doc
Yangyang Shen [Mon, 29 Mar 2021 12:29:54 +0000 (20:29 +0800)]
fix wrong statement JOURNAL_FILE_FORMAT.md doc

4 years agounits: make locale directory writable for systemd-localed
Christian Hesse [Sun, 28 Mar 2021 11:00:49 +0000 (13:00 +0200)]
units: make locale directory writable for systemd-localed

With 8f20232fcb52dbe6255f3df6101fc057af90bcfa systemd-localed supports
generating locales when required. This fails if the locale directory is
read-only, so make it writable.

Closes #19138

4 years agosd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTER
Fangrui Song [Mon, 29 Mar 2021 06:35:06 +0000 (23:35 -0700)]
sd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTER

LLD 13 and GNU ld 2.37 support -z start-stop-gc which allows garbage
collection of C identifier name sections despite the __start_/__stop_
references.  Simply set the retain attribute so that GCC 11 (if
configure-time binutils is 2.36 or newer)/Clang 13 will set the
SHF_GNU_RETAIN section attribute to prevent garbage collection.

Without the patch, there are linker errors like the following with -z
start-stop-gc.

```
ld: error: undefined symbol: __start_SYSTEMD_BUS_ERROR_MAP
>>> referenced by bus-error.c:93 (../src/libsystemd/sd-bus/bus-error.c:93)
>>>               sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a
```

4 years agoMerge pull request #19116 from keszybz/readvirtualfile-opt
Zbigniew Jędrzejewski-Szmek [Mon, 29 Mar 2021 08:51:32 +0000 (10:51 +0200)]
Merge pull request #19116 from keszybz/readvirtualfile-opt

Optimize read_full_virtual_file() and another coverity issue

4 years agoresolvectl: suppress warning about --type for names with a dot
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 13:14:38 +0000 (14:14 +0100)]
resolvectl: suppress warning about --type for names with a dot

People don't generally type the trailing dot by mistake, so let's treat this as
indication that they want to resolve this particular hostname.

4 years agoMerge pull request #19129 from keszybz/test-random-range
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 19:22:29 +0000 (20:22 +0100)]
Merge pull request #19129 from keszybz/test-random-range

Test random_u64_range()

4 years agotest-dhcp6-client: add one more assert on memory mapping
Luca Boccassi [Fri, 26 Mar 2021 12:03:11 +0000 (12:03 +0000)]
test-dhcp6-client: add one more assert on memory mapping

Same as 7489d0640a4864d4b47fd8fda77f8eb7cf2e3fe8, one more case
that was missed.

Coverity CID #1394277

4 years agoMerge pull request #19125 from keszybz/cat-config
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 19:16:09 +0000 (20:16 +0100)]
Merge pull request #19125 from keszybz/cat-config

config files: recommend systemd-analyze cat-config

4 years agoresolved: tweak how we signal authoritative answers
Lennart Poettering [Wed, 24 Feb 2021 16:04:55 +0000 (17:04 +0100)]
resolved: tweak how we signal authoritative answers

let's make sure we set the "aa" bit in the stub only if we answer with
fully authoritative data. For this ensure:

1. Either all data is synthetic, including all CNAME/DNAME redirects

2. Or all data comes from the local trust anchor or the local zones
   (i.e. not the network or the cache)

Follow-up for 4ad017cda57b04b9d65e7da962806cfcc50b5f0c

4 years agotests: drop calls to unsetenv SYSTEMD_MEMPOOL
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 11:19:18 +0000 (12:19 +0100)]
tests: drop calls to unsetenv SYSTEMD_MEMPOOL

Coverity was complaining that we don't check the return value, which we stopped
doing in 772e0a76f34914f6f81205e912e4744c6b23f704.

But it seems that we don't want those calls at all. The test was originally
added with the call in a6ee01caf3409ba9820e8824b9262fbac31a9f77, but I don't
see why we should override this. If the user wants to execute the test with
mempool disabled, we shouldn't ignore that.

Coverity CID#1444464, CID#1444466.

4 years agobasic/fileio: use malloc_usable_size() to use all allocated memory
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 12:50:13 +0000 (13:50 +0100)]
basic/fileio: use malloc_usable_size() to use all allocated memory

4 years agobasic/fileio: optimize buffer sizes in read_full_virtual_file()
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 11:10:32 +0000 (12:10 +0100)]
basic/fileio: optimize buffer sizes in read_full_virtual_file()

We'd proceed rather inefficiently: the initial buffer size was LINE_MAX/2,
i.e. only 1k. We can read 4k at the same cost.

Also, we'd try to allocate 1025, 2049, 4097 bytes, i.e. always one higher than
the power-of-two size. Effectively the allocation would be bigger, and we'd
waste the additional space. So let's allocate aligned to the power-of-two size.
size=4095, 8191, 16383, so we allocate 4k, 8k, 16k.

4 years agobasic/fileio: simplify calculation of buffer size in read_full_virtual_file()
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 10:58:35 +0000 (11:58 +0100)]
basic/fileio: simplify calculation of buffer size in read_full_virtual_file()

We'd first assign a value up to SSIZE_MAX, and then immediately check if we
have a value bigger than READ_FULL_BYTES_MAX. This wasn't exactly wrong, but a
bit roundabout. Let's immediately assign the value from the appropriate range
or error out.

Coverity CID#1450973.