1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00
Commit Graph

49938 Commits

Author SHA1 Message Date
Lennart Poettering
e1aec57dd1 copy: simplify error paths when creating temporary files 2021-03-05 07:12:51 +09:00
Lennart Poettering
e6283cbf48 run: tweak algorithm for generating unit name from dbus unique name
This reverts behaviour of systemd-run's unit name generation to the
status quo ante of #18871: we chop off the ":1." prefix if we can.
However, to address the issue that the unique name can overrun we then
do what #18871 did as fallback: only chop off the ":" prefix.

This way we should have pretty names that look like they always looked
in the common case, but in the case of a unique name overrun we still
will have names that work.

Follow-up for #18871
2021-03-04 20:50:41 +00:00
Lennart Poettering
4d930e87ee rm-rf: fix up chmod in the _cleanup_ rm_rf() destructors
REMOVE_CHMOD is necessary to remove files/dirs that are owned by us but
have an access mode that would not allow us to remove them. In generic
destructor calls for use with `_cleanup_` that are "fire-and-forget"
style we should make use of that, to maximize the chance we can actually
remove the files/dirs.

(Also, add in REMOVE_MISSING_OK. Just because prettier, we ignore the
return codes anyway, but it' a bit nicer to ignore a bit fewer errors.)
2021-03-04 20:50:07 +00:00
Lennart Poettering
44a8ad7a24 man: document how to use --network-interface= during boot
Fixes: #18793
2021-03-04 18:55:36 +01:00
Lennart Poettering
a60d064748 fileio: minor read_full_stream_full() optimization
If we shall read as much of a file/stream as we can, then it makes sense
to use the full malloc()ed memory, not just the part we asked for.
2021-03-04 18:55:02 +01:00
Lennart Poettering
407234203b
Merge pull request #18615 from xry111/private-ipc-1
New directives PrivateIPC and IPCNamespacePath
2021-03-04 18:04:28 +01:00
caoxia
370d3c31b4 trans_time sec is int32,it will overflow if local system time is later than 2038. 2021-03-04 18:00:29 +01:00
Lennart Poettering
9706d27cbe
Merge pull request #18840 from yuwata/libudev-monitor-tiny-cleanup
io-util: introduce ppoll_usec()
2021-03-04 17:23:17 +01:00
Lennart Poettering
1b153a82f4 install: include OS headers before our own definition
Doesn't matter much, but matches more our usual coding style where our
definition are done after all headers provided by the OS are included.
2021-03-04 16:20:46 +01:00
Zbigniew Jędrzejewski-Szmek
b4e9c97477
Merge pull request #18773 from yuwata/network-move-several-functions
network: move several functions
2021-03-04 12:25:59 +01:00
Anita Zhang
01584bf9e4 run: update dbus unique names check
Some code in systemd-run checks that a bus's unique name must start with
`:1.`. However the dbus specification on unique connection names only specifies
that it must begin with a colon. And the freedesktop/dbus implementation allows
allows unique names to go up to `:INT_MAX.INT_MAX`. So update the
current check to only look for a colon at the beginning.
2021-03-04 09:52:13 +00:00
Zbigniew Jędrzejewski-Szmek
da46a1bc3c core: fix mtime calculation of dropin files
Nominally, the bug was in unit_load_dropin(), which just took the last mtime
instead of calculating the maximum. But instead of adding code to wrap the
loop, this patch goes in the other direction.

All (correct) callers of config_parse() followed a very similar pattern to
calculate the maximum mtime. So let's simplify things by making config_parse()
assume that mtime is initialized and update it to the maximum. This makes all
the callers that care about mtime simpler and also fixes the issue in
unit_load_dropin().

config_parse_many_nulstr() and config_parse_many() are different, because it
makes sense to call them just once, and current ret_mtime behaviour make sense.

Fixes #17730, https://bugzilla.redhat.com/show_bug.cgi?id=1933137.
2021-03-04 16:07:03 +09:00
Zbigniew Jędrzejewski-Szmek
0746159886 coredumpctl: show container hostame
Fixes #18321. I don't see any point in showing the hostname in
_HOSTNAME: it's either the same as COREDUMP_HOSTNAME or irrelevant.
2021-03-04 15:51:59 +09:00
Yu Watanabe
6ce8eda8a1
Merge pull request #18864 from poettering/fsync-tweaks
make sure fsync_directory_of_file() + fsync_full() work on more inode types reasonably
2021-03-04 14:51:10 +09:00
Lennart Poettering
1b55621dab rm-rf: fstatat() might fail if containing dir has limited access mode, patch that too 2021-03-04 14:50:50 +09:00
Lennart Poettering
1071c195f7 fs-util: when opening arbitrary inodes, better use O_NONBLOCK
In case this is a device node where opening might block.
2021-03-04 14:50:38 +09:00
Lennart Poettering
22a0a36efa gpt: generalize validator for GPT partition labels
This adds a proper validator function.

No change in behaviour, just some minor refactoring (this should be
useful elsewhere later on though)
2021-03-04 14:50:24 +09:00
Lennart Poettering
30cdcd628b fs-util: port open_parent() to path_extract_directory() 2021-03-03 22:00:24 +01:00
Hela Basa
79c25eaee4 po: Added translation using Weblate (Sinhala)
Co-authored-by: Hela Basa <r45xveza@pm.me>
2021-03-03 21:56:30 +01:00
Yu Watanabe
d9e2af0ae8 tree-wide: use ppoll_usec() 2021-03-04 05:06:48 +09:00
Yu Watanabe
c4febde9d0 io-util: introduce ppoll_usec() helper function 2021-03-04 05:06:43 +09:00
Yu Watanabe
1d61d70abb libudev: shorten code a bit
fd_wait_for_event() or ppoll() does not return -EAGAIN.
2021-03-04 05:03:44 +09:00
Lennart Poettering
ed4a653c09 fs-util: handle gracefully if fsync_full() is called on block devices and such 2021-03-03 18:31:23 +01:00
Lennart Poettering
9041e36d07 fs-util: allow fsync_directory_of_file() on directories too
(in which case the parent dir is synced)
2021-03-03 18:31:20 +01:00
Xℹ Ruoyao
80271a446c
Remount /dev/mqueue in unshared mount namespace for PrivateIPC 2021-03-04 00:08:09 +08:00
Xℹ Ruoyao
a70581ffb5
New directives PrivateIPC and IPCNamespacePath 2021-03-04 00:04:36 +08:00
Xℹ Ruoyao
54c2459d56
Refactor network namespace specific functions in generic helpers 2021-03-04 00:04:36 +08:00
Xℹ Ruoyao
a959cd2812
fuzz: add NetworkNamespacePath= into directives.service 2021-03-04 00:04:35 +08:00
Vincent Pelletier
dbdcd51f78 rules: Move ID_SMARTCARD_READER definition to a <70 configuration.
70-uaccess.rules sets the uaccess tag on devices with ID_SMARTCARD_READER
set, but it is set in 99-systemd.rules .
Move this to a 60-*.rules which already matches USB CCID class, factorising
the matching, so 70-uaccess.rules sets up these devices as expected.
2021-03-03 15:18:55 +01:00
Yu Watanabe
66d2330265 network: do not remove LLDP state file on failure 2021-03-03 16:42:23 +09:00
Yu Watanabe
5288861bf6 network: use conservative_rename() at one more place 2021-03-03 16:34:51 +09:00
Yu Watanabe
a34e58d445 network: remove DHCP lease and LLDP state file on link_free() 2021-03-03 16:31:28 +09:00
Yu Watanabe
ab7153b3f4 dhcp: use unlink_and_freep() in dhcp_lease_save() 2021-03-03 16:26:32 +09:00
Yu Watanabe
3be9d62ad1 network: move manager_{rtnl,udev}_process_link() to networkd-link.[ch] 2021-03-03 16:12:33 +09:00
Yu Watanabe
24e3ed843f network: drop unnecessary {} 2021-03-03 16:12:33 +09:00
Yu Watanabe
44e1f7e3dc network: minor style fixes 2021-03-03 16:12:33 +09:00
Yu Watanabe
d23a66f274 network: use unlink_and_freep() cleanup functions
This also makes state files not removed on failure.
2021-03-03 16:11:45 +09:00
Yu Watanabe
3b5a4fc685 network: move state file related functions to networkd-state-file.[ch] 2021-03-03 16:07:45 +09:00
Lennart Poettering
725ad3b062 fstab-generator: add new root=tmpfs option
It's useful to be able to combine a regular /usr/ file system with a
tmpfs as root, for an OS that boots up in volatile mode on every single
boot.  Let's add explicit support for this via root=tmpfs.

Note the relationship to the existing systemd.volatile= option:

1. The kernel command line "root=/dev/… systemd.volatile=yes" will mount
   the specified root fs, and then hide everything at the top by
   overmounting it with a tmpfs, except for the /usr subtree.

2. The kernel command line "root=tmpfs mount.usr=/dev/…" otoh will mount
   a toot fs at the top (just like the case above), but will then mount
   the top-level dir of the fs specified in mount.usr= directly below
   it.

Or to say this differently: in the first case /usr/ from the physical
storage fs is going to become /usr/ of the hierarchy ultimately booted,
while in the second case / from the physical storage fs is going to
become /usr of the hierarchy booted.

Philosophically I figure systemd.volatile= is more an option for
"one-off" boots, while root=tmpfs is something to have as default mode
of operation for suitable images.

This is currently hard to test reasonably, since Dracut refuses to
accept root=tmpfs. This needs to be addressed separately though.
2021-03-03 12:16:32 +09:00
Lennart Poettering
ab05bee1dd time-util: simplify overflow check
And don't rely on 2s complement.
2021-03-03 12:16:21 +09:00
Luca Boccassi
294f1b40ab
Merge pull request #18834 from poettering/path-extract
Beef up path_extract_filename() a bit, and introduce path_extract_directory()
2021-03-02 19:22:53 +00:00
Lennart Poettering
312dff1760 util: add helpers for generating colored check mark glyphs from bools 2021-03-03 03:08:31 +09:00
Lennart Poettering
62a88d7a3e tmpfile: port tempfn_*() to path_extract_*() 2021-03-02 15:07:52 +01:00
Lennart Poettering
7fc607637f machinectl: make sure of path_extract_filename() returning O_DIRECTORY 2021-03-02 15:07:48 +01:00
Lennart Poettering
ee277c6bc7 path-util: return O_DIRECTORY from path_extract_filename() when path ends in slash
Let's fine-tune the path_extract_filename() interface: on succes return
O_DIRECTORY as indicator that the input path was slash-suffixed, and
regular 0 otherwise. This is useful since in many cases it is useful to
filter out paths that must refer to dirs early on.

I opted for O_DIRECTORY instead of the following other ideas:

1. return -EISDIR: I think the function should return an extracted
   filename even when referring to an obvious dir, so this is not an
   option.

2. S_ISDIR, this was a strong contender, but I think O_DIRECTORY is a
   tiny bit nicer since quite likely we will go on and open the thing,
   maybe with openat(), and hence it's quite nice to be able to OR in
   the return value into the flags argument of openat().

3. A new enum defined with two values "dont-know" and
   "definitely-directory". But I figured this was unnecessary, given we
   have other options too, that reuse existing definitions for very
   similar purposes.
2021-03-02 15:07:44 +01:00
Lennart Poettering
8dcb891c19 path-util: add path_extract_directory(), to match path_extract_filename()
These two together are a lot like dirname() + basename() but have the
benefit that they return clear errors when one passes a special case
path to them where the extraction doesn't make sense, i.e. "", "/",
"foo", "foo/" and so on.

Sooner or later we should probably port all our uses of
dirname()/basename() over to this, to catch these special cases more
safely.
2021-03-02 15:07:11 +01:00
Luca Boccassi
7e40042b55 man: document usage of SD_BUS_CREDS_AUGMENT 2021-03-02 12:18:53 +01:00
Lennart Poettering
0498d8d74a
Merge pull request #18841 from keszybz/a-bunch-of-man-page-updates
Two minor small man page updates
2021-03-02 11:03:44 +01:00
Tom Shield
e595edf1a3
udev: add i2c to 60-persistent-input.rules for by-path (#18808)
Add the i2c subsystem to those that create by-path links.
i2c devices may not have IDs so we can't rely on the by-id links
but they (or some of them) should at least have a path that we can use.
2021-03-02 19:56:06 +10:00
Martin Wilck
d8ce385fe3 sd-device: don't use BPF filtering for kernel monitors
BPF filtering accesses fields in the netlink header that are
only filled in by libudev, never by the kernel. Therefore adding
BPF filters for kernel monitors is pointless. Even false filtering
of kernel events might be possible; at least it's hard to prove that
it can't occur.
2021-03-02 18:38:36 +09:00