1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
Commit Graph

50293 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
bcceabcfc2
Merge pull request #18886 from anitazha/shutdownconsole
logging shutdown to /dev/console
2021-03-31 10:28:26 +02:00
Zbigniew Jędrzejewski-Szmek
87f9300d71
Merge pull request #18850 from yuwata/sd-device-monitor-cleanups
sd-device-monitor: trivial cleanups
2021-03-31 10:27:06 +02:00
Henri Chain
cb0e818f7c Introduce ExitType 2021-03-31 10:26:07 +02:00
Zbigniew Jędrzejewski-Szmek
82a335db83
Merge pull request #18777 from yuwata/network-set-ifname-to-engines
network: set ifname to dhcp4 client or friends
2021-03-31 10:25:23 +02:00
Lennart Poettering
938bdfc0fa
Merge pull request #19157 from keszybz/read-medium-sized-virtual-file
basic/fileio: fix reading of not-too-small virtual files
2021-03-30 22:59:02 +02:00
Lennart Poettering
9ca34cf5a4 NEWS: prep release date 2021-03-30 22:00:11 +02:00
Zbigniew Jędrzejewski-Szmek
bca895c4f4 test-fileio: test for read_full_virtual_file()
It was already called through other places, but indirectly.
Let's add some direct invocations.
2021-03-30 21:58:59 +02:00
Zbigniew Jędrzejewski-Szmek
2ac67221bb 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.
2021-03-30 21:56:22 +02:00
Luca Boccassi
ae63987fac
Merge pull request #19149 from anitazha/oomdlogging
oomd: make it more clear when a kill happens
2021-03-30 19:01:01 +01:00
Luca Boccassi
c71bb61e8d
Merge pull request #19155 from keszybz/hwdb-contrib-v248
hwdb update + contrib list
2021-03-30 18:13:16 +01:00
Zbigniew Jędrzejewski-Szmek
f94a80ab59 oomd: fix iteration over candidates to kill 2021-03-30 14:45:22 +02:00
Anita Zhang
37a7e15968 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]
2021-03-30 14:44:09 +02:00
Lennart Poettering
414f59dad7
Merge pull request #19131 from keszybz/resolvectl-warn-less
Suppress warnings in resolvectl about --type=
2021-03-30 13:29:55 +02:00
Zbigniew Jędrzejewski-Szmek
7960ba96d1 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)
2021-03-30 13:24:12 +02:00
Zbigniew Jędrzejewski-Szmek
f8a6e1e523 hwdb: update fingerprint autosuspend rules 2021-03-30 13:17:59 +02:00
Zbigniew Jędrzejewski-Szmek
a22c7690d4 hwdb: update for v248
As usual, it seems to be additions and updates, no major removals.
2021-03-30 13:17:59 +02:00
Zbigniew Jędrzejewski-Szmek
8ce2255178 NEWS: update contributor list for v248 final 2021-03-30 13:17:59 +02:00
Zbigniew Jędrzejewski-Szmek
b242d2dec9 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.
2021-03-30 13:17:59 +02:00
Zbigniew Jędrzejewski-Szmek
75e53df7e3 mailmap: two more names 2021-03-30 13:17:58 +02:00
Luca Boccassi
063a43a1a7 Revert "fix wrong statement JOURNAL_FILE_FORMAT.md doc"
This reverts commit 119063d2b1.
2021-03-30 10:26:54 +02:00
Yangyang Shen
119063d2b1 fix wrong statement JOURNAL_FILE_FORMAT.md doc 2021-03-29 19:11:27 +02:00
Christian Hesse
46cfe8f50d units: make locale directory writable for systemd-localed
With 8f20232fcb systemd-localed supports
generating locales when required. This fails if the locale directory is
read-only, so make it writable.

Closes #19138
2021-03-29 12:33:36 +02:00
Fangrui Song
945317a4b6 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
```
2021-03-29 12:31:42 +02:00
Zbigniew Jędrzejewski-Szmek
8a773a30ba
Merge pull request #19116 from keszybz/readvirtualfile-opt
Optimize read_full_virtual_file() and another coverity issue
2021-03-29 10:51:32 +02:00
Zbigniew Jędrzejewski-Szmek
200b4f3d80 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.
2021-03-26 21:24:36 +01:00
Zbigniew Jędrzejewski-Szmek
a81c7ac8d4
Merge pull request #19129 from keszybz/test-random-range
Test random_u64_range()
2021-03-26 20:22:29 +01:00
Luca Boccassi
a9dd1010f0 test-dhcp6-client: add one more assert on memory mapping
Same as 7489d0640a, one more case
that was missed.

Coverity CID #1394277
2021-03-26 20:17:35 +01:00
Zbigniew Jędrzejewski-Szmek
008adf875e
Merge pull request #19125 from keszybz/cat-config
config files: recommend systemd-analyze cat-config
2021-03-26 20:16:09 +01:00
Lennart Poettering
9ddf099f30 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 4ad017cda5
2021-03-26 18:21:41 +01:00
Zbigniew Jędrzejewski-Szmek
bc52deda4b tests: drop calls to unsetenv SYSTEMD_MEMPOOL
Coverity was complaining that we don't check the return value, which we stopped
doing in 772e0a76f3.

But it seems that we don't want those calls at all. The test was originally
added with the call in a6ee01caf3, 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.
2021-03-26 15:54:58 +01:00
Zbigniew Jędrzejewski-Szmek
f1a8a66c35 basic/fileio: use malloc_usable_size() to use all allocated memory 2021-03-26 15:54:56 +01:00
Zbigniew Jędrzejewski-Szmek
a9899ff358 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.
2021-03-26 15:53:50 +01:00
Zbigniew Jędrzejewski-Szmek
ca79564309 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.
2021-03-26 15:46:44 +01:00
David Tardon
cb6c4f37dc use the right member to define property 2021-03-26 14:44:01 +01:00
Zbigniew Jędrzejewski-Szmek
f2a8b8decf test-random-util: add stochastic test for random_u64_range() 2021-03-26 14:38:44 +01:00
Zbigniew Jędrzejewski-Szmek
93457c0c7a test-random-util: modernization 2021-03-26 14:28:24 +01:00
Zbigniew Jędrzejewski-Szmek
058946d1f9 resolvectl: do not warn about single hostnames for names we synthesize
https://github.com/systemd/systemd/pull/17535#discussion_r534005801
2021-03-26 14:19:05 +01:00
Zbigniew Jędrzejewski-Szmek
75c9d6b5cf resolved: split out function to determine the local llmnr hostname 2021-03-26 14:18:51 +01:00
Zbigniew Jędrzejewski-Szmek
20e994b392 resolvectl: reword note about "raw record types"
As noted in https://github.com/systemd/systemd/pull/17535#discussion_r534129256,
"raw" is misleading in this context. Let's use a more descriptive term.
2021-03-26 14:18:17 +01:00
Zbigniew Jędrzejewski-Szmek
e355fb6fb1 basic/log: fix log_trace()
log_trace() was always on. It's supposed to be opt-in.
2021-03-26 13:08:24 +01:00
Zbigniew Jędrzejewski-Szmek
d83e90c73c Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
Zbigniew Jędrzejewski-Szmek
3b0754b16c config files: recommend systemd-analyze cat-config
This adds the same line to most of our .conf files.

Not for systemd/user.conf though, since we can't correctly display it right
now:
$ systemd-analyze cat-config --user systemd/user.conf
Option --user is not supported for cat-config right now.

For sysusers.d, tmpfiles.d, rules.d, etc, there is no single file. Maybe
we should short READMEs in /usr/lib/sysusers.d, /usr/lib/tmpfiles.d, etc.?

Inspired by #19118.
2021-03-26 08:45:04 +01:00
Zbigniew Jędrzejewski-Szmek
b240c08d09 docs: link to stable releases in the bug template
Also, ask people to use a recent stable release and provide useful version information.
Inspired by #19118.
2021-03-25 20:38:45 +00:00
Zbigniew Jędrzejewski-Szmek
7eafbd4270
Merge pull request #19112 from poettering/more-stub-fixes
resolved: two more tweaks to the stub
2021-03-25 21:31:27 +01:00
Luca Boccassi
6f4c93259e
Merge pull request #19117 from bluca/coverity
Two small coverity issues
2021-03-25 19:33:58 +00:00
Lennart Poettering
915ba31cfd resolved: rework CNAME logic a bit more
When following CNAME/DNAME redirects in the stub we currently first
iterate through the packet and pick up what we can use (in
dns_stub_collect_answer_by_question() and friends), following all
CNAMEs/DNAMEs, and would then issue dns_query_process_cname() to move
the DnsQuery object forward too, where we'd then possibly restart
the query and pick things up again, as above.

There's one thought error in this though: dns_query_process_cname()
tries to be smart and will internally follow not just a single
CNAME/DNAME redirect, but a chain of them if they are contained inside
the same packet until we reach the point where the answer is not
included in the packet anymore, where we'd restart the query. This was
great as long as we only focussed on the D-Bus and Varlink resolver
APIs, since there the CNAME/DNAME chain in the middle doesn't actually
matter, we just return information about the final name of the RR and
its content, and aren't interested in the chain to it. For the DNS stub
this is different however: there we need to place the full CNAME/DNAME
chain (and all the appropriate metadata RRs) in the stub reply.

Hence rework this so that we build on the fact that the previous commit
split dns_query_process_cname() in two:

1. dns_query_process_cname_one() will do exactly one CNAME/DNAME
   redirect step. This will be called by the stub, so that we can pick
   up matching RRs for every single step along the way.

2. dns_query_process_cname_many() will follow a chain as long as that's
   possible within the same packet. It's thus pretty much identical to
   the old dns_query_process_cname() call. This is what we now use in
   the D-Bus and Varlink APIs. dns_query_process_cname_many() is
   basically just a loop around dns_query_process_cname_one().

Any logic to follow and pick up RRs manually in the stub along the
CNAME/DNAME path is now dropped (i.e.
dns_stub_collect_answer_by_question() becomes trivially simple again),
we solely rely on dns_query_process_cname_one() to follow CNAME/DNAME
now: each step followed by a full call of dns_stub_assign_sections() to
copy out the RRs that matter.

Net result: things are a bit simpler again, as the only place we follow
CNAME/DNAME redirects is DnsQuery again, and stub answers are always
complete: they contain all CNAME/DNAME RRs on the way including all
their metadata we might pick up in the other sections.
2021-03-25 13:12:19 +01:00
Lennart Poettering
1db8e6d1db resolved: split dns_query_process_cname() into two separate functions
This does some refactoring: the dns_query_process_cname() function
becomes two: dns_query_process_cname_one() and
dns_query_process_cname_many(). The former will process exactly one
CNAME chain element, the latter will follow a chain for as long as
possible within the current packet.

dns_query_process_cname_many() is mostly identical to the old
dns_query_process_cname(), and all existing code is moved over to using
that.

This is mostly preparation for the next commit, where we make direct use
of dns_query_process_cname_one().

This also renames the DNS_QUERY_RESTARTED return value to
DNS_QUERY_CNAME. That's because in the dns_query_process_cname_many()
case as before if we return this we restarted the query in case we
reached the end of the chain without a conclusive answer, as before. But
in dns_query_process_cname_one() we'll only go one step anyway, and
leave restarting if needed to the caller. Hence DNS_QUERY_RESTARTED is a
bit of a misnomer in that case.

This also gets rid of the weird tail recursion in
dns_query_process_cname() and replaces it with an explicit loop in
dns_query_process_cname_many(). The old recursion wasn't a security
issue since we put a limit on the number of CNAMEs we follow anyway, but
it's still icky to scale stack use by that.
2021-03-25 13:12:19 +01:00
Luca Boccassi
7489d0640a test-dhcp6-client: add one more assert on memory mapping
Static analyzers need a hint that optval is not pointing
off the end of the msg_advertise array, since pos can go
up to the full length of it. The array is manually
constructed so we know this won't happen, but adding one
more assert should be enough to avoid false positives.

Coverity CID #1394277
2021-03-25 12:02:43 +00:00
Luca Boccassi
c0ef415862 test-firewall-util: add more asserts on allocated variables
Makes things nicer for readers, and hopefully gives static analyzers
a hint on the origin/cleanup of the ctx pointer.
Coverity CID #1451399
2021-03-25 10:49:06 +00:00
Lennart Poettering
d451f0e84b resolved: tweak sections we add answer RRs to
Previously we'd stick all answer sections RRs we acquired into
the authoritative section if we didn't find them directly answering our
question. Let's put them into additional instead. The authoritative
section should hence only include what comes from the upstream
authoritative section, and nothing else.
2021-03-25 11:42:39 +01:00