1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00
Commit Graph

52397 Commits

Author SHA1 Message Date
Yu Watanabe
e2bacccd06 network: fix segfault in link_update_hardware_address()
This fixes a bug introduced by fe321d457c.

When we want to update a value (in the case of this commit, it is a hardware
address) which is used as a hashmap key, we need to do the following steps:
1. remove the old hashmap entry,
2. update the value,
3. create a new hashmap entry with the new value.
2021-07-01 16:24:07 +09:00
Yu Watanabe
cd3a828c62 network: ipv4acd: update log message
C.f. https://github.com/systemd/systemd/pull/19980#discussion_r661784168
2021-07-01 16:24:07 +09:00
Zbigniew Jędrzejewski-Szmek
dd376574fd
Merge pull request #20080 from bluca/core_flag
analyze: do not attempt to set up cgroups while verifying units
2021-07-01 09:04:15 +02:00
Zbigniew Jędrzejewski-Szmek
cc03890a9d
Merge pull request #20058 from keszybz/status-format
Implement StatusUnitFormat=combined and prettify Descriptions
2021-07-01 08:58:14 +02:00
Zbigniew Jędrzejewski-Szmek
9faf12110a
Merge pull request #20030 from keszybz/exec_fd-event-source
exec_fd event source rework
2021-07-01 08:57:23 +02:00
Lennart Poettering
988bcc7c21 Revert "core: do not set noexec on sysfs/procfs"
This reverts commit b33cd6b3ee.
2021-07-01 08:54:46 +02:00
Luca Boccassi
a381a9d134 analyze: use MANAGER_TEST_RUN_MINIMAL instead of MANAGER_TEST_RUN_BASIC
MANAGER_TEST_RUN_MINIMAL allows to skip setting up cgroups, which we don't
really want to do in systemd-analyze. MANAGER_TEST_RUN_BASIC doesn't
actually do anything by itself anyway.
2021-07-01 00:06:35 +01:00
Luca Boccassi
5dd2f5ff07 core: do not setup/teardown cgroup if MANAGER_TEST_RUN_MINIMAL is set as a flag
Rather than checking if test_run_flags is set exclusively to MANAGER_TEST_RUN_MINIMAL,
check if it is set as a flag, so that it can be used together with other flags.
2021-07-01 00:06:35 +01:00
Zbigniew Jędrzejewski-Szmek
24c006d83d
Merge pull request #20076 from keszybz/improve-logs-for-exec-condition-and-rescoping
Improve logs for ExecCondition and rescoping
2021-06-30 22:23:10 +02:00
Zbigniew Jędrzejewski-Szmek
807aa0b64b
Merge pull request #19980 from yuwata/sd-ipv4acd-filter-all-hwaddr
network: IPv4LL and ACD fixes
2021-06-30 22:22:47 +02:00
Zbigniew Jędrzejewski-Szmek
dc9880d475
Merge pull request #20020 from anitazha/oomd_with_mem
oomd: check that memory use also exceeds threshold before doing a swap kill
2021-06-30 21:59:34 +02:00
Luca Boccassi
e01030633c core: when recursively bind-remounting nested mounts, use options from top one
When mount points are stacked, bind_remount_recursive_with_mountinfo()
uses the existing mount options of the "lower" level mount (ie: the
first one that was mounted on a mount point). But the actual mount
point in use is the "top" one (ie: the last one that was mounted on a
mount point), so in practice if the mount options are different between
the layers, the bottom options are used by mistake on the top mount,
which is not what we want. This is because libmount returns the "bottom"
one first.

If the hashmap returns EEXIST, which means the same key (path) with different
value (options) is already present, update the hashmap instead of discarding
the result. This way, the last/top mount options are always used when
mounts are stacked on a mount point.

This was found to cause problems as LXC version 4.x stacks two /sys mounts,
the bottom one read-write and the top one read-only. systemd accidentally
remounts the top-one read-write, breaking various expectations since a
read-only /sys is the way we decide whether we are running in a container
or not (in this particular case, networkd tests are broken as networkd
expects to be able to modify network settings with a writable /sys).

Future versions of LXC will no longer do this double-stacking, but we
need to support running inside older versions too.

This was triggered by https://github.com/systemd/systemd/commit/6720e356c137
as that causes a recursive remount of '/', which processes '/sys' as one
of the submounts, from make_nosuid(). But it's likely that other combinations
of options could trigger this as well.

Before:

root@systemd-debug:/# systemd-run -t --wait --property ProtectSystem=yes findmnt
Running as unit: run-u9.service
Press ^] three times within 1s to disconnect TTY.
TARGET                         SOURCE                           FSTYPE    OPTIONS
/                              /dev/sda2[/var/lib/lxc/systemd-debug/rootfs]
│                                                               ext4      ro,nosuid,relatime,errors=remount-ro,stripe=
├─/dev                         none                             tmpfs     rw,nosuid,relatime,size=492k,mode=755
│ ├─/dev/.lxc/proc             proc                             proc      rw,nosuid,relatime
│ ├─/dev/.lxc/sys              sys                              sysfs     rw,nosuid,relatime
│ ├─/dev/console               devpts[/2]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/pts                   devpts                           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/ptmx                  devpts[/ptmx]                    devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty1                  devpts[/0]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty2                  devpts[/1]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty3                  devpts[/2]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty4                  devpts[/3]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/shm                   tmpfs                            tmpfs     rw,nosuid,nodev
│ ├─/dev/hugepages             hugetlbfs                        hugetlbfs rw,nosuid,relatime,pagesize=2M
│ └─/dev/mqueue                mqueue                           mqueue    rw,nosuid,nodev,noexec,relatime
├─/proc                        proc                             proc      rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys                  proc[/sys]                       proc      ro,nosuid,nodev,noexec,relatime
│ │ ├─/proc/sys/net            proc[/sys/net]                   proc      rw,nosuid,nodev,noexec,relatime
│ │ └─/proc/sys/kernel/random/boot_id
│ │                            none[/.lxc-boot-id]              tmpfs     ro,nosuid,nodev,noexec,relatime,size=492k,mo
│ └─/proc/sysrq-trigger        proc[/sysrq-trigger]             proc      ro,nosuid,nodev,noexec,relatime
├─/sys                         sysfs                            sysfs     rw,nosuid,nodev,noexec,relatime
│ └─/sys                       sysfs                            sysfs     rw,nosuid,nodev,noexec,relatime
│   ├─/sys/devices/virtual/net sysfs                            sysfs     rw,relatime
│   │ └─/sys/devices/virtual/net
│   │                          sysfs[/devices/virtual/net]      sysfs     rw,nosuid,relatime
│   ├─/sys/fs/fuse/connections fusectl                          fusectl   rw,nosuid,nodev,noexec,relatime
│   └─/sys/fs/cgroup           cgroup                           cgroup2   rw,nosuid,nodev,noexec,relatime,nsdelegate,m
├─/run                         tmpfs                            tmpfs     ro,nosuid,nodev,size=4912348k,nr_inodes=8192
│ ├─/run/credentials           tmpfs[/systemd/inaccessible/dir] tmpfs     ro,nosuid,nodev,noexec,size=4912348k,nr_inod
│ └─/run/systemd/incoming      tmpfs[/systemd/propagate/run-u9.service]
│                                                               tmpfs     ro,nosuid,nodev,size=4912348k,nr_inodes=8192
├─/tmp                         tmpfs                            tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409
│ └─/tmp                       tmpfs[/systemd-private-b730df90da424397a3f246cb15dcdbb1-run-u9.service-K6EUwf/tmp]
│                                                               tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409
└─/var/tmp                     /dev/sda2[/var/lib/lxc/systemd-debug/rootfs/var/tmp/systemd-private-b730df90da424397a3f246cb15dcdbb1-run-u9.service-vEHyRi/tmp]
                                                                ext4      rw,nosuid,relatime,errors=remount-ro,stripe=
Finished with result: success
Main processes terminated with: code=exited/status=0
Service runtime: 14.249s
CPU time consumed: 37ms

After:

root@systemd-debug:/# systemd-run -t --wait --property ProtectSystem=yes findmnt
Running as unit: run-u3.service
Press ^] three times within 1s to disconnect TTY.
TARGET                         SOURCE                      FSTYPE    OPTIONS
/                              /dev/sda2[/var/lib/lxc/systemd-debug/rootfs]
│                                                          ext4      rw,relatime,errors=remount-ro,stripe=32699
├─/dev                         none                        tmpfs     rw,relatime,size=492k,mode=755
│ ├─/dev/.lxc/proc             proc                        proc      rw,relatime
│ ├─/dev/.lxc/sys              sys                         sysfs     rw,relatime
│ ├─/dev/console               devpts[/2]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/pts                   devpts                      devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/ptmx                  devpts[/ptmx]               devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty1                  devpts[/0]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty2                  devpts[/1]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty3                  devpts[/2]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty4                  devpts[/3]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/shm                   tmpfs                       tmpfs     rw,nosuid,nodev
│ ├─/dev/hugepages             hugetlbfs                   hugetlbfs rw,relatime,pagesize=2M
│ └─/dev/mqueue                mqueue                      mqueue    rw,nosuid,nodev,noexec,relatime
├─/proc                        proc                        proc      rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys                  proc[/sys]                  proc      ro,nosuid,nodev,noexec,relatime
│ │ ├─/proc/sys/net            proc[/sys/net]              proc      rw,nosuid,nodev,noexec,relatime
│ │ └─/proc/sys/kernel/random/boot_id
│ │                            none[/.lxc-boot-id]         tmpfs     ro,nosuid,nodev,noexec,relatime,size=492k,mode=75
│ └─/proc/sysrq-trigger        proc[/sysrq-trigger]        proc      ro,nosuid,nodev,noexec,relatime
├─/sys                         sysfs                       sysfs     rw,nosuid,nodev,noexec,relatime
│ └─/sys                       sysfs                       sysfs     ro,nosuid,nodev,noexec,relatime
│   ├─/sys/devices/virtual/net sysfs                       sysfs     rw,relatime
│   │ └─/sys/devices/virtual/net
│   │                          sysfs[/devices/virtual/net] sysfs     rw,nosuid,nodev,noexec,relatime
│   ├─/sys/fs/fuse/connections fusectl                     fusectl   rw,nosuid,nodev,noexec,relatime
│   └─/sys/fs/cgroup           cgroup                      cgroup2   rw,nosuid,nodev,noexec,relatime,nsdelegate,memory
├─/run                         tmpfs                       tmpfs     rw,nosuid,nodev,size=4912348k,nr_inodes=819200,mo
│ ├─/run/credentials           tmpfs[/systemd/inaccessible/dir]
│ │                                                        tmpfs     ro,nosuid,nodev,noexec,size=4912348k,nr_inodes=81
│ └─/run/systemd/incoming      tmpfs[/systemd/propagate/run-u3.service]
│                                                          tmpfs     ro,nosuid,nodev,size=4912348k,nr_inodes=819200,mo
├─/tmp                         tmpfs                       tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409600
├─/boot                        /dev/sda2[/var/lib/lxc/systemd-debug/rootfs/boot]
│                                                          ext4      ro,relatime,errors=remount-ro,stripe=32699
└─/usr                         /dev/sda2[/var/lib/lxc/systemd-debug/rootfs/usr]
                                                           ext4      ro,relatime,errors=remount-ro,stripe=32699
Finished with result: success
Main processes terminated with: code=exited/status=0
Service runtime: 14ms
CPU time consumed: 5ms

Host (LXC):

root@systemd-debug:/# findmnt
TARGET                         SOURCE               FSTYPE    OPTIONS
/                              /dev/sda2[/var/lib/lxc/systemd-debug/rootfs]
│                                                   ext4      rw,relatime,errors=remount-ro,stripe=32699
├─/run                         tmpfs                tmpfs     rw,nosuid,nodev,size=4912348k,nr_inodes=819200,mode=755
├─/tmp                         tmpfs                tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409600
├─/dev                         none                 tmpfs     rw,relatime,size=492k,mode=755
│ ├─/dev/pts                   devpts               devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/ptmx                  devpts[/ptmx]        devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty1                  devpts[/0]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty2                  devpts[/1]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty3                  devpts[/2]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty4                  devpts[/3]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/shm                   tmpfs                tmpfs     rw,nosuid,nodev
│ ├─/dev/hugepages             hugetlbfs            hugetlbfs rw,relatime,pagesize=2M
│ ├─/dev/mqueue                mqueue               mqueue    rw,nosuid,nodev,noexec,relatime
│ ├─/dev/console               devpts[/2]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/.lxc/proc             proc                 proc      rw,relatime
│ └─/dev/.lxc/sys              sys                  sysfs     rw,relatime
├─/proc                        proc                 proc      rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys                  proc[/sys]           proc      ro,nosuid,nodev,noexec,relatime
│ │ ├─/proc/sys/kernel/random/boot_id
│ │ │                          none[/.lxc-boot-id]  tmpfs     ro,nosuid,nodev,noexec,relatime,size=492k,mode=755
│ │ └─/proc/sys/net            proc[/sys/net]       proc      rw,nosuid,nodev,noexec,relatime
│ └─/proc/sysrq-trigger        proc[/sysrq-trigger] proc      ro,nosuid,nodev,noexec,relatime
└─/sys                         sysfs                sysfs     rw,nosuid,nodev,noexec,relatime
  └─/sys                       sysfs                sysfs     ro,nosuid,nodev,noexec,relatime
    ├─/sys/devices/virtual/net sysfs                sysfs     rw,relatime
    │ └─/sys/devices/virtual/net
    │                          sysfs[/devices/virtual/net]
    │                                               sysfs     rw,nosuid,nodev,noexec,relatime
    ├─/sys/fs/fuse/connections fusectl              fusectl   rw,nosuid,nodev,noexec,relatime
    └─/sys/fs/cgroup           cgroup               cgroup2   rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recurs

Fixes https://github.com/systemd/systemd/issues/20032
2021-06-30 21:57:35 +02:00
Zbigniew Jędrzejewski-Szmek
abaf5edd08 Revert "Introduce ExitType"
This reverts commit cb0e818f7c.

After this was merged, some design and implementation issues were discovered,
see the discussion in #18782 and #19385. They certainly can be fixed, but so
far nobody has stepped up, and we're nearing a release. Hopefully, this feature
can be merged again after a rework.

Fixes #19345.
2021-06-30 21:56:47 +02:00
Zbigniew Jędrzejewski-Szmek
7a2ba40787 core/cgroup: upgrade log level when we fail to rescope a pid
See https://bugzilla.redhat.com/show_bug.cgi?id=1973058 again:

systemd[1779]: Started Application launched by gnome-session-binary.
systemd[1779]: app-glib-liveinst\x2dsetup-1897.scope: Failed to add PIDs to scope's control group: No such process
systemd[1779]: app-glib-liveinst\x2dsetup-1897.scope: Failed with result 'resources'.
systemd[1779]: Failed to start Application launched by gnome-session-binary.
systemd[1779]: app-glib-xdg\x2duser\x2ddirs-1900.scope: Failed to add PIDs to scope's control group: No such process
systemd[1779]: app-glib-xdg\x2duser\x2ddirs-1900.scope: Failed with result 'resources'.
systemd[1779]: Failed to start Application launched by gnome-session-binary.
systemd[1779]: app-gnome-gsettings\x2ddata\x2dconvert-1902.scope: Failed to add PIDs to scope's control group: No such process
systemd[1779]: app-gnome-gsettings\x2ddata\x2dconvert-1902.scope: Failed with result 'resources'.
systemd[1779]: Failed to start Application launched by gnome-session-binary.

Since we don't show the PID anywhere, it can be quite hard to figure out what
is going on. There may be logs from the pid above or below in the log, but
we have no PID number to identify them. So let's upgrade the log from
unit_attach_pids_to_cgroup() to tell us precisely which PIDs and why couldn't
be handled.
2021-06-30 21:55:16 +02:00
Dan Streetman
147bc3639b time: get timezones from tzdata.zi
The zone1970.tab file doesn't include any timezone 'aliases'. Instead
of parsing it, parse the tzdata.zi file which does include all zones
as well as aliases.

This keeps the parsing function for zone1970.tab as a fallback in case
the tzdata.zi file isn't found.
2021-06-30 13:42:58 -04:00
Dan Streetman
09a54a862b time: split get_timezone() into main function and zone1970.tab function
This allows for adding another function to read from a different timezone
source, which is added in the next commit.
2021-06-30 13:42:58 -04:00
Dan Streetman
31097e2b99 time: simplify get_timezones()
The function can be simplified by using extract_many_words() and strv_extend()
2021-06-30 13:42:58 -04:00
Yu Watanabe
4492443124 test-network: update tests for ipv4acd 2021-07-01 00:49:03 +09:00
Yu Watanabe
d7ab6ef098 network: introduce callback fucntions to check the sender MAC address for IPv4ACD and IPv4LL
Fixes #12145.
2021-07-01 00:49:03 +09:00
Yu Watanabe
76a86ffdbe network: ipv4acd: first probe address and then assign it
Previously, if IPv4 ACD is enabled on an address, then we first
assign the address, and start sd-ipv4acd daemon for the address.
This is not only RFC incompliant, but also the address is always
dropped, as the daemon always considers the address is conflicted.

This commit makes networkd first starts sd-ipv4acd daemon to probe
the address, and then the address is configured if no conflict is
detected.

Fixes #17235.
2021-07-01 00:49:03 +09:00
Yu Watanabe
475ec3346f network: make request_drop() accept NULL 2021-07-01 00:49:03 +09:00
Yu Watanabe
c0c04a4b22 network: acquire address on request configure rather than on configure
A preparation for later commits.
2021-07-01 00:49:03 +09:00
Yu Watanabe
9155da08ee network: rename dhcp_lease_lost() -> dhcp4_lease_lost() and expose it
A preparation for later commits.
2021-07-01 00:49:02 +09:00
Yu Watanabe
d5e3b3eb8c network: address: do not send tentative flag
Currently, networkd does not set tentative flag on create, and kernel
ignore the flag on remove. So, this commit does not change any current
behaviour. This is just a preparation for later commits.
2021-07-01 00:49:02 +09:00
Yu Watanabe
8c29f484d5 network: introduce link_request_static_address() 2021-07-01 00:49:02 +09:00
Yu Watanabe
99b466693e network: introduce address_dup() and replace address_copy() with it 2021-07-01 00:49:02 +09:00
Yu Watanabe
f8d6397ac2 network: ipv4ll: reset MAC address without stopping sd-ipv4ll engine 2021-07-01 00:49:02 +09:00
Yu Watanabe
a1e35fca46 network: ipv4ll: refuse to configure IPv4LL address on interface where the length of the hardware address is not ETH_ALEN
Currently, sd-ipv4acd assumes hardware address is ETH_ALEN.
2021-07-01 00:49:02 +09:00
Yu Watanabe
89d8ed9932 network: ipv4ll: make link enter failed state on failure of restarting ipv4ll engine 2021-07-01 00:49:02 +09:00
Yu Watanabe
fe321d457c network: introduce link_get_by_hw_addr() 2021-07-01 00:49:02 +09:00
Yu Watanabe
6eab614db8 network: rename Manager::links -> Manager::links_by_index
This also renames link_get() -> link_get_by_index().
2021-07-01 00:49:02 +09:00
Yu Watanabe
907d5ce4d4 ether-addr-util: introduce hw_addr_hash_ops 2021-07-01 00:49:02 +09:00
Yu Watanabe
1e59122d45 sd-ipv4ll: introduce sd_ipv4ll_set_check_mac_callback() 2021-07-01 00:49:02 +09:00
Yu Watanabe
9e5aa34fc8 sd-ipv4ll: allow to set MAC address without stopping sd-ipv4ll engine 2021-07-01 00:49:02 +09:00
Yu Watanabe
7f77917c0e sd-ipv4acd: update condition of address conflict
See RFC 5227 section 2.1.1.

This introduces a callback which intend to a library user, e.g.
networkd, checks whether the sender hardware address is a MAC address of
the host's intrerface or not.
2021-07-01 00:49:02 +09:00
Yu Watanabe
5c35c13a4d sd-ipv4acd: allow to change requesting address without restarting sd-ipv4acd 2021-07-01 00:49:02 +09:00
Yu Watanabe
3d817902c4 sd-ipv4acd: set defend window in timeout event and state is IPV4ACD_STATE_STARTED 2021-07-01 00:49:02 +09:00
Yu Watanabe
fcb7345950 sd-ipv4acd: allow to change MAC address without restarting sd-ipv4acd
This also makes sd_ipv4acd_set_mac() refuses null MAC address.
2021-07-01 00:49:02 +09:00
Yu Watanabe
d17ed573aa arp-util: split out logic of setting BPF code into a function 2021-07-01 00:49:02 +09:00
Yu Watanabe
ecad63f850 arp-util: use struct in_addr 2021-07-01 00:49:02 +09:00
Yu Watanabe
e1a3915b41 arp-util: make arp_send_{probe,announcement}() inline 2021-07-01 00:49:02 +09:00
Yu Watanabe
28ba416c99 arp-util: shorten code a bit 2021-07-01 00:49:02 +09:00
Yu Watanabe
504bf2b54a arp-util: check ifindex and mac address 2021-07-01 00:49:02 +09:00
Yu Watanabe
f6720fe62e arp-util: check sent message size 2021-07-01 00:49:02 +09:00
Yu Watanabe
51d113512f arp-util: align elements 2021-07-01 00:49:02 +09:00
Yu Watanabe
265b6d4e0c sd-ipv4acd: include announced address in log message 2021-07-01 00:49:02 +09:00
Yu Watanabe
9be2ba5e12 sd-ipv4acd: use struct in_addr instead of be32_t 2021-07-01 00:49:02 +09:00
Zbigniew Jędrzejewski-Szmek
58551e6ebc
Merge pull request #20074 from yuwata/fix-typo
tree-wide: fix typo
2021-06-30 17:26:51 +02:00
Zbigniew Jędrzejewski-Szmek
e8616626eb core/cgroup: inline more iterator variable declarations 2021-06-30 17:22:23 +02:00
Zbigniew Jędrzejewski-Szmek
58441bc177 core: emit nicer log message for exiting ConditionExec processes
See https://bugzilla.redhat.com/show_bug.cgi?id=1973058:

we would log something like:
systemd[244]: Starting willskip.service...
systemd[244]: willskip.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
systemd[244]: willskip.service: Skipped due to 'exec-condition'.
systemd[244]: Condition check resulted in willskip.service being skipped.

The line with 'Control process exited' would be at LOG_NOTICE level.

With the patch:
systemd[244]: Starting willskip.service...
systemd[244]: willskip.service: Skipped due to 'exec-condition'.
systemd[244]: Condition check resulted in willskip.service being skipped.

Debug logs:
systemd[244]: Starting willskip.service...
systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/willskip_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=8 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/willskip_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/job/46 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
systemd[11020]: Skipping PR_SET_MM, as we don't have privileges.
systemd[11020]: willskip.service: Executing: sh -c 'exit 2'
systemd[244]: Received SIGCHLD from PID 11020 (sh).
systemd[244]: Child 11020 (sh) died (code=exited, status=2/INVALIDARGUMENT)
systemd[244]: willskip.service: Child 11020 belongs to willskip.service.
systemd[244]: willskip.service: Condition check process exited, code=exited, status=2/INVALIDARGUMENT (success)
systemd[244]: willskip.service: Got final SIGCHLD for state condition.
systemd[244]: willskip.service: Skipped due to 'exec-condition'.
systemd[244]: willskip.service: Service will not restart (restart setting)
systemd[244]: willskip.service: Changed condition -> dead
systemd[244]: willskip.service: Job 46 willskip.service/start finished, result=done
systemd[244]: Condition check resulted in willskip.service being skipped.
2021-06-30 17:22:23 +02:00