Commit Graph

47024 Commits

Author SHA1 Message Date
Lennart Poettering
6db53d20f5 nspawn: lock down access to notify socket a bit
On Linux only the "w" access bit is necessary to connect to an AF_UNIX
socket, hence let's only set that and nothing else, to limit exposure.

Just paranoia.
2024-01-06 11:21:00 +09:00
Frantisek Sumsal
d7942fe5fc core: escape spaces in paths during serialization
Otherwise we split them incorrectly when deserializing them.

Resolves: #30747
2024-01-06 11:19:59 +09:00
Yu Watanabe
b82b4d258e Merge pull request #30794 from poettering/parse-vsock-better
socket-util: add more careful parsers for AF_VSOCK cid/port
2024-01-06 11:16:19 +09:00
Yu Watanabe
7ba3e44651 udevadm: allow to override the default log level by environment variable
Previously, there was no way to override the log level for test and
test-builtin commands. Let's re-parse environment after setting the log
level to debug. Then, we can control the log level through environment
variable.
2024-01-06 08:30:58 +09:00
Yu Watanabe
976309db6a Merge pull request #30796 from mrc0mmand/journalctl-namespaces
journalctl: provide shell completion for --namespace=
2024-01-06 08:30:31 +09:00
Lennart Poettering
a6a7983dbf dev-setup: rework make_inaccessible_nodes() around openat() and friends
Let's operate on fds rather than paths. Make some tweaks to the logic on
top:

1. Mark the resulting dir as read-only after we are done.
2. Use the new inode_type_to_string() calls to determine the inode
   names.
3. If an inode already exists, try to adjust the access mode, just in
   case.
4. Use FOREACH_ARRAY()
2024-01-06 08:27:51 +09:00
Yu Watanabe
0d1706b5fa Merge pull request #30775 from yuwata/network-nexthop-is-ready
network: introduce nexthop_is_ready() helper function and use it
2024-01-06 08:27:35 +09:00
networkException
dcfac3a3f9 parse-helpers: allow port 0 for socket bind items
This patch adds a new parameter to parse_ip_port_range, giving callers
the option to allow ranges to have their min be 0 instead of 1.

This is then used by parse_ip_ports_token, intern used by
parse_socket_bind_item to allow port 0 when restricting bind system
calls with SocketBindDeny / SocketBindAllow.

With this, users running server software written using the golang
standard library will be able to effectively sandbox their software,
albeit with a small loss in security protections by allowing the
process to bind on a random port in the
/proc/sys/net/ipv4/ip_local_port_range.
2024-01-06 08:27:14 +09:00
Lennart Poettering
9807ee19b0 Merge pull request #30791 from poettering/nspawn-restrict-run-host
nspawn: make some files we expose in /run/host/ in nspawn read-only via access mode
2024-01-05 22:37:29 +01:00
Lennart Poettering
32fa24582c nspawn: add new common make_run_host() helper
This new helper creates the /run/host/ top-level dir inside the
container.
2024-01-05 22:34:47 +01:00
Lennart Poettering
8e471c6a9f socket-util: add more careful parsers for AF_VSOCK cid/port
Let's handle the magic CIDs, and filter out invalid ports.
2024-01-05 22:29:55 +01:00
Lennart Poettering
41dd51f8f5 missing: add a bunch of vsock related defines 2024-01-05 22:29:55 +01:00
Frantisek Sumsal
68f66a1713 journalctl: implement --list-namespaces
Apart from being useful on its own, this will be used in the following
commit for shell completions.
2024-01-05 19:21:51 +01:00
Lennart Poettering
05794f5c48 nspawn: set read-only access mode on two /run/host/ files
The diectory is mounted read-only anyway, hence this doesn't do much,
but let's lock this down on every level we can.
2024-01-05 17:31:08 +01:00
Lennart Poettering
2148c669d2 fileio: add new flag WRITE_STRING_FILE_MODE_0444
With this write_string_file() will create the file with 0444 access mode
(i.e. read-only).
2024-01-05 17:30:41 +01:00
Lennart Poettering
3a3315c705 test: add credential encryption/decryption test 2024-01-05 17:20:05 +01:00
Lennart Poettering
9c3d8db990 creds-util: optionally, allow NULL credentials even with TPM 2024-01-05 17:20:05 +01:00
Lennart Poettering
3289aba5a0 Merge pull request #30754 from poettering/iovecification
tpm2-util: convert various things over to struct iovec rather that data ptr + size
2024-01-05 14:45:15 +01:00
Lennart Poettering
53cea64542 Merge pull request #30784 from poettering/json-dispatch-enum
json: add macro for automatically defining a dispatcher for an enum
2024-01-05 14:44:59 +01:00
Lennart Poettering
f0e4244b2f tree-wide: use JSON_ALLOW_EXTENSIONS when disptching at various places
If we want to allow method replies to be extended without this breaking
compat, then we should set this flag. Do so at various method call
replies hence.

Also do it when parsing user/group records, which are expressly
documented to be extensible, as well as the hibernate JSON record.
2024-01-05 12:43:06 +01:00
Lennart Poettering
a617fd9047 json: add new dispatch flag JSON_ALLOW_EXTENSIONS
This is a subset of JSON_PERMISSIVE focussed on allowing parsing of
varlink replies that get extended, i.e. gain new fields, without
allowing more than that (i.e. without allowing missing fields, or bad
field types or such).
2024-01-05 12:43:06 +01:00
Lennart Poettering
8ef31e1f13 Merge pull request #29692 from H5117/fix_pkcs11_uri
cryptenroll: change class in provided PKCS#11 URI if necessary
2024-01-05 12:14:26 +01:00
Lennart Poettering
00096a3549 oomd: make use of new JSON_DISPATCH_ENUM_DEFINE() macro 2024-01-05 12:08:37 +01:00
Lennart Poettering
19f3282929 user-record: port over to JSON_DISPATCH_ENUM_DEFINE() 2024-01-05 12:08:37 +01:00
Lennart Poettering
8618ff1368 test: add unit test for JSON_DISPATCH_ENUM_DEFINE() 2024-01-05 12:08:37 +01:00
Lennart Poettering
dda6629622 json: add macro for automatically defining a dispatcher for an enum 2024-01-05 12:08:37 +01:00
Lennart Poettering
8d042bc40a tpm2-util: more iovec'ification
Let's move more code to using struct iovec for passing around binary
chunks of data.

No real changes in behaviour, just refactoring.
2024-01-05 11:34:46 +01:00
Lennart Poettering
9d1c3e9413 test: add unit tests for the new iovec helpers 2024-01-05 11:34:46 +01:00
Lennart Poettering
dddc12f9eb iovec-util: add CONST_IOVEC_MAKE_STRING() 2024-01-05 11:10:22 +01:00
Lennart Poettering
4cc467b67c iovec-util: add new iovec_memdup() helper 2024-01-05 11:10:22 +01:00
Lennart Poettering
bf38e4c0c1 iovec-util: add new iovec_memcmp() helper 2024-01-05 11:10:22 +01:00
Lennart Poettering
39f586873d iovec-util: add iovec_is_valid() helper 2024-01-05 11:10:22 +01:00
Lennart Poettering
33d1febbd7 iovec-util: rework IOVEC_MAKE_STRING() to work with compound initialized input
This avoids the ({}) that IOVEC_MAKE_STRING() so far used and might
cause a memory corruption if the parameter passed in is itself allocated
via a compount initialized array or so.

Also, this makes sure both IOVEC_MAKE_STRING() and IOVEC_MAKE() accept
'const' parameters without this causing a compiler warning.
2024-01-05 11:10:22 +01:00
Lennart Poettering
b22f0a502d json: add more iovec helpers for serializing/deserializing binary data 2024-01-05 11:10:22 +01:00
Yu Watanabe
20a0aeb039 vpick: fix typo
Follow-up for 76511c1bd3.
2024-01-05 19:08:12 +09:00
Yu Watanabe
d61df11fcd login: noone -> no one
Follow-up for 59afe07c21.
2024-01-05 19:08:12 +09:00
Yu Watanabe
e75c24c450 core/dbus-manager: fix typo
Follow-up for 84c01612de.
2024-01-05 19:08:12 +09:00
Yu Watanabe
9e44842a9a string-util: fix typo
Follow-up for 63566c6b6f.
2024-01-05 19:08:12 +09:00
Lennart Poettering
35a7dd4834 Merge pull request #30728 from polarina/noda
Assign noDA attribute to TPM2 objects not dependant on a PIN
2024-01-05 11:04:11 +01:00
Adrian Vovk
cc51085a41 core: Add %D specifier for $XDG_DATA_HOME
We already have specifiers that resolve to $XDG_STATE_HOME, and
$XDG_CONFIG_HOME. $XDG_DATA_HOME is in a similar vein.

It allows units belonging to the user service manager to correctly look
into ~/.local/share. I imagine this would be most useful inside of
condition checks (i.e. only run a service on session startup if some
data is not found in ~/.local/share) or in the inotify monitoring of a
.path unit
2024-01-05 11:03:06 +01:00
Vladimir Stoiakin
85828ef920 cryptenroll: change class in provided PKCS#11 URI if necessary
cryptenroll accepts only PKCS#11 URIs that match both a certificate and a private key in a token.
This patch allows users to provide a PKCS#11 URI that points to a certificate only, and makes possible to use output of some PKCS#11 tools directly.
Internally the patch changes 'type=cert' in the provided PKCS#11 URI to 'type=private' before storing in a LUKS2 header.

Fixes: #23479
2024-01-05 12:32:36 +03:00
Yu Watanabe
2743854540 network: do not make the implied default have the first priority
Follow-up for b732606950 and
6706ce2fd2.

If Network.ignore_carrier_loss_set flag is set, then the timeout value
is always used, hence the logic implemented by
b732606950 never worked.
2024-01-05 18:04:18 +09:00
Mike Yuan
9c02eb283a core/cgroup: use designated initializer more, make dup source const 2024-01-05 10:01:52 +01:00
Lennart Poettering
4e99803f23 Merge pull request #30731 from poettering/logind-user-early
logind: rework the special casing we give root's sessions
2024-01-05 10:01:30 +01:00
Alberto Planas
ef949448ec Use .d path for PCRLOCK_KERNEL_*_PATH
Fix the path for the generated.pcrlock files for the cmdline and initrd
cases.  Without it the tool complains with:

    Failed to parse component file /var/lib/pcrlock.d/720-kernel-initrd.pcrlock, ignoring: Is a directory

Signed-off-by: Alberto Planas <aplanas@suse.com>
2024-01-05 10:00:42 +01:00
Lennart Poettering
c759fad16c Merge pull request #30753 from aafeijoo-suse/special-refactor
tree-wide: use defines from special.h in some missing places
2024-01-05 10:00:03 +01:00
Lennart Poettering
e745400bee Merge pull request #30769 from AdrianVovk/statx-timestamp
stat-util: Add statx version of timespec_load
2024-01-05 09:59:40 +01:00
Luca Boccassi
90043781ba Merge pull request #30743 from bluca/coverity
Assorted coverity fixes
2024-01-05 09:27:21 +01:00
Luca Boccassi
6a80e22766 Merge pull request #30759 from mrc0mmand/resolved-followup
resolve: initialize `r` during OOM
2024-01-05 09:26:19 +01:00
Sergei Zhmylev
25aa35d465 journalctl: add --exclude-identifier option 2024-01-04 23:21:39 +01:00