1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00
Commit Graph

53000 Commits

Author SHA1 Message Date
Luca Boccassi
3f1487f5a0 analyze: ignore dependencies with security --offline
We don't care about validating dependencies here, the security verb is
only checking the unit(s) under test.
2021-09-08 19:46:57 +01:00
Michal Sekletar
9f6ef46781 sd-event: take ref on event loop object before dispatching event sources
Idea is that all public APIs should take reference on objects that get
exposed to user-provided callbacks. We take the reference as a
protection from callbacks dropping it. We used to do this also here in
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
accidentally dropped.
2021-09-09 01:15:57 +09:00
xujing
1509274359 core: fix free undefined pointer when strdup failed in the first loop 2021-09-08 22:42:22 +09:00
Frantisek Sumsal
39e1753673 test: rename dracut_install to image_install
The `dracut_install` is a misnomer, since the systemd integration test
suite is based on the original dracut's test suite, and not all the
references to dracut has been edited out. Let's fix that.
2021-09-08 22:41:20 +09:00
pedro martelletto
b6aa89b0a3 explicitly close FIDO2 devices
FIDO2 device access is serialised by libfido2 using flock().
Therefore, make sure to close a FIDO2 device once we are done
with it, or we risk opening it again at a later point and
deadlocking. Fixes #20664.
2021-09-08 13:42:07 +01:00
Luca Boccassi
afd4814651
Merge pull request #20667 from keszybz/portable-docs
Tweaks to documentation about portable services
2021-09-08 13:41:44 +01:00
Zbigniew Jędrzejewski-Szmek
8c7e2b48c5 docs: polish the text about Portable Services a bit
No semantic changes, just removal of repetitions and unnecessary words, and
some more formatting.
2021-09-08 12:59:08 +02:00
Zbigniew Jędrzejewski-Szmek
a00ff6717b docs: portablectl is in bin/
Follow-up for 80f39b81f3.
2021-09-08 11:37:56 +02:00
Luca Boccassi
7728f6aa81 test: rename TEST-63-ANALYZE to solve conflict
Two PRs adding TEST-63-* were merged more or less at the
same time, and we missed the conflict.
2021-09-08 10:12:03 +09:00
Frantisek Sumsal
f2204ac27d test: udev storage tests 2021-09-08 04:31:24 +09:00
Yu Watanabe
771a36439e network: fix wrong flag: manage_foreign_routes -> manage_foreign_rules
Fixes a bug in d94dfe7053.
2021-09-07 20:00:18 +01:00
Lennart Poettering
dd4c15296c
Merge pull request #20618 from yuwata/path-find-component
use path_find_{first,last}_component() at more several places
2021-09-07 10:02:44 +02:00
Yu Watanabe
af7c37a486 test: do not try to remove /dev 2021-09-07 14:08:21 +09:00
Yu Watanabe
4e046c5c2f fs-util: rewrite rmdir_parents() with path_find_last_component() 2021-09-07 14:08:21 +09:00
Yu Watanabe
3008a6f21c mkdir: rewrite mkdir_parents() with path_find_{first,last}_component() 2021-09-07 14:08:18 +09:00
Lennart Poettering
7d50cd65bb
Merge pull request #20465 from bluca/portable_validate_sysext
portabled: validate SYSEXT_LEVEL when attaching
2021-09-06 21:10:15 +02:00
Lennart Poettering
f0a8ec4372
Merge pull request #20527 from systemd/wip/hadess/usb-analysers-uaccess
hwdb: Allow end-users root-less access to USB analysers
2021-09-06 21:06:40 +02:00
Maanya Goenka
4b4a8ef741 systemd-analyze: add new option to generate JSON output of security analysis table
The new option --json= works with the 'security' verb and takes in one of three format flags.
These are off which is the default, pretty and short which use JSON format flags for output.
When set to true, it generates a JSON formatted output of the security analysis table. The
format is a JSON array with objects containing the following fields: set which indicates if
the id has been set or not, name which is what is used to refer to the id, json_field
which is the equivalent JSON formatted id name only used for JSON outputs, description which
is an outline of the id state, and exposure which is an unsigned integer in the range 0.0..10.0,
where a higher value corresponds to a higher security threat. The JSON version of the table is
printed on the standard output file.

Example Run:

The unit file testfile.service was created to test the --json= option

maanya-goenka@debian:~/systemd (json-security)$ cat <<EOF >testfile.service

> [Service]
> ExecStart = echo hello
> PrivateNetwork = yes
> PrivateMounts = yes
> PrivateDevices = yes
> EOF

Both the JSON output and the security analysis table below have been truncated to increase readability.
1. Testing for when --json=off

maanya-goenka@debian:~/systemd (json-security)$ sudo build/systemd-analyze security --json=off --root= --offline=true
testfile.service --no-pager

/usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
Support for KillMode=none is deprecated and will eventually be removed.
/usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
/var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
/usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
unit file, and consider removing the setting altogether.
/home/maanya-goenka/systemd/foo.service:2: Unknown key name 'foo' in section 'Unit', ignoring.

    NAME                                                      DESCRIPTION                                                       EXPOSURE
✓   PrivateNetwork=                                           Service has no access to the host's network
✗   User=/DynamicUser=                                        Service runs as root user                                              0.4
✗   CapabilityBoundingSet=~CAP_SET(UID|GID|PCAP)              Service may change UID/GID identities/capabilities                     0.3
✗   CapabilityBoundingSet=~CAP_NET_ADMIN                      Service has administrator privileges                                   0.3

→ Overall exposure level for testfile.service: 8.3 EXPOSED 🙁

2. Testing for when --json=pretty

maanya-goenka@debian:~/systemd (json-security)$ sudo build/systemd-analyze security --json=pretty --root= --offline=true
testfile.service

/usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
Support for KillMode=none is deprecated and will eventually be removed.
/usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
/var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
/usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
unit file, and consider removing the setting altogether.
/home/maanya-goenka/systemd/foo.service:2: Unknown key name 'foo' in section 'Unit', ignoring.

[
        {
                "set" : true,
                "name" : "PrivateNetwork=",
		"json-field" : "PrivateNetwork",
                "description" : "Service has no access to the host's network",
                "exposure" : null
        },
        {
                "set" : false,
                "name" : "User=/DynamicUser=",
		"json-field" : "UserOrDynamicUser",
                "decsription" : "Service runs as root user",
                "exposure" : "0.4"
        },
        {
                "set" : false,
                "name" : "CapabilityBoundingSet=~CAP_SET(UID|GID|PCAP)",
		"json_field" : "CapabilityBoundingSet_CAP_SET_UID_GID_PCAP",
                "description" : "Service may change UID/GID identities/capabilities",
                "exposure" : "0.3"
        },
        {
                "set" : false,
                "name" : "CapabilityBoundingSet=~CAP_NET_ADMIN",
		"json_field" : "CapabilityBoundingSet_CAP_NET_ADMIN",
                "description" : "Service has administrator privileges",
                "exposure" : "0.3"
        },
        ...
]

3. Testing for when --json=short

maanya-goenka@debian:~/systemd (json-security)$ sudo build/systemd-analyze security --json=short --root= --offline=true
testfile.service

/usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
Support for KillMode=none is deprecated and will eventually be removed.
/usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
/var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
/usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
unit file, and consider removing the setting altogether.
/home/maanya-goenka/systemd/foo.service:2: Unknown key name 'foo' in section 'Unit', ignoring.

[{"set":true,"name":"PrivateNetwork=", "json_field":"PrivateNetwork", "description":"Service has no access to the host's network","exposure":null}, ...]
2021-09-06 19:55:27 +01:00
Kyle Laker
c1e6f21556
systemd-analyze: use config value in RestrictNamespaces id (#20645)
For most fields, the text shown by `.id` is the value that should be set
in the unit file; however, for RestrictNamespaces, it is not. Changing
this to show the actual text makes it more clear to a user what the
actual change that needs to be made to the unit file is.
2021-09-06 17:33:16 +02:00
Ross Jennings
f77e015a88
Fix volume control keys for LG Gram (#20644)
Fix volume control keys for LG Gram
2021-09-06 16:55:11 +02:00
Luca Boccassi
9ff61565be portabled: refactor extraction/validation into a common helper 2021-09-06 13:20:01 +01:00
Luca Boccassi
239ac0c7f7 portabled: validate SYSEXT_LEVEL when attaching
When attaching a portable service with extensions, immediately validate
that the os-release and extension-release metadata values match, rather
than letting it fail when the units are started
2021-09-06 12:14:50 +01:00
Luca Boccassi
7bf5ec4538 portabled: error out if there are no units only after parsing all images
It's ok if the OS image doesn't have matching units, if we find them
in the extensions. Tidies up the parsing logic a bit.
2021-09-06 12:13:53 +01:00
Luca Boccassi
9ccb531a5f dissect-image: add extension-specific validation flag
Allows callers to specify which image type they are looking for
2021-09-06 12:13:53 +01:00
lainahai
77afbef692 Fix esc, volume control keys and Fn+F1 for Samsung Galaxy Book 2021-09-05 20:02:35 +02:00
saikat0511
21b589a155 Fix volume control keys for Lenovo Ideapad Flex 5
Fixes the keys not creating release events
2021-09-05 18:19:24 +02:00
Yu Watanabe
fe2f05b72e tmpfiles: minor modernization 2021-09-05 10:07:04 +02:00
Yu Watanabe
6a09dbb895 home: 'secret' argument of handle_generic_user_record_error may be null
When RefHome() bus method is called in acquire_home(), secret is NULL.

Fixes #20639.
2021-09-05 10:05:41 +02:00
Yu Watanabe
05403363ca tree-wide: fix typo 2021-09-05 09:09:13 +02:00
Luca Boccassi
5bf20f3a0d
Merge pull request #20626 from yuwata/network-keep-master
network: introduce KeepMaster= setting
2021-09-04 15:08:56 +01:00
Dan Streetman
c29537f39e meson.build: change operator combining bools from + to and
upstream meson stopped allowing combining boolean with the plus
operator, and now requires using the logical and operator

reference:
43302d3296

Fixes: #20632
2021-09-04 09:09:32 +09:00
Yu Watanabe
e643c3d82d network: add 80-container-vb.network 2021-09-04 08:15:34 +09:00
Yu Watanabe
b06469a66c test-network: add tests for KeepMaster= 2021-09-04 08:15:30 +09:00
Zbigniew Jędrzejewski-Szmek
2c1591b91e
Merge pull request #20629 from keszybz/mkosi-host-distro-by-default
mkosi: build for the host distro by default
2021-09-03 17:46:35 +02:00
Yu Watanabe
57aef9d737 network: introduce KeepMaster= setting
Closes #20624.
2021-09-04 00:23:20 +09:00
Yu Watanabe
1f024462d1 network: assume enslaved when master ifindex is positive 2021-09-04 00:20:36 +09:00
Yu Watanabe
571bf1aa31 network: use master ifindex to check if the interface is enslaved 2021-09-04 00:20:36 +09:00
Yu Watanabe
a94ed9bd62 man: drop unnecessary white space 2021-09-04 00:20:36 +09:00
Lennart Poettering
b03803f0dc format-table: allow to explicitly override JSON field names
In some cases it's useful to explicitly generate the JSON field names to
generate for table columns, instead of auto-mangling them from table
header names that are intended for human consumption.

This adds the infra and a test for it.

It's intended to be used by #20544, for the first column, which in text
mode should have an empty header field, but have an explicit name in
json output mode.
2021-09-03 14:37:26 +01:00
Zbigniew Jędrzejewski-Szmek
d55ad7fe96 mkosi: move distro files to mkosi.default.d/
With this change, "mkosi build" will automatically build systemd for the
current distro without any further configuration. If people want to do a
cross-distro build by default, they can still create mkosi.default, but I
assume that this is relatively rare.

If people have symlinked mkosi.default to one of the files in .mkosi/, they'll
need to adjust the symlink.

(Building without configuration would always fail, since systemd has many many
required dependencies. I think it's nicer to do the most commonly expected
thing by default, i.e. rebuild for the current distro.)

Mkosi is nowadays packaged for most distros, so recommend installing of distro
packages as the primary installation mechanism.
2021-09-03 13:18:38 +02:00
Zbigniew Jędrzejewski-Szmek
6ad92aaf90 gitignore: only ignore *local*.conf" under mkosi.default.d/
The pattern was added in 6242cda99d, with the
idea that users will have local configuration files for mkosi and git should
not bother them about those. But let's make this narrower, and only match
files with "local". This way we reduce the risk that some unrelated file
will be ignored by accident.

.gitignore in the parent directory is used, because mkosi apparently tries
to load all files under mkosi.default.d/, without looking at the extension.
This is probably something to fix in mkosi too.
2021-09-03 13:15:52 +02:00
Jan Janssen
0d5765f7af journalctl: Use constants in some more places 2021-09-03 09:58:07 +02:00
Zbigniew Jędrzejewski-Szmek
068d133881 mkosi: make mkosi.build shellcheck-clean
Also remove the space after redirection operators. (Some redirections
were with, some without, and I think it's nicer without.)
2021-09-03 09:54:43 +02:00
Zbigniew Jędrzejewski-Szmek
fc5f5c2a3c mkosi: drop the code to determine nobody user name
The comments were outdated: at least "nfsnobody" is not used in Fedora since a
few years. So I hope we don't need this anymore. The meson build scripts do
autodetection on their own.
2021-09-03 09:54:42 +02:00
Yu Watanabe
b2cdc2c05e
Merge pull request #20603 from yuwata/udev-node-cleanups
udev: cleanups for creating/removing device node symlinks
2021-09-03 05:33:06 +09:00
Bastien Nocera
9e2dbfef47 hwdb: Allow end-users root-less access to USB analyzers
Procotol analyzers are external devices used to capture traffic over a
wire so that it could be analysed. End-users at the console should be
able to access those devices without requiring root access.

This change obsoletes the need to install Total Phase's "Linux drivers",
which are really just udev rules and hotplug usermap files to do that:
https://www.totalphase.com/products/usb-drivers-linux/
2021-09-02 16:01:28 +02:00
Vito Caputo
a4121e965f sd-journal: use FILE streams to buffer write_uint64()
journal_file_verify() uses a set of tmpfs files to create lists
of object positions by type.

The existing code used a bare write() call for every object
position written, incurring a syscall per listed object.

This commit encapsulates the bare file descriptors in FILE *'s
and replaces the bare write with fwrite, buffering the writes so
there's less syscalls.

Cached `journalctl --verify` tests showed a ~8% faster runtime
with this change on a release build, verifying 1.3GiB of
production journals across 16 files.
2021-09-02 11:29:23 +02:00
Yu Watanabe
fad45198b6 xattr-util: drop unused path_getcrtime() 2021-09-01 21:36:36 -07:00
Yu Watanabe
b57947114e fs-util: use futimens_opath() helper function 2021-09-01 21:36:36 -07:00
Yu Watanabe
b71dbc6b56 fs-util: drop unnecessary initialization 2021-09-01 21:36:36 -07:00