Commit graph

42365 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 124e05b3b6 core: move bpf devices implementation to bpf-devices.[ch] and rename
The naming of the functions was a complete mess: the most specific functions
which don't know anything about cgroups had "cgroup_" prefix, while more
general functions which took a node path and a cgroup for reporting had no
prefix. Let's use "bpf_devices_" for the latter group, and "bpf_prog_*" for the
rest.

The main goal of this move is to split the implementation from the calling code
and add unit tests in a later patch.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek 084870f9c0 core: rename CGROUP_AUTO/STRICT/CLOSED to CGROUP_DEVICE_POLICY_…
The old names were very generic, and when used without context it wasn't at all
clear that they are about the devices policy.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek 77abd02985 tests: move memlock helper to shared code 2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek ee19c80733 test-bpf-firewall: do not mlock() a large amount of memory
64MB is not that much, but let's not be greedy, esp. because we may run
many things in parallel.

Also, rlim_cur should never be higher than rlim_max, so let's simplify our
code.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek d3472f9b50 test-bpf: rename to test-bpf-firewall
Let's make the name better reflect its scope.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek 672cbcbc20 bpf: return normally from whitelist_major()
All callers do (void) anyway, so we can just use normal return here.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek d49c180826 bpf: do not bother adding device patterns after whitelisting the full class
This seems to have been unintentional.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek fa6613fc53 bpf: refactor how we create device major:minor whitelists
No functional change intended except for minor adjustments to error messages.
2019-11-10 23:22:15 +01:00
Zbigniew Jędrzejewski-Szmek 2899aac46a core: constify bpf program arrays
In cases where the programs were modified after being initially declared,
reorder operations so that the declaration is already in final form.
2019-11-10 23:22:14 +01:00
Vito Caputo a602d93e44 journal-file: delete some unnecessary braces
Trivial change, just something I noticed skimming the code.
2019-11-10 12:39:44 +01:00
Yu Watanabe e64664cefe
Merge pull request #13975 from keszybz/more-seccomp-syscalls
Add more syscalls to the seccomp lists
2019-11-09 23:27:34 +09:00
Zbigniew Jędrzejewski-Szmek 5021735fad shared/sleep-config: fix potential SEGV
We were looking at the wrong variable, and would always crash if this
comparison was reached. Fixes #13965.

Also, fix crash (_cleanup_ called on uninitialized variable) if we failed in
error path.

While at it, let's shorten some messages.
2019-11-09 09:19:36 +00:00
Zach Smith 4b55952dbe systemd-tmpfiles: cleanup man page program listing 2019-11-08 20:29:36 -08:00
Zbigniew Jędrzejewski-Szmek 9493b16871 Add @pkey syscall group
Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=1769299.
This change doesn't solve the issue, but makes it easier to whitelist the
syscall group.
2019-11-08 14:41:22 +01:00
Zbigniew Jędrzejewski-Szmek 6ca6771069 seccomp: add all *time64 syscalls
From https://bugzilla.redhat.com/show_bug.cgi?id=1770154:
> utime is an obsolete system call. The current kernel interface is
> utimensat_time64. New 32-bit architectures do not even provide the utime
> system call.

Also add all other *time64 syscalls listed in
https://fedora.juszkiewicz.com.pl/syscalls.html.
2019-11-08 14:40:49 +01:00
Zbigniew Jędrzejewski-Szmek 7fd7dab90f
Merge pull request #13554 from keur/systemctl_status_timer
systemctl: Add timer activation to status
2019-11-08 14:19:40 +01:00
Michal Suchanek 581e2d96fc libblkid: open device in nonblock mode.
When autoclose is set (kernel default but many distributions reverse the
setting) opening a CD-rom device causes the tray to close.

The function of blkid is to report the current state of the device and
not to change it. Hence it should use O_NONBLOCK when opening the
device to avoid closing a CD-rom tray.

blkid is used liberally in scripts so it can potentially interfere with
the user operating the CD-rom hardware.

[kzak@redhat.com: add O_NONBLOCK also to:
                  - wipefs
                  - blkid_new_probe_from_filename()
                  - blkid_evaluate_tag()]

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 39f5af25982d8b0244000e92a9d0e0e6557d0e17)
2019-11-08 12:11:32 +01:00
Zbigniew Jędrzejewski-Szmek d5c30300da
Merge pull request #13962 from keszybz/man-ordering
Describe ordering in case of Conflicts=
2019-11-08 10:18:46 +01:00
Zbigniew Jędrzejewski-Szmek 38c432b37c man: describe ordering in case of Conflicts=
Fixes #13421.
2019-11-08 10:17:27 +01:00
Alcaro 72a68f9d6d doc: Fix missing parenthesis 2019-11-07 15:35:41 +01:00
Anita Zhang 0499585ffe include missing_fcntl.h where needed
f5947a5e92 dropped missing.h and
replaced with the more specific headers but did not add
missing_fcntl.h in places that use O_TMPFILE. This is needed for
some older versions of glibc.
2019-11-07 10:17:44 +00:00
Zbigniew Jędrzejewski-Szmek 754499fab2
Merge pull request #13904 from keur/job_mode_triggering
Job mode triggering
2019-11-07 08:36:26 +01:00
Anita Zhang 3e1db806b0 core: change top-level drop-in from -.service.d to service.d
Discussed in #13743, the -.service semantic conflicts with the
existing root mount and slice names, making this feature not
uniformly extensible to all types. Change the name to be
<type>.d instead.

Updating to this format also extends the top-level dropin to
unit types.
2019-11-07 08:34:53 +01:00
Zbigniew Jędrzejewski-Szmek d19cd71a8a man: put description of Wants= above Requires=
We want users to use Wants, but we'd describe Requires first and ask users to
look for Wants instead. While at it, let's split the wall of text into sensible
paragraphs: syntax first, followed by semantics and longer description, and
finally hints and comparison to other configuration items last.
2019-11-06 22:39:03 +01:00
Anita Zhang 8069017a0f
Merge pull request #13960 from keszybz/meson-loop-fix
meson: remove strange dep that causes meson to enter infinite loop
2019-11-06 11:44:09 -08:00
Dominique Martinet 98647fa0fa man: fix option typo in pam_systemd man page
The session= option does not exist, XDG_SESSION_TYPE overrides the type=
option.
2019-11-06 21:02:55 +09:00
Zbigniew Jędrzejewski-Szmek af336643a0 meson: remove strange dep that causes meson to enter infinite loop
The value is obviously bogus, but didn't seem to cause problems so far.
With meson-0.52.0, it causes a hang. The number of aliases is always rather
small (usually just one or two, possibly up to a dozen in a few cases), so
even if this causes some looping, it is strange that it has such a huge impact.
But let's just remove it.

Fixes #13742.

Tested with meson-0.52.0-1.module_f31+6771+f5d842eb.noarch,
meson-0.51.1-1.fc29.noarch.
2019-11-06 12:47:03 +01:00
Anita Zhang b12a67ae14 man: save pull-raw example file without underscores
Destination file needs to be a valid hostname and underscores
are not valid hostname characters.

Closes #13542
2019-11-06 10:45:03 +09:00
Anita Zhang 7792d9cdd4 man: small grammatical/word choice fixes to crypttab man page
Closes #13608
2019-11-06 10:38:53 +09:00
Anita Zhang f03378805f
Merge pull request #13936 from keszybz/format-table-uninhibited
Output tables at full width if piped
2019-11-05 15:03:15 -08:00
Anita Zhang 9087384d39
Merge pull request #13944 from yuwata/network-split-struct-prefix
network: split struct Prefix into Prefix and RoutePrefix
2019-11-05 15:02:01 -08:00
Yu Watanabe 3126d64e5f sd-device-enumerator: do not return error when a device is removed
Fixes #13814.
2019-11-05 22:13:11 +01:00
Zbigniew Jędrzejewski-Szmek bc9aa96bbd systemctl: simplify printing of Triggers/TriggeredBy 2019-11-05 22:01:46 +01:00
Kevin Kuehler 0d588deae2 systemctl: Align all status outputs to TriggeredBy 2019-11-05 21:51:31 +01:00
Kevin Kuehler 965c5d1d5a systemctl: Add TriggeredBy and Triggers to status
For all units that aren't timers, if it is activated by another unit,
add the triggering unit under the  "TriggeredBy:" header. If a unit can
trigger other units, print the units it triggers other the "Triggers:"
header.
2019-11-05 21:51:31 +01:00
Zbigniew Jędrzejewski-Szmek 7f3614e547 run: propagate return code/status from the child
Fixes #13756. We were returning things that didn't make much sense:
we would always use the exit_code value as the exit code. But it sometimes
contains a exit code from the process, and sometimes the number of a signal
that was used to kill the process. We would also ignore SuccessExitStatus=
and in general whether systemd thinks the service exited successfully
(hence the issue in #13756, where systemd would return success/SIGTERM,
but we'd just look at the SIGTERM part.)

If we are doing --wait, let's always propagate the exit code/status from
the child.

While at it, make the documentation useful.
2019-11-05 21:38:21 +01:00
Kevin Kuehler 132e0b532c man: Document --job-mode=triggering switch 2019-11-05 11:17:56 -08:00
Kevin Kuehler 1f0f9f21c1 core: Add triggering job mode
When used with systemctl stop, follows TRIGGERED_BY dependencies and
adds them to the same transaction.

Fixes: #3043
2019-11-05 11:17:38 -08:00
Zbigniew Jędrzejewski-Szmek 0db41a8f1f shared/format-table: disable ellipsization when piped
Fixes #13461.

Before:
$ systemd-inhibit --no-pager
WHO            UID  USER    PID   COMM           WHAT                                  WHY          MODE
ModemManager   0    root    1093  ModemManager   sleep                                 ModemManage… delay
NetworkManager 0    root    1400  NetworkManager sleep                                 NetworkMana… delay
UPower         0    root    5141  upowerd        sleep                                 Pause devic… delay
zbyszek        1000 zbyszek 10036 gsd-power      handle-lid-switch                     External mo… block
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:… GNOME handl… block
zbyszek        1000 zbyszek 10035 gsd-media-keys sleep                                 GNOME handl… delay
zbyszek        1000 zbyszek 10036 gsd-power      sleep                                 GNOME needs… delay

7 inhibitors listed.
$ systemd-inhibit --no-pager|grep suspend
$ systemd-inhibit --no-pager|cat
WHO            UID  USER    PID   COMM           WHAT                WHY   MODE
ModemManager   0    root    1093  ModemManager   sleep               Mode… delay
NetworkManager 0    root    1400  NetworkManager sleep               Netw… delay
UPower         0    root    5141  upowerd        sleep               Paus… delay
zbyszek        1000 zbyszek 10036 gsd-power      handle-lid-switch   Exte… block
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:h… GNOM… block
zbyszek        1000 zbyszek 10035 gsd-media-keys sleep               GNOM… delay
zbyszek        1000 zbyszek 10036 gsd-power      sleep               GNOM… delay

After:
$ build/systemd-inhibit --no-pager
(same as above)

$ build/systemd-inhibit --no-pager|grep suspend
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block
$ build/systemd-inhibit --no-pager|cat
WHO            UID  USER    PID   COMM           WHAT                                                     WHY                                                         MODE
ModemManager   0    root    1093  ModemManager   sleep                                                    ModemManager needs to reset devices                         delay
NetworkManager 0    root    1400  NetworkManager sleep                                                    NetworkManager needs to turn off networks                   delay
UPower         0    root    5141  upowerd        sleep                                                    Pause device polling                                        delay
zbyszek        1000 zbyszek 10036 gsd-power      handle-lid-switch                                        External monitor attached or configuration changed recently block
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block
zbyszek        1000 zbyszek 10035 gsd-media-keys sleep                                                    GNOME handling keypresses                                   delay
zbyszek        1000 zbyszek 10036 gsd-power      sleep                                                    GNOME needs to lock the screen                              delay

7 inhibitors listed.

Note that this affect all tools that use format-table.c: machinectl, busctl,
loginctl, systemd-analyze, networkctl, portablectl.
2019-11-05 17:50:09 +01:00
Yu Watanabe 95081e08d7 network: split struct Prefix into Prefix and RoutePrefix 2019-11-05 22:31:20 +09:00
Yu Watanabe c631c3d6a3
Merge pull request #13939 from yuwata/network-fix-memleak-and-13938
network: fix memleak and invalid free function
2019-11-05 20:16:06 +09:00
Lorenz Bauer 09d0b46ab6 journal: refresh cached credentials of stdout streams
journald assumes that getsockopt(SO_PEERCRED) correctly identifies the
process on the remote end of the socket. However, this is incorrect
according to man 7 socket:

    The returned  credentials  are  those that were in effect at the
    time of the call to connect(2) or socketpair(2).

This becomes a problem when a new process inherits the stdout stream
from a parent. First, log messages from the child process will
be attributed to the parent. Second, the struct ucred used by journald
becomes invalid as soon as the parent exits. Further sendmsg calls then
fail with ENOENT. Logs for the child process then vanish from the journal.

Fix this by using recvmsg on the stdout stream, and refreshing the cached
struct ucred if SCM_CREDENTIALS indicate a new process.

Fixes #13708
2019-11-05 10:41:03 +01:00
Sebastian Wick d7d31692bf hwdb: add XKB_FIXED_MODEL to the keyboard hwdb
Chromebook keyboards have a top row which generates f1-f10 key codes but
the keys have media symbols printed on them. A simple scan code to key
code mapping to the correct media keys makes the f1-f10 inaccessible. To
properly use the keyboard a custom key code to symbol mapping in xbk is
required (a variant of the chromebook xkb model is already upstream).
Other devices have similar problems.
This commit makes it possible to specify which xkb model should be used
for a specific device by setting XKB_FIXED_MODEL.
2019-11-05 10:08:26 +01:00
Anita Zhang d36b573ef7
Merge pull request #13935 from poettering/bootctl-random-seed-mkdir
bootctl: create leading dirs when "bootctl random-seed" is called if …
2019-11-04 22:57:12 -08:00
Yu Watanabe 69d7eba188 sd-radv: fix memleak 2019-11-05 13:30:00 +09:00
Yu Watanabe c1ed516cde test: add testcase for issue #13938 2019-11-05 10:49:07 +09:00
Yu Watanabe 471e126b25 network: fix memleak in route_prefix_free() 2019-11-05 10:48:15 +09:00
Yu Watanabe 095b3a7d90 network: fix typo 2019-11-05 10:43:43 +09:00
Yu Watanabe e7825b2359 network: fix invalid cleanup function 2019-11-05 10:39:15 +09:00
Yu Watanabe 9be6ae775f network: fix memleak 2019-11-05 09:41:03 +09:00