]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 years agotree-wide: constify variables if possible 18662/head
Yu Watanabe [Wed, 17 Feb 2021 18:33:39 +0000 (03:33 +0900)] 
tree-wide: constify variables if possible

4 years agonetwork: use temporary buffer for safety
Yu Watanabe [Wed, 17 Feb 2021 18:27:35 +0000 (03:27 +0900)] 
network: use temporary buffer for safety

4 years agonetwork: use in_addr_prefix_to_string()
Yu Watanabe [Wed, 17 Feb 2021 18:22:28 +0000 (03:22 +0900)] 
network: use in_addr_prefix_to_string()

4 years agoresolve: use sockaddr_in_addr()
Yu Watanabe [Wed, 17 Feb 2021 17:51:09 +0000 (02:51 +0900)] 
resolve: use sockaddr_in_addr()

4 years agoresolve: make manager_find_ifindex() or friends return earlier
Yu Watanabe [Wed, 17 Feb 2021 17:50:50 +0000 (02:50 +0900)] 
resolve: make manager_find_ifindex() or friends return earlier

4 years agotree-wide: use in_addr_is_set() or friends
Yu Watanabe [Wed, 17 Feb 2021 16:29:43 +0000 (01:29 +0900)] 
tree-wide: use in_addr_is_set() or friends

4 years agonetwork: assign values after all checks are passed
Yu Watanabe [Wed, 17 Feb 2021 17:23:42 +0000 (02:23 +0900)] 
network: assign values after all checks are passed

4 years agoin-addr-util: introduce in6_addr_equal()
Yu Watanabe [Wed, 17 Feb 2021 17:17:08 +0000 (02:17 +0900)] 
in-addr-util: introduce in6_addr_equal()

4 years agoin-addr-util: introduce in6_addr_is_link_local()
Yu Watanabe [Wed, 17 Feb 2021 16:56:47 +0000 (01:56 +0900)] 
in-addr-util: introduce in6_addr_is_link_local()

4 years agoin-addr-util: introduce in_addr_is_set() or friends
Yu Watanabe [Wed, 17 Feb 2021 15:36:38 +0000 (00:36 +0900)] 
in-addr-util: introduce in_addr_is_set() or friends

4 years agonetwork: enumerate nexthops before routes
Yu Watanabe [Sun, 14 Feb 2021 18:29:55 +0000 (03:29 +0900)] 
network: enumerate nexthops before routes

Preparation for the later commits.
Routes may have RTA_NH_ID attribute. To resolve the nexthop ID, all
nexthops must be enumerated earlier.

4 years agonetwork: nexthop: first create nexthops with ID
Yu Watanabe [Fri, 5 Feb 2021 01:21:19 +0000 (10:21 +0900)] 
network: nexthop: first create nexthops with ID

Otherwise, an ID-less nexthop may conflict with a later nexthop with ID.

4 years agotest: avoid leaking open loop devices
Luca Boccassi [Tue, 16 Feb 2021 23:47:34 +0000 (23:47 +0000)] 
test: avoid leaking open loop devices

When a subshell is used ('make' or 'make all') the LOOPDEV environment
variable, which is used to store the opened loop device, is lost.
So the cleanup on trap/exit doesn't do anything, and the loop
device used to mount the test image is left around.

Avoid using a subshell to fix the issue.

4 years agoMerge pull request #18653 from yuwata/in-addr-prefix-nth
Lennart Poettering [Wed, 17 Feb 2021 17:52:24 +0000 (18:52 +0100)] 
Merge pull request #18653 from yuwata/in-addr-prefix-nth

in-addr-util: fix in_addr_prefix_nth() and use the function to get ip address range in firewall-util

4 years agoresolved: address DVE-2018-0001
Lennart Poettering [Thu, 12 Nov 2020 16:05:36 +0000 (17:05 +0100)] 
resolved: address DVE-2018-0001

This is an updated version of #8608 with more restrictive logic. To
quite the original bug:

    Some captive portals, lie and do not respond with the captive portal
    IP address, if the query is with EDNS0 enabled and D0 bit set to
    zero. Thus retry "secure" domain name look ups with less secure
    methods, upon NXDOMAIN.

https://github.com/dns-violations/dns-violations/blob/master/2018/DVE-2018-0001.md

Yes, this fix sucks hard, but I guess this is what we need to do to make
sure resolved works IRL.

Heavily based on the original patch from Dimitri John Ledkov, and I
copied the commentary verbatim.

Replaces: #8608

4 years agoci: enable DNS over TLS using OpenSSL in the build test
Frantisek Sumsal [Wed, 17 Feb 2021 08:56:59 +0000 (09:56 +0100)] 
ci: enable DNS over TLS using OpenSSL in the build test

Prompted by:
    * https://github.com/systemd/systemd/pull/18641#issuecomment-780371055
    * https://github.com/systemd/systemd/issues/18639

4 years agoMerge pull request #18632 from yuwata/network-nexthop-add-family
Zbigniew Jędrzejewski-Szmek [Wed, 17 Feb 2021 14:02:50 +0000 (15:02 +0100)] 
Merge pull request #18632 from yuwata/network-nexthop-add-family

network: introduce Family= setting in [NextHop] section

4 years agofirewall-util: replace nft_in6addr_to_range() with in_addr_prefix_range() 18653/head
Yu Watanabe [Wed, 17 Feb 2021 13:57:10 +0000 (22:57 +0900)] 
firewall-util: replace nft_in6addr_to_range() with in_addr_prefix_range()

4 years agoin-addr-util: introduce in_addr_prefix_range()
Yu Watanabe [Wed, 17 Feb 2021 13:55:01 +0000 (22:55 +0900)] 
in-addr-util: introduce in_addr_prefix_range()

This will replace nft_in6addr_to_range() in later commit.

4 years agoin-addr-util: make in_addr_prefix_nth() always return valid prefix
Yu Watanabe [Wed, 17 Feb 2021 11:01:26 +0000 (20:01 +0900)] 
in-addr-util: make in_addr_prefix_nth() always return valid prefix

Previously, e.g. in_addr_prefix_nth(2400::1, prefixlen=32, nth=1)
does not return 2400:1:: but does 2400:1::1.

4 years agoin-addr-util: make in_addr_prefix_nth() refuse prefixlen larger than maximum size
Yu Watanabe [Wed, 17 Feb 2021 10:06:36 +0000 (19:06 +0900)] 
in-addr-util: make in_addr_prefix_nth() refuse prefixlen larger than maximum size

4 years agoin-addr-util: make in_addr_prefix_nth() returns 0 on success
Yu Watanabe [Wed, 17 Feb 2021 08:32:54 +0000 (17:32 +0900)] 
in-addr-util: make in_addr_prefix_nth() returns 0 on success

4 years agonetwork: refuse IPv4 multipath route for IPv6 route
Yu Watanabe [Thu, 4 Feb 2021 15:49:49 +0000 (00:49 +0900)] 
network: refuse IPv4 multipath route for IPv6 route

4 years agonetwork: Route::gw_family may be AF_UNSPEC
Yu Watanabe [Tue, 9 Feb 2021 09:35:45 +0000 (18:35 +0900)] 
network: Route::gw_family may be AF_UNSPEC

4 years agologs-show: move show_journal_by_unit _BOOT_ID match
Vito Caputo [Tue, 27 Oct 2020 06:24:34 +0000 (23:24 -0700)] 
logs-show: move show_journal_by_unit _BOOT_ID match

In scrutinizing the journal overhead of `systemctl status $service`
it became apparent that the matching engine was performing the unit
matches on every journal in my system, even ones containing nothing
relevant to the current boot.

This seemed strange and likely suboptimal to me, since there's likely
far more unit data to rifle through than boot IDs in any given
journal.  The _BOOT_ID match seemed like it should be serving as an
early exit match on irrelevant journals, but that wasn't what seemed
to be happening.

As a quick experiment to see if I could get the _BOOT_ID match to be
something along the lines of a higher priority when matching, and try
early exit on these unrelated journals, I moved add_match_this_boot()
to after the unit match adds, inserting a conjunction between them.

The end result seems to be a very substantial performance gain in my
simple uncached tests, and I still get the expected journal output
from the `systemctl status $service` command:

----------------------------------------------------------------------

Unmodified systemctl times:

 root@localhost:/# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/# time systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
    Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
      Docs: man:dbus-daemon(1)
  Main PID: 572 (dbus-daemon)
    Memory: 2.8M
       CPU: 110ms
    CGroup: /system.slice/dbus.service
            └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.695s
 user    0m0.005s
 sys     0m0.043s
 root@localhost:/# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/# time systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
    Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
      Docs: man:dbus-daemon(1)
  Main PID: 572 (dbus-daemon)
    Memory: 2.8M
       CPU: 110ms
    CGroup: /system.slice/dbus.service
            └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.696s
 user    0m0.003s
 sys     0m0.046s
 root@localhost:/# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/# time systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
    Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
      Docs: man:dbus-daemon(1)
  Main PID: 572 (dbus-daemon)
    Memory: 2.8M
       CPU: 110ms
    CGroup: /system.slice/dbus.service
            └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.694s
 user    0m0.006s
 sys     0m0.041s

----------------------------------------------------------------------

Modified systemctl including this commit:

 root@localhost:/home/vc/gh/systemd/build# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/home/vc/gh/systemd/build# time ./systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
      Loaded: loaded (/lib/systemd/system/dbus.service; static)
      Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
 TriggeredBy: ● dbus.socket
        Docs: man:dbus-daemon(1)
    Main PID: 572 (dbus-daemon)
      Memory: 2.8M
         CPU: 110ms
      CGroup: /system.slice/dbus.service
              └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.168s
 user    0m0.003s
 sys     0m0.016s
 root@localhost:/home/vc/gh/systemd/build# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/home/vc/gh/systemd/build# time ./systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
      Loaded: loaded (/lib/systemd/system/dbus.service; static)
      Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
 TriggeredBy: ● dbus.socket
        Docs: man:dbus-daemon(1)
    Main PID: 572 (dbus-daemon)
      Memory: 2.8M
         CPU: 110ms
      CGroup: /system.slice/dbus.service
              └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.167s
 user    0m0.005s
 sys     0m0.013s
 root@localhost:/home/vc/gh/systemd/build# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/home/vc/gh/systemd/build# time ./systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
      Loaded: loaded (/lib/systemd/system/dbus.service; static)
      Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
 TriggeredBy: ● dbus.socket
        Docs: man:dbus-daemon(1)
    Main PID: 572 (dbus-daemon)
      Memory: 2.8M
         CPU: 110ms
      CGroup: /system.slice/dbus.service
              └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.170s
 user    0m0.005s
 sys     0m0.014s

4 years agoresolved: include NSID support to DNS stub
Lennart Poettering [Thu, 12 Nov 2020 19:47:35 +0000 (20:47 +0100)] 
resolved: include NSID support to DNS stub

This adds minimal support for RFC5001 NSID to the stub resolver. This
useful to identify systemd-resolved when talking to the stub resolver,
and distuingishing the packets resolved answers itself (where NSID is
now set) from those which it proxies 1:1 upstream (where NSID will not
be set, or set to whatever the upstream server has it set to).

The NSID chosen consist of two parts:

1. The first part is derived from /etc/machine-id and identifies the
   resolved instance in a stable way.

2. The second part is the fixed string ".resolved.systemd.io".

This thus maybe used for a veriety of checks:

a. Am I talking to a resolved stub?
b. Am I talking to the same stub as last time?
c. Am I talking to the local resolved?

Given that the first part leaks the identity of the system in away two
protections are in place:

I) The NSID is only included on the main stub, not the extra stub. The
   main stub has with a TTL of 1 and other protections a lot of safety
   in place that the datagrams never leave the local system, thus the
   identifying info is only accessible to the local system — but
   /etc/machine-id is accessible to local software anyway.

II) The NSID is hashed from /etc/machine-id in a non-invertable way, so
    that the machine ID itself isn't leaked, but only an identifier
    derived from it.

Example dig run:

```
$ dig +nsid localhost @127.0.0.53

; <<>> DiG 9.11.23-RedHat-9.11.23-1.fc33 <<>> +nsid localhost @127.0.0.53
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46917
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
; NSID: 35 33 64 34 61 34 66 63 32 31 32 65 34 31 61 30 39 66 30 39 65 33 32 34 63 64 64 38 30 36 32 33 2e 72 65 73 6f 6c 76 65 64 2e 73 79 73 74 65 6d 64 2e 69 6f ("53d4a4fc212e41a09f09e324cdd80623.resolved.systemd.io")
;; QUESTION SECTION:
;localhost. IN A

;; ANSWER SECTION:
localhost. 0 IN A 127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Do Nov 12 20:57:16 CET 2020
;; MSG SIZE  rcvd: 110
```

4 years agohwdb: Add accel orientation quirk for the Trekstor Surftab Wintron 10.1 ST10432-3...
Hans de Goede [Tue, 16 Feb 2021 20:24:40 +0000 (21:24 +0100)] 
hwdb: Add accel orientation quirk for the Trekstor Surftab Wintron 10.1 ST10432-3 tablet

Add a quirk to fix the accelerometer orientation on the
Trekstor Surftab Wintron 10.1 ST10432-3 tablet.

4 years agoMerge pull request #18641 from benjarobin/fix-enum-invalid-val
Zbigniew Jędrzejewski-Szmek [Wed, 17 Feb 2021 07:46:09 +0000 (08:46 +0100)] 
Merge pull request #18641 from benjarobin/fix-enum-invalid-val

Various follow-up: Fix build and EINVAL for _INVALID enum value

4 years agotest-network: add tests for Family= in [NextHop] 18632/head
Yu Watanabe [Wed, 3 Feb 2021 08:19:04 +0000 (17:19 +0900)] 
test-network: add tests for Family= in [NextHop]

4 years agoman: update explanations of settings in [NextHop] section
Yu Watanabe [Tue, 9 Feb 2021 06:42:51 +0000 (15:42 +0900)] 
man: update explanations of settings in [NextHop] section

4 years agonetwork: nexthop: refuse 0 id
Yu Watanabe [Thu, 4 Feb 2021 14:22:27 +0000 (23:22 +0900)] 
network: nexthop: refuse 0 id

We usually do not accept values which will be handled as unspecified.
Instead, this makes config_parse_nexthop_id() accept an empty string.

4 years agonetwork: nexthop: introduce Family= setting in [NextHop] section
Yu Watanabe [Wed, 3 Feb 2021 07:59:26 +0000 (16:59 +0900)] 
network: nexthop: introduce Family= setting in [NextHop] section

This is an alias of `Gateway=0.0.0.0` or `Gateway=::`.

4 years agonetwork: allow to configure nexthop with null address
Yu Watanabe [Wed, 3 Feb 2021 08:07:24 +0000 (17:07 +0900)] 
network: allow to configure nexthop with null address

Closes #18446.

4 years agonetwork: nexthop: unset gateway when an empty string is assigned
Yu Watanabe [Wed, 3 Feb 2021 07:58:29 +0000 (16:58 +0900)] 
network: nexthop: unset gateway when an empty string is assigned

4 years agocondition: add CPUFeature
Giedrius Statkevičius [Wed, 11 Nov 2020 20:45:58 +0000 (22:45 +0200)] 
condition: add CPUFeature

Taking a stab at implementing #14479.

Add {Condition,Assert}CPUFeature to `systemd-analyze` & friends. Implement it
by executing the CPUID instruction. Add tables for common x86/i386
features.

Tested via unit tests + checked that commands such as:

```bash
systemd-analyze condition 'AssertCPUFeature = rdrand'
```

Succeed as expected and that commands such as

```bash
systemd-analyze condition 'AssertCPUFeature = foobar'
```

Fail as expected. Finally, I have amended the `systemd.unit` manual page
with the new condition and the list of all currently supported flags.

4 years agoresolve: Fix build for cleanup function (SSL_free + BIO_free) 18641/head
Benjamin Robin [Tue, 16 Feb 2021 22:57:29 +0000 (23:57 +0100)] 
resolve: Fix build for cleanup function (SSL_free + BIO_free)

Follow-up of #18616

4 years agoMerge pull request #18007 from fw-strlen/ipv6_masq_and_dnat
Lennart Poettering [Tue, 16 Feb 2021 22:41:35 +0000 (23:41 +0100)] 
Merge pull request #18007 from fw-strlen/ipv6_masq_and_dnat

Support ipv6 for masquerade and dnat in nspawn and networkd

4 years agoshared: use -EINVAL for _NETDEV_BRIDGE_STATE_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:24:11 +0000 (23:24 +0100)] 
shared: use -EINVAL for _NETDEV_BRIDGE_STATE_INVALID

Follow-up of #11484

4 years agoportable: use -EINVAL for _PORTABLE_CHANGE_TYPE_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:23:41 +0000 (23:23 +0100)] 
portable: use -EINVAL for _PORTABLE_CHANGE_TYPE_INVALID

Follow-up of #11484

4 years agolibsystemd-network: use -EINVAL for _DUID_TYPE_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:23:13 +0000 (23:23 +0100)] 
libsystemd-network: use -EINVAL for _DUID_TYPE_INVALID

Follow-up of #11484

4 years agobasic: use -EINVAL for _DUID_TYPE_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:22:37 +0000 (23:22 +0100)] 
basic: use -EINVAL for _DUID_TYPE_INVALID

Follow-up of #11484 and of #18481

4 years agoshared: Fix _DNS_CACHE_MODE_INVALID value: use -EINVAL
Benjamin Robin [Tue, 16 Feb 2021 22:22:00 +0000 (23:22 +0100)] 
shared: Fix _DNS_CACHE_MODE_INVALID value: use -EINVAL

Follow-up of #11484

4 years agoshared: use -EINVAL for _UNIT_FILE_CHANGE_TYPE_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:21:07 +0000 (23:21 +0100)] 
shared: use -EINVAL for _UNIT_FILE_CHANGE_TYPE_INVALID

Follow-up of #11484

4 years agoshared: use -EINVAL for _EXEC_COMMAND_FLAGS_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:19:37 +0000 (23:19 +0100)] 
shared: use -EINVAL for _EXEC_COMMAND_FLAGS_INVALID

Follow-up of #11484

4 years agobasic: use -EINVAL for _MANAGED_OOM_PREFERENCE_INVALID
Benjamin Robin [Tue, 16 Feb 2021 22:18:28 +0000 (23:18 +0100)] 
basic: use -EINVAL for _MANAGED_OOM_PREFERENCE_INVALID

Follow-up of #11484

4 years agojournal-file: fix archiving offline journals
Vito Caputo [Sun, 29 Nov 2020 00:28:08 +0000 (16:28 -0800)] 
journal-file: fix archiving offline journals

The existing set_offline() short-circuit erroneously included
when f->archive was true and header->state was STATE_OFFLINE.

This commit makes the short-circuit f->archive aware, so it will
only catch scenarios where there's not an offlining in progress
and the header state matches the target state of either archived
or offline.

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

4 years agoMerge pull request #18601 from keszybz/env-assign-cleanup
Lennart Poettering [Tue, 16 Feb 2021 21:36:48 +0000 (22:36 +0100)] 
Merge pull request #18601 from keszybz/env-assign-cleanup

Envvar assignment cleanup

4 years agonetlink: introduce sd_netlink_message_has_flag()
Yu Watanabe [Sun, 14 Feb 2021 17:49:55 +0000 (02:49 +0900)] 
netlink: introduce sd_netlink_message_has_flag()

4 years agoMerge pull request #18631 from yuwata/sd-netlink-fix-assertions
Lennart Poettering [Tue, 16 Feb 2021 21:36:06 +0000 (22:36 +0100)] 
Merge pull request #18631 from yuwata/sd-netlink-fix-assertions

sd-netlink: update assertions and drop unused functions

4 years agosystemd: don't try to run as user manager when called without any arguments
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 16:40:56 +0000 (17:40 +0100)] 
systemd: don't try to run as user manager when called without any arguments

It's better for users if programs don't do "significant" things too easily, and
should be especially conservative when called without any arguments whatsoever.
So far systemd would would try to launch itself as a user manager and fail on
some cgroup permission stuff. systemd --user is run execlusively from user@.service
and there we call it with --user. Calls to the binary without any arguments as
non-pid1 are almost always a mistake.

https://github.com/systemd/systemd/issues/18419#issuecomment-779422571

4 years agoman: make clear that sd-journal notifications always come with extra latency
Lennart Poettering [Tue, 16 Feb 2021 16:15:16 +0000 (17:15 +0100)] 
man: make clear that sd-journal notifications always come with extra latency

Replaces: #17699

4 years agoMerge pull request #18636 from poettering/resolved-different-server
Lennart Poettering [Tue, 16 Feb 2021 19:27:09 +0000 (20:27 +0100)] 
Merge pull request #18636 from poettering/resolved-different-server

resolved: tweaks for switching to different DNS servers

4 years agoMerge pull request #18620 from bluca/mount_images_fixes
Lennart Poettering [Tue, 16 Feb 2021 19:26:06 +0000 (20:26 +0100)] 
Merge pull request #18620 from bluca/mount_images_fixes

MountImages and core tmpfs fixes

4 years agoMerge pull request #18616 from keszybz/argv-fuzzer-quick-fix
Lennart Poettering [Tue, 16 Feb 2021 19:25:37 +0000 (20:25 +0100)] 
Merge pull request #18616 from keszybz/argv-fuzzer-quick-fix

fuzz-systemctl-parse-argv: avoid "leak" of bus object

4 years agologind: Restore chvt as non-root user without polkit
Joshua Watt [Fri, 30 Oct 2020 13:15:43 +0000 (08:15 -0500)] 
logind: Restore chvt as non-root user without polkit

4acf0cfd2f ("logind: check PolicyKit before allowing VT switch") broke
the ability to write user sessions that run graphical sessions (e.g.
weston/X11). This was partially amended in 19bb87fbfa ("login: allow
non-console sessions to change vt") by changing the default PolicyKit
policy so that non-root users with a session are again allowed to switch
the VT. This makes the policy when PolKit is not enabled (as on many
embedded systems) closer the default PolKit policy and allows launching
graphical sessions as a non-root user.

Closes #17473

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
4 years agostat-util: fix dir_is_empty_at without path
Luca Boccassi [Mon, 18 Jan 2021 20:15:03 +0000 (20:15 +0000)] 
stat-util: fix dir_is_empty_at without path

Use the right FD, and do a fd_reopen instead of a dup, since the
latter will still share the internal pointer which then gets
moved by FOREACH_DIRENT, affecting the caller's FD.

4 years agoMerge pull request #18624 from poettering/resolved-feature-level-tweak
Lennart Poettering [Tue, 16 Feb 2021 19:24:05 +0000 (20:24 +0100)] 
Merge pull request #18624 from poettering/resolved-feature-level-tweak

resolved: three tweaks to server feature level tracking

4 years agoMerge pull request #18629 from yuwata/sd-netlink-nexthop-types
Yu Watanabe [Tue, 16 Feb 2021 19:06:15 +0000 (04:06 +0900)] 
Merge pull request #18629 from yuwata/sd-netlink-nexthop-types

sd-netlink: add nexthop related types

4 years agoresolved: unify code for trying a different DNS server 18636/head
Lennart Poettering [Thu, 12 Nov 2020 17:36:08 +0000 (18:36 +0100)] 
resolved: unify code for trying a different DNS server

Let's unify some code, and add a common implementation of a function
that checks whether we have tried all DNS servers yet, and retries the
transaction if we don't. We already use this same code twice. Let's use
it at some other places too now — basically all cases where we switch to
a new server — with the one case of packet loss, where we too switch
servers, but don#t care how many times we already tried to switch.

4 years agoresolved: improve log message when retrying a transaction with a different server
Lennart Poettering [Thu, 12 Nov 2020 17:34:18 +0000 (18:34 +0100)] 
resolved: improve log message when retrying a transaction with a different server

4 years agoresolved: never go below DNSSEC feature level in DNSSEC strict mode 18624/head
Lennart Poettering [Thu, 12 Nov 2020 15:05:15 +0000 (16:05 +0100)] 
resolved: never go below DNSSEC feature level in DNSSEC strict mode

This adjusts our feature level handling: when DNSSEC strict mode is on,
let's never lower the feature level below the lowest DNSSEC mode.

Also, when asking whether DNSSEC is supproted, always say yes in strict
mode. This means that error reporting about transactions that fail
because of missing DNSSEC RRs will not report "incompatible-server" but
instead "missing-signature" or suchlike.

The main difference here is that DNSSEC failures become local to a
transaction, instead of propagating into the feature level we reuse for
future transactions. This is beneficial with routers that implement
"mostly a DNS proxy", i.e. that propagate most DNS requests 1:1 to their
upstream servers, but synthesize local answers for a select few domains.
For example, AVM Fritz!Boxes operate that way: they proxy most traffic
1:1 upstream in an DNSSEC-compatible fashion, but synthesize the
"fritz.box" locally, so that it can be used to configure the router.
This local domain cannot be DNSSEC verified, it comes without
signatures. Previously this would mean once that domain was resolved
feature level would be downgraded, and we'd thus fail all future DNSSEC
attempts. With this change, the immediate lookup for "fritz.box" will
fail validation, but for all other unrelated future ones that comes
without prejudice.

(While we are at it, also make a couple of other downgrade paths a bit
tighter.)

Fixes: #10570 #14435 #6490
4 years agoresolved: make feature level checks a bit more discriptive
Lennart Poettering [Wed, 11 Nov 2020 20:19:22 +0000 (21:19 +0100)] 
resolved: make feature level checks a bit more discriptive

The levels have an order, but the order is sometimes a bit arbitrary.
Hence add simple macros to check for specific features and use those, so
that the ordering leaks a bit less into all files.

4 years agoresolved: when we can't parse a packet, downgrade feature level
Lennart Poettering [Wed, 11 Nov 2020 20:03:04 +0000 (21:03 +0100)] 
resolved: when we can't parse a packet, downgrade feature level

So far we didn't really handle the case where we can't parse a reply
packet. Since this apparently happens in real-life though, let's add
some minimal logic, to downgrade/restart if we see this.

4 years agonetlink: drop sd_rtnl_message_{route,nexthop}_set_family() 18631/head
Yu Watanabe [Mon, 15 Feb 2021 00:21:24 +0000 (09:21 +0900)] 
netlink: drop sd_rtnl_message_{route,nexthop}_set_family()

The family is already set when the message is created.

4 years agonetwork: drop unnecessary family setting
Yu Watanabe [Tue, 16 Feb 2021 17:05:28 +0000 (02:05 +0900)] 
network: drop unnecessary family setting

It is already set in sd_rtnl_message_new_nexthop().

4 years agoman: fix indentation
Yu Watanabe [Sun, 14 Feb 2021 05:49:46 +0000 (14:49 +0900)] 
man: fix indentation

4 years agoresolved: paranoia — ensure DNS reply came over stream we sent it to
Lennart Poettering [Tue, 10 Nov 2020 17:45:28 +0000 (18:45 +0100)] 
resolved: paranoia — ensure DNS reply came over stream we sent it to

4 years agoAdding an explanation for CONFIG_NET requirement (#18600)
heretoenhance [Tue, 16 Feb 2021 16:26:51 +0000 (16:26 +0000)] 
Adding an explanation for CONFIG_NET requirement (#18600)

* README: replace CONFIG_NET with CONFIG_UNIX in requirements list

4 years agonetlink: fix assertions
Yu Watanabe [Mon, 15 Feb 2021 00:15:06 +0000 (09:15 +0900)] 
netlink: fix assertions

4 years agonetlink: add nexthop related types 18629/head
Yu Watanabe [Sun, 14 Feb 2021 17:38:28 +0000 (02:38 +0900)] 
netlink: add nexthop related types

4 years agosd-netlink: add RTA_NH_ID attribute support
Yu Watanabe [Thu, 4 Feb 2021 14:32:12 +0000 (23:32 +0900)] 
sd-netlink: add RTA_NH_ID attribute support

4 years agoRename unit_times_free to unit_times_free_array 18616/head
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 16:09:00 +0000 (17:09 +0100)] 
Rename unit_times_free to unit_times_free_array

It frees the whole array and the type is UnitTimes not UnitTime.

4 years agoRename strbuf_cleanup to strbuf_free
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 16:05:42 +0000 (17:05 +0100)] 
Rename strbuf_cleanup to strbuf_free

It frees the whole object.

4 years agofuzz-systemctl-parse-argv: call static destuctors
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 13:27:26 +0000 (14:27 +0100)] 
fuzz-systemctl-parse-argv: call static destuctors

With all the preparatory work in previous PRs, we can now call static destructors
repeatedly without issue. We need to do it here so that global variables allocated
during parsing are properly freed.

4 years agosystemctl: use free_and_replace on global variable
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 13:19:36 +0000 (14:19 +0100)] 
systemctl: use free_and_replace on global variable

In normal usage we cannot set it multiple times, but from a fuzzer we
may. Doing it this way is nicer anyway.

4 years agotree-wide: reset the cleaned-up variable in cleanup functions
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 13:18:30 +0000 (14:18 +0100)] 
tree-wide: reset the cleaned-up variable in cleanup functions

If the cleanup function returns the appropriate type, use that to reset the
variable. For other functions (usually the foreign ones which return void), add
an explicit value to reset to.

This causes a bit of code churn, but I think it might be worth it. In a
following patch static destructors will be called from a fuzzer, and this
change allows them to be called multiple times. But I think such a change might
help with detecting unitialized code reuse too. We hit various bugs like this,
and things are more obvious when a pointer has been set to NULL.

I was worried whether this change increases text size, but it doesn't seem to:

-Dbuildtype=debug:
before "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 4117672 Feb 16 14:36 build/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 4494520 Feb 16 15:06 build/systemd*
after "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 4117672 Feb 16 14:36 build/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 4494576 Feb 16 15:10 build/systemd*
now:
-rwxrwxr-x 1 zbyszek zbyszek 4117672 Feb 16 14:36 build/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 4494640 Feb 16 15:15 build/systemd*

-Dbuildtype=release:
before "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 5252256 Feb 14 14:47 build-rawhide/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 1834184 Feb 16 15:09 build-rawhide/systemd*
after "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 5252256 Feb 14 14:47 build-rawhide/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 1834184 Feb 16 15:10 build-rawhide/systemd*
now:
-rwxrwxr-x 1 zbyszek zbyszek 5252256 Feb 14 14:47 build-rawhide/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 1834184 Feb 16 15:16 build-rawhide/systemd*

I would expect that the compiler would be able to elide the setting of a
variable if the variable is never used again. And this seems to be the case:
in optimized builds there is no change in size whatsoever. And the change in
size in unoptimized build is negligible.

Something strange is happening with size of libsystemd: it's bigger in
optimized builds. Something to figure out, but unrelated to this patch.

4 years agotree-wide: return NULL from freeing functions
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 12:48:04 +0000 (13:48 +0100)] 
tree-wide: return NULL from freeing functions

I started working on this because I wanted to change how
DEFINE_TRIVIAL_CLEANUP_FUNC is defined. Even independently of that change, it's
nice to make make things more consistent and predictable.

4 years agoresolved: reduce indentation level a bit
Lennart Poettering [Wed, 11 Nov 2020 20:02:06 +0000 (21:02 +0100)] 
resolved: reduce indentation level a bit

4 years agoresolved: let's preferably route reverse lookups for local subnets to matching interfaces
Lennart Poettering [Mon, 9 Nov 2020 21:22:56 +0000 (22:22 +0100)] 
resolved: let's preferably route reverse lookups for local subnets to matching interfaces

Let's preferably route traffic for reverse lookups to LLMNR/mDNS/DNS on
the matching interface if the IP address is in the local subnet. Also,
if looking up an IP address of our own host, let's avoid doing
LLMNR/mDNS at all.

This is useful if "~." is a routing domain to DNS, as it means, local
reverse lookups still go to LLMNR/mDNS, too.

Fixes: #16243 #10081
4 years agoRefactor strv_env_replace() into strv_env_replace_consume() 18601/head
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 15:04:41 +0000 (16:04 +0100)] 
Refactor strv_env_replace() into strv_env_replace_consume()

All callers of strv_env_replace() would free the argument on error.
So let's follow the same pattern as with strv_consume (and similar
naming) and unconditionally "use up" the argument.

4 years agoshared/exec-util: fix minor memleak
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 15:00:17 +0000 (16:00 +0100)] 
shared/exec-util: fix minor memleak

p was not freed on error.

4 years agotest-env-util: add tests for the two new functions
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 14:01:52 +0000 (15:01 +0100)] 
test-env-util: add tests for the two new functions

4 years agobasic/env-util: drop now-unused strv_env_set()
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 13:55:40 +0000 (14:55 +0100)] 
basic/env-util: drop now-unused strv_env_set()

4 years agobasic/env-util: add strv_env_assign() helper
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 13:52:39 +0000 (14:52 +0100)] 
basic/env-util: add strv_env_assign() helper

4 years agoshared/user-record: inline iterator variable declarations
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 13:22:18 +0000 (14:22 +0100)] 
shared/user-record: inline iterator variable declarations

4 years agolocale: inline iterator variable declarations
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 13:17:50 +0000 (14:17 +0100)] 
locale: inline iterator variable declarations

4 years agonamespace: store and use original MountEntry paths when prefixing 18620/head
Luca Boccassi [Thu, 28 Jan 2021 17:02:33 +0000 (17:02 +0000)] 
namespace: store and use original MountEntry paths when prefixing

Some paths (eg: mount_tmpfs) simply assumed that prefixing always
happens and it always stores the original path in path_const, and
the prefixed path in path_malloc.
But if a MountEntry is set up in a helper function and thus uses
only _malloc struct members, this assumption doesn't hold and there's
a crash.

Refactor so that prefixing is done with a helper which stores the
original path in a separate struct member, and accessing it also
uses a helper which does the right thing.

4 years agoMountImages: actually support optional paths
Luca Boccassi [Thu, 28 Jan 2021 13:25:41 +0000 (13:25 +0000)] 
MountImages: actually support optional paths

ENOENT did not cause an image mount to be skipped, fix it

4 years agonetworkd: make network_config_section_free() inline
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 13:14:41 +0000 (14:14 +0100)] 
networkd: make network_config_section_free() inline

4 years agoresolved: make dns_transaction_gc return a pointer
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 13:10:28 +0000 (14:10 +0100)] 
resolved: make dns_transaction_gc return a pointer

_gc() does cleanup if it is possible. So far it returned a bool to
signal if it succeeded (false on success). When working on the resolved
code I had to look at the definition every time, because the (arguably
reversed) calling convention is unobvious. So let's return a pointer
(non-NULL: gc has not been done, NULL: gc has been done).

This fits nicely with the standard to return a pointer from all free
functions obviously.

4 years agonetworkd-ndisc: drop confused freepp function
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 12:57:43 +0000 (13:57 +0100)] 
networkd-ndisc: drop confused freepp function

The function to cleanup IPv6Token was defined using freep, i.e. the macro
generated a freepp function. The correct way would be to do something like
  #define ipv6_token_free mfree
  DEFINE_TRIVIAL_CLEANUP_FUNC(IPv6Token *, ipv6_token_free);
which would create ipv6_token_freep().
But since the cleanup function is unused, let's just drop it.

4 years agocoredump: add typedef for struct
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 12:51:58 +0000 (13:51 +0100)] 
coredump: add typedef for struct

4 years agobasic/capability-util: add missing initialization
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 12:50:08 +0000 (13:50 +0100)] 
basic/capability-util: add missing initialization

There was no error, because the pointer is unconditionally set below.

4 years agoanalyze: use typedefs for structs and inline iterator variable decls
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2021 12:36:59 +0000 (13:36 +0100)] 
analyze: use typedefs for structs and inline iterator variable decls

4 years agoresolved: log process info of clients requesting resolution via D-Bus
Lennart Poettering [Mon, 9 Nov 2020 21:20:16 +0000 (22:20 +0100)] 
resolved: log process info of clients requesting resolution via D-Bus

Let's make things more debuggable: when debug logging is on, let's
say which client is asking for our services.

This is helpful for easily figuring out which local process might
interfere with your debugging sessions by issuing additional requests
while you try to debug a request (I am looking at you, geoclue!).

4 years agoMerge pull request #18617 from poettering/resolved-confidential
Lennart Poettering [Tue, 16 Feb 2021 12:40:46 +0000 (13:40 +0100)] 
Merge pull request #18617 from poettering/resolved-confidential

resolved: tell clients which source a response is from, and whether it was never sent via unencrypted transports

4 years agoresolved: propagate source where an RR from back to client 18617/head
Lennart Poettering [Tue, 10 Nov 2020 22:34:40 +0000 (23:34 +0100)] 
resolved: propagate source where an RR from back to client

This is extremely useful when debugging stuff: knowing whether a result
was cached, came from network, or was synthesized.

4 years agoresolved: add "confidential" flag for replies passed to clients
Lennart Poettering [Tue, 10 Nov 2020 17:06:19 +0000 (18:06 +0100)] 
resolved: add "confidential" flag for replies passed to clients

Let's introduce a new flag that indicates whether the response was
acquired in "confidential" mode, i.e. via encrypted DNS-over-TLS, or
synthesized locally.

Fixes: #12859
4 years agoresolved: replace "answer_authenticated" bool by uint64_t query_flags field
Lennart Poettering [Tue, 10 Nov 2020 16:14:16 +0000 (17:14 +0100)] 
resolved: replace "answer_authenticated" bool by uint64_t query_flags field

Let's use the same flags type we use for client communication, i.e.
instead of "bool answer_authenticated", let's use "uint64_t
answer_query_flags", with the SD_RESOLVED_AUTHENTICATED flag.

This is mostly just search/replace, i.e. a refactoring, no change in
behaviour.

This becomes useful once in a later commit SD_RESOLVED_CONFIDENTIAL is
added to indicate resolution that either were encrypted (DNS-over-TLS)
or never left the local system.

4 years agoMerge pull request #18611 from poettering/ifname-validate-tighter
Lennart Poettering [Tue, 16 Feb 2021 08:52:32 +0000 (09:52 +0100)] 
Merge pull request #18611 from poettering/ifname-validate-tighter

make ifname validation tighter