1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-04 21:47:31 +03:00

50444 Commits

Author SHA1 Message Date
Lennart Poettering
10cdbb8372 test: add test for bind_remount_recursive() 2021-03-26 11:51:26 +01:00
Lennart Poettering
0338df47cf mount-util: generate failure if bind_remount_one_with_mountinfo() is called on non-existing path 2021-03-26 11:51:26 +01:00
Lennart Poettering
b23c6a6411 mount-util: handle remount failures gracefully if flags already match
In bind_remount_one_with_mountinfo() let's handle mount failures
gracefully if the flags already match anyway. This isn't perfect, since
it mixes up superblock and mount point flags, but it's close enough.
2021-03-26 11:51:26 +01:00
Lennart Poettering
2c5ff8ea76 mount-util: fold what we need from get_mount_flags() bind_remount_one_with_mountinfo()
And get rid of get_mount_flags() altogether.

(This drops the statvfs() fallback that get_mount_flags() did. That
fallback was incomplete however, and mostly hid errors. Our primary
avenue to get mount flags is /proc/self/mountinfo and we should trust
it, and fix bugs we might encounter with it, but not tape over it.
Dropping the fallback is relevant in particular as it actually returned
mount flags for any path, not just mount points, which was very icky.)
2021-03-26 11:51:26 +01:00
Lennart Poettering
ba8dced2a6 mount-util: store mount flags in "todo" list in + handle submounts gracefully
This replaces the "todo" set with a "todo" hash map that stores the
mount flags we found. This makes an explicit call to get_mount_flags()
unncessary, since we have the flags handy right-away, and lowers our
work from O(n^2) to O(n). Nice!

The "done" set is also improved slightly: we'll use more modern ways to
allocate it, via set_ensure_consume(), and freeing-via-hash_ops.

Finally, failures on submount remounts are now handled gracefully,
there are just too many reasons why they might fail, given NFS, autofs,
FUSE which weird access controls, where even root might lack the privs
to do something.

Fixes: #16156
2021-03-26 11:51:26 +01:00
Lennart Poettering
4b6ef52756 mount-util: extend comment a bit, mention that we aren't atomic in behaviour 2021-03-26 11:39:37 +01:00
Lennart Poettering
5c5753b9ea mount-util: shortcut things after generating top-level bind mount
Instead of marking the bind mount read-only right-away, let's just
restart the loop, so that we'll pick it up like any other mount and then
remount like that.
2021-03-26 11:39:37 +01:00
Lennart Poettering
d6bfab118d mount-util: reorder a few things
Let's always query one property, check it, and then query the next,
preferring "cheap" ones over "slow" ones (i.e. cheap are the ones we can
check directly, and slow are the ones we need to check with some loop of
some kind).
2021-03-26 11:39:37 +01:00
Lennart Poettering
c6111b85f7 path: drop simplification of path in bind_remount_recursive_with_mountinfo()
We only use path-aware comparisons and hashops, hence no need to
simplify, we can use the path as it is.
2021-03-26 11:39:37 +01:00
Lennart Poettering
670e8efd60 mount-until: make sure we'll exit bind_remount_recursive_with_mountinfo() loop eventually
Just some robustness given that /proc/self/mountinfo was previously
broken in the kernel.
2021-03-26 11:39:37 +01:00
Lennart Poettering
9d0619dee7 mountpoint-util: rebreak some comments 2021-03-26 11:39:37 +01:00
Lennart Poettering
b898474fec mountpoint-util: a symlink is never a mount point
The various flavours of stat() basically tell us for free if something
is a symlink. If it is, then it's definitely not a mount point. Use
that.

All other inode types can be mount point, just symlinks cannot.
2021-03-26 11:39:37 +01:00
Lennart Poettering
981318d2b5 test-namespace: drop spurious double new line 2021-03-26 11:39:37 +01:00
Lennart Poettering
6d660692f2 resolved: use sd_event_add_time_relative() where appropriate 2021-03-26 11:38:04 +01:00
Lennart Poettering
213cb4f7e4 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)
2021-03-26 11:38:01 +01:00
Lennart Poettering
2f9c3b2ab4 resolved: mention transaction ID in jitter log message 2021-03-26 11:37:57 +01:00
Lennart Poettering
9ee18bf473 resolved: use random_u64_range() for randomizing initial transaction jitter 2021-03-26 11:37:54 +01:00
Lennart Poettering
ca55fb8840 resolved: don't mention confusing server switch on server-less protocols 2021-03-26 11:37:49 +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
Lennart Poettering
8640566ac4 resolved: pass mDNS reply packets to each transaction exactly once
Previously we'd iterate through the RRs of an mDNS reply and then find
exactly one matching transaction on our scope for it, and pass it as
reply to that. If multiple RRs of the same packet match we'd pas the
packet multiple times to the transaction even.

This all doesn't really work anymore since there can be multiple open
transactions for the same key (with different flags), and it's kinda
ugly anywy. Hence let's turn this around: let's iterate through the
transactions and check if any of the included RRs match it, and if so
pass the packet to that transaction exactly once.

This speeds up mDNS a bit, since previously we'd oftentimes fail to find
all suitable transactions for an mDNS reply (because there can be
multiple transactions for the same RR key with different flags, and we
checked exactly one flag combination). Which would then mean the
transaction would time out, and be retried – at which point the cache
would be populated and thus it would still succeed, but only after this
timeout. With this fix this is corrected: every transaction that matches
will get the reply, instantly as we get it.
2021-03-25 11:37:30 +01:00
Lennart Poettering
9b564bbca5 resolved: upgrade log level to LOG_NOTICE if we switch to fallback server (or back)
This is inspired by a recent thread on fedora-devel: it's noteworthy
when we switch to the fallback servers, since it might (or might not)
indicate some configuration problem.

Fixes: #18788
2021-03-25 10:43:23 +01:00
simmon
390e67305d po: Translated using Weblate (Korean)
Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: simmon <simmon@nplob.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/ko/
Translation: systemd/main
2021-03-25 10:42:02 +01:00
Lennart Poettering
729c5deb2e resolved: don't suppress OPT if we have no OPT
This is inspired by #18917. It suppresses a misleading log message about
suppressing OPT where we might not actually have OPT.
2021-03-25 11:38:53 +09:00
Luca Boccassi
a2c69debd9
Merge pull request #19076 from yuwata/firewall-util-modernizations
firewall-util: modernize code and improve test
2021-03-24 23:19:59 +00:00
David Tardon
d2f4a9488c local-addresses: fix use of uninitialized value
This can happen if ifi fails to be read from the netlink message and the
error is ENODATA.

Fixes the following valgrind message when running netstat:

==164141== Conditional jump or move depends on uninitialised value(s)
==164141==    at 0x524AE60: address_compare (local-addresses.c:29)
==164141==    by 0x48BCC78: msort_with_tmp.part.0 (msort.c:105)
==164141==    by 0x48BC9E4: msort_with_tmp (msort.c:45)
==164141==    by 0x48BC9E4: msort_with_tmp.part.0 (msort.c:53)
==164141==    by 0x48BCF85: msort_with_tmp (msort.c:45)
==164141==    by 0x48BCF85: qsort_r (msort.c:297)
==164141==    by 0x52500FC: UnknownInlinedFun (sort-util.h:47)
==164141==    by 0x52500FC: local_gateways.constprop.0 (local-addresses.c:310)
==164141==    by 0x5251C05: _nss_myhostname_gethostbyaddr2_r (nss-myhostname.c:456)
==164141==    by 0x5252006: _nss_myhostname_gethostbyaddr_r (nss-myhostname.c:500)
==164141==    by 0x498E7FE: gethostbyaddr_r@@GLIBC_2.2.5 (getXXbyYY_r.c:274)
==164141==    by 0x498E560: gethostbyaddr (getXXbyYY.c:135)
==164141==    by 0x121353: INET_rresolve.constprop.0 (inet.c:212)
==164141==    by 0x1135B9: INET_sprint (inet.c:261)
==164141==    by 0x121BFC: addr_do_one.constprop.0.isra.0 (netstat.c:1156)
2021-03-24 18:14:45 +01:00
Yu Watanabe
b5d2f4e757 test-firewall-util: use assert_se() at most places
Otherwise, we cannot notice any failures...
2021-03-25 01:05:54 +09:00
Pjotr Vertaalt
91a96a564f po: Translated using Weblate (Dutch)
Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: Pjotr Vertaalt <pjotrvertaalt@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/nl/
Translation: systemd/main
2021-03-24 18:26:52 +09:00
Anita Zhang
7b7a060e83 process-util: dont allocate max length to read /proc/PID/cmdline
Alternative title: Replace get_process_cmdline()'s fopen()/fread() with
read_full_virtual_file().

When RLIMIT_STACK is set to infinity:infinity, _SC_ARG_MAX will
return 4611686018427387903 (depending on the system, but definitely
something larger than most systems have). It's impractical to allocate this
in one go when most cmdlines are much shorter than that.

Instead use read_full_virtual_file() which seems to increase the buffer
depending on the size of the contents.
2021-03-24 16:46:45 +09:00
Lincoln Ramsay
7325a2b2d1
pid1: do not use generated strings as format strings (#19098)
The generated string may include %, which will confuse both the
xprintf call, and the VA_FORMAT_ADVANCE macro.

Pass the generated string as an argument to a "%s" format string
instead.
2021-03-24 16:37:25 +09:00
hide
6b1ed5e7e6
network: fix ipv6 tunnel encapsulation limit (#19087)
The encapsulation limit of IPv6 tunnel can not be set to 4, which is the default value of the encapsulation limit.
2021-03-24 01:05:25 +09:00
Lennart Poettering
f19384b43f repart: remove spurious empty double newlines 2021-03-23 15:52:59 +00:00
Lennart Poettering
86b8610794 blockdev-util: actually specify an access mode on open()
Linux is pretty lenient here, but we should specify the access mode.
2021-03-23 16:37:05 +01:00
Lennart Poettering
49bd547b38 update TODO 2021-03-23 14:43:07 +01:00
Zbigniew Jędrzejewski-Szmek
f0cb09bb0f test-nss-hosts: make buffer size configurable too and document it 2021-03-23 14:14:08 +01:00
Zbigniew Jędrzejewski-Szmek
e2aa384bcd test-nss-hosts: use _cleanup_, fix return value, assert on allocations 2021-03-23 14:14:08 +01:00
Zbigniew Jędrzejewski-Szmek
f0d1266821 test-nss-users: add new nss test that resolves users and groups
Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=1929936.
This is similar to test-nss-hosts, but does users, groups, uid, gids.

Functions tested are:
_nss_*_getpwnam_r
_nss_*_getgrnam_r
_nss_*_getpwgid_r
_nss_*_getgrgid_r

Other entry points should be tested too, but it's not relevant to the bug
I was investigating, so I'm leaving that for later ;)
2021-03-23 14:14:08 +01:00
Yu Watanabe
9fffe0a912 resolve: dns_answer_contains() does not return negative errno 2021-03-23 21:30:23 +09:00
Yu Watanabe
06939d3b0c resolve: use dns_answer_size() and dns_answer_isempty() 2021-03-23 21:30:23 +09:00
Yu Watanabe
ae526a5ea5 resolve: rename function argument in prototype to match its declaration 2021-03-23 21:30:23 +09:00
Yu Watanabe
160f3145db resolve: drop doubled white space 2021-03-23 21:30:23 +09:00
Yu Watanabe
8e95506a22 resolve: drop meaningless bitfield specifier
This also rearrange the members to remove holes in the struct.
2021-03-23 21:30:23 +09:00