1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-28 05:57:33 +03:00

48328 Commits

Author SHA1 Message Date
Daan De Meyer
d6e8137716 boot: Only use io.systemd.boot.kernel-cmdline-extra for type 1 images
Otherwise the cmdline is duplicated for UKIs.
2024-03-13 23:42:34 +01:00
Evgeny Vereshchagin
a96b4557cb fuzz: make sure DHCP client leases are loaded successfully
Now that fa3357b9e8d9d7a486902d0b6d4b4015fc10aac0 is merged the fuzz
target should no longer crash there.
2024-03-14 00:10:08 +09:00
sharad3001
e0cd8a1bdf
udev: add assert for EVENT_RESULT_EXIT_STATUS_BASE (#31710)
EVENT_RESULT_EXIT_STATUS_BASE and EVENT_RESULT_SUCCESS has the same value.
Code updated to add assert statement for EVENT_RESULT_EXIT_STATUS_BASE.
2024-03-13 22:25:22 +09:00
Yu Watanabe
cac8e820d6 network/varlink: return StorageReadOnly error
Addresses https://github.com/systemd/systemd/pull/30021#discussion_r1521595855.
2024-03-13 21:49:12 +09:00
AKHIL KUMAR
8cbc701ded networkctl.c : call 'assert_not_reached' where appropriate
networkctl.c : call 'assert_not_reached' where appropriate
2024-03-13 21:46:05 +09:00
Mike Yuan
9c16c8a177 networkd-manager: drop spurious return
Follow-up for f90eb086270f0aea8efcbff5a5e4c338d178cfd4
2024-03-13 21:44:33 +09:00
Luca Boccassi
8fb8c037b3
Merge pull request #31729 from aafeijoo-suse/logind-cleanups
logind: coding style cleanups
2024-03-13 11:27:35 +00:00
Lennart Poettering
91180a1eec polkit: add another flag that controls how to treat the PK absent case
Typically if PK is not present we want to treat this as "denied". But
sometimes it makes sense to treat this case as "allowed".

In particular the combination POLKIT_ALWAYS_QUERY and
POLKIT_DEFAULT_ALLOW makes a lot of sense: it means we can enable PK
logic for actions where we so far bypassed the checks for root. With the
new combination we can have a default policy of allowing some operation
but still provide an effective hook to disable it.

Also add some debug logging about PK operations and results as they are ongoing.
2024-03-13 10:43:44 +01:00
Lennart Poettering
f5a12ceaed polkit: add new POLKIT_ALWAYS_QUERY flag
When this flag is set we'll disable the local shortcut that skips polkit
checks for clients that are privileged, and assumes they are
authenticated.

Or in other words: if this flag is set, we'll query PK not matter what,
regardless if it's root we talk about or any other user.
2024-03-13 10:42:27 +01:00
Lennart Poettering
b9632ec42f polkit: allow checking if we already acquired some action
This adds a new helper that basically just wraps
async_polkit_query_have_action() and allows calling this without
actually triggering a PK authentication operation: it just checks if we
aleady have acquired an action or not.
2024-03-13 10:42:13 +01:00
Lennart Poettering
95db87ffed
Merge pull request #31731 from poettering/stat-is-set
stat-util: add explicit helpers for checking if stat/statx is initialized
2024-03-13 10:37:15 +01:00
SidhuRupinder
7d08e23558
local-addresses: call 'assert_not_reached' where appropriate (#31728)
Added code for calling the 'assert_not_reached' function as the value of the 'family' parameter must be either 'AF_INET' or 'AF_INET6'.
2024-03-13 13:16:46 +08:00
Mike Yuan
a793133963
Merge pull request #31727 from YHNdnzj/homed-followup
data-fd-util: some cleanups
2024-03-13 13:10:34 +08:00
Lars Ellenberg
b8e25bff38 fs-utils: new wrapper fd_reopen_propagate_append_and_position()
We may want to propagate O_APPEND, or (try to) keep the current file position,
even if we use fd_reopen() to re-initialize (and "unshare") other file
description status.

For now, used only with --pty to keep/propagate O_APPEND (and/or) position
if set on stdin/stdout.

If we re-open stdout and "drop" the O_APPEND,
we get rather "unexpected" behavior,
for example with repeated "systemd-run --pty >> some-log".

If someone carefully pre-positioned the passed in original file descriptors,
we avoid surprises if we do not reset file postition to zero.

fcntl F_GETFL first, and propagate O_APPEND if present in the existing flags.

Then use lseek to propagate the file position.
2024-03-12 19:01:00 +01:00
Antonio Alvarez Feijoo
d3d880e558 homed: fix typo 2024-03-12 16:18:29 +00:00
Luca Boccassi
121c4eba0a ukify: really add default .sbat for UKIs
This was lost on refactor, and only addons had a default uki
line in the .sbat. Add it back, and differentiate between the
default for UKIs vs the default for addons, so that they can
be revoked separately. These are only defaults and users are
encouraged to provide their own.

Follow-up for a8b645dec8e6abf4c9ba0c93a6a0088953a2155e
2024-03-12 11:36:08 +01:00
Yu Watanabe
3fbade30a8
Merge pull request #31716 from evverx/fuzz-lease-save-load
fuzz: save/load DHCP client leases
2024-03-12 19:05:17 +09:00
Lennart Poettering
7cff2b79f0 stat-util: make sure inode_type_to_string() handles anonymous inodes in a reasonable way 2024-03-12 10:45:24 +01:00
Antonio Alvarez Feijoo
af9f57e731
logind-inhibit: get rid of basename() in inhibitor_new()
Follow-up to #31594
2024-03-12 10:43:31 +01:00
Antonio Alvarez Feijoo
26ed3ecfe0
logind: place 'ret' param at last
Follow-up to 2454cee32e
2024-03-12 10:39:08 +01:00
Lennart Poettering
1c248d7fb7 stat-util: add explicit helpers for checking if stat/statx is initialized
This is a follow-up for 945a8210c770801c8492eda03b6e9af3ec5d03a3 and
makes the st_dev check generic, so that we can reuse it some other
places. It also incorporates the non-NULL check now, to be a
comprehensive one-stop solution.

The helper is static inline so that compilers can optimize the redundant
checks away in case it is combined with other checks.
2024-03-12 10:25:48 +01:00
Mike Yuan
72a22e737b
homework-cifs: log correct errno
Follow-up for 606a1f203c8871871bc8c5833d66ccbef870b010
2024-03-12 16:42:49 +08:00
Mike Yuan
0870fc2404
data-fd-util: accept size == SIZE_MAX and translate that to strlen
Like what we already do at other places
2024-03-12 16:42:48 +08:00
Mike Yuan
7799e7d9f0
data-fd-util: some modernization 2024-03-12 16:42:48 +08:00
Mike Yuan
faadc90c33
fileio,data-fd-util: use U64_* more 2024-03-12 16:42:48 +08:00
Mike Yuan
8b8edb512a
env-util: remove unneeded DISABLE_WARNING_FORMAT_NONLITERAL
_printf_ is used, so this shouldn't emit a warning
in the first place.
2024-03-12 15:41:51 +08:00
Mike Yuan
5d789ba5a6
Merge pull request #31671 from AdrianVovk/homework-cifs-credentials
homework-cifs: Pass password via fd
2024-03-12 15:40:43 +08:00
Mike Yuan
18eebde33a
Merge pull request #31713 from YHNdnzj/pidref-equal
pidref: use fd_inode_same to compare pidfds
2024-03-12 14:15:36 +08:00
Yu Watanabe
06baee4ea3
Merge pull request #30021 from yuwata/dhcp-client-id-cleanups
dhcp-server: save bound leases to persistent storage, and load it on start
2024-03-12 13:40:09 +09:00
Luca Boccassi
b6fb31be45
Merge pull request #31721 from aafeijoo-suse/service-util-help-fix
shared/service-util: actually use the `bus_introspect` argument in `help()`
2024-03-11 18:13:57 +00:00
Adrian Vovk
606a1f203c
homework-cifs: Pass password via fd
Pass the password into mount.cifs via a file descriptor, rather
than putting it into a plain-text file in /tmp. This uses the $PASSWD_FD
environment variable, which is undocumented but has existed since
forever (initial commit from 2010 [1] has it already)

[1]:
https://git.samba.org/?p=cifs-utils.git;a=blob;f=mount.cifs.c;hb=ce0b1609a9eedce6c5eb20eab287ea44217c0a6a#l1477
2024-03-11 13:07:06 -04:00
Yu Watanabe
5582b36c38 network/dhcp-server: save leases in state directory
Then, we can read the lease file on restart, and the DHCP server will be
able to manage previously assigned addresses.

To save leases in the state directory /var/lib/systemd/network/, this
adds systemd-networkd-dhcp-server.service, and by default
systemd-networkd does not start the DHCP server without the heler
service started.

Closes #29991.
2024-03-12 01:57:17 +09:00
Yu Watanabe
35b2c1b0c8 fuzz-dhcp-server: also test saving and loading lease file 2024-03-12 01:57:17 +09:00
Yu Watanabe
033f119756 sd-dhcp-server: introduce sd_dhcp_server_set_lease_file() and dhcp_server_{save,load}_leases().
The functionality is not used networkd yet in this commit, but will be
used in later commits.
2024-03-12 01:57:17 +09:00
Yu Watanabe
aa8200e971 sd-dhcp-server: also expose lease expiration timestamp in realtime
Here, we use map_clock_usec_raw(), instead of map_clock_usec() to reduce
number of calls of now() -> clock_gettime().
2024-03-12 01:57:17 +09:00
Yu Watanabe
3ecd6fa98b time-util: expose map_clock_usec_internal() as map_clock_usec_raw()
This will be used later.
2024-03-12 01:57:17 +09:00
Yu Watanabe
b923ada838 sd-dhcp-server-lease: move functions to build json format
No functional change, just preparation for later commits.
2024-03-12 01:57:17 +09:00
Yu Watanabe
5a2f378362 sd-dhcp-server: refuse invalid hostname in request
Currently, the received hostname is not used for assigning an address to
the host, or options in the subsequent reply message. But, the parsed
hostname is exposed through DBus, and possibly Varlink in the future.
Let's ignore spurious hostname.
2024-03-12 01:57:17 +09:00
Yu Watanabe
fa3357b9e8 dhcp-option: refuse control and non-UTF8 characters in string option
We oftem save parsed DHCP options into a file, or expose them
through DBus or Varlink. In such case, control characters or non-UTF8
characters may cause many kind of unexpected errors. In general, a DHCP
message that have string options with spurious characters is mostly
malformed or broken. Let's refuse them.

This also makes dhcp_option_parse_string() do not free 'ret' argument,
to follow our usual coding style. So, callers now need to free the
pre-exisitng string if necessary.

Fixes #31708.
2024-03-12 01:57:17 +09:00
Yu Watanabe
91676b6458 networkctl: introduce "persistent-storage" command
Then, this introduces systemd-networkd-persistent-storage.service.

systemd-networkd.service is an early starting service. So, at the time
it is started, the persistent storage for the service may not be ready,
and we cannot use StateDirectory=systemd/network in
systemd-networkd.service.

The newly added systemd-networkd-persistent-storage.service creates the
state directory for networkd, and notify systemd-networkd that the
directory is usable.
2024-03-12 01:57:16 +09:00
Yu Watanabe
f90eb08627 network/varlink: introduce io.systemd.Network.SetPersistentStorage method
And make the networkd use state directory.

Currently, the state directory and the method are not used, but will be used later.
2024-03-12 01:57:11 +09:00
Adrian Vovk
58d061b5aa
data-fd-util: Fixup header
inttypes.h doesn't define size_t
2024-03-11 12:24:30 -04:00
Mike Yuan
2f41f10bcd
pidref: use fd_inode_same to compare pidfds 2024-03-11 22:57:50 +08:00
Mike Yuan
945a8210c7
stat-util: struct stat could be initialized with (st_mode & S_IFMT == 0)
For anonymous inodes, the result would be 0, but
the struct stat is initialized obviously.
So let's switch to st_dev for the check, which
is guaranteed to be non-zero.

Also this is completely unnecessary for statx(),
since we check stx_mask first and that on its own
denotes that the struct is initialized.
2024-03-11 22:57:50 +08:00
Mike Yuan
0cdb8df620
stat-util: introduce fd_inode_same 2024-03-11 22:53:08 +08:00
Luca Boccassi
14300cdde4 polkit: update the rest of bus_verify_polkit_async_full() calls to new flags parameter
Looks like the compiler doesn't even notice these were left over
as the types end up matching somehow

Follow-up for 29556b75d8025580eebe160a1fa1459965912ee2
2024-03-11 14:17:45 +00:00
Lennart Poettering
9f65355b85 fd-util: beef up fd_verify_safe_flags() features
Let's make fd_verify_safe_flags() even more useful:

1. let's return the cleaned up flags (i.e. just the access mode) after
   validation, hiding all the noise, such as O_NOFOLLOW, O_LARGEFILE and
   similar.

2. let's add a "full" version of the call that allows passing additional
   flags that are OK to be set.
2024-03-11 14:49:51 +01:00
Antonio Alvarez Feijoo
4313b99136
shared/service-util: actually use the bus_introspect argument in help()
If `bus_introspect` is false, do not print the `--bus-introspect=PATH` option.

Also, modernize help output.
2024-03-11 13:56:30 +01:00
Luca Boccassi
c7edd9f13d
Merge pull request #31711 from YHNdnzj/gpt-auto-has-node
gpt-auto: ignore fstab_has_node failure
2024-03-11 12:40:22 +00:00
Antonio Alvarez Feijoo
65064e2ff0
tree-wide: drop custom formatting for print() help messages
Follow-up for bc556335b1c568c98688cc1f586b5f753fcddac6
2024-03-11 13:34:34 +01:00