Yu Watanabe
bc5e8ebbfb
sd-device: use path_hash_ops to store sysattrs
...
As the stored values are actually path. Just for safety.
This also drops unnecessary duplication of path.
2022-09-19 18:04:12 +09:00
Yu Watanabe
d64b44be52
test: add testcase for link priority
2022-09-19 06:08:58 +09:00
Yu Watanabe
5b4671ec47
Merge pull request #24646 from yuwata/udev-node-symlink_atomic
...
udev: introduce symlink_atomic_full() and use it
2022-09-19 05:25:58 +09:00
Yu Watanabe
3afe230d4a
Merge pull request #24725 from yuwata/blockdev-util-introduce-block_device_get_whole_disk
...
blockdev-util: introduce block_device_get_whole_disk()
2022-09-19 05:25:09 +09:00
Yu Watanabe
626f15a4c1
Merge pull request #24730 from yuwata/dissect-image-drop-reference-to-decrypted-image
...
dissect-image: introduce dissected_image_relinquish()
2022-09-19 05:24:35 +09:00
Yu Watanabe
28f9bcd65a
path-util: add examples for path_make_relative() and path_make_relative_parent()
...
Addresses https://github.com/systemd/systemd/pull/24646#discussion_r973691797 .
2022-09-19 00:30:29 +09:00
Yu Watanabe
e330f97a89
tree-wide: drop unused reference to DecryptedImage
2022-09-18 23:47:20 +09:00
Yu Watanabe
3044d343dd
tree-wide: use dissected_image_relinquish()
2022-09-18 23:47:20 +09:00
Yu Watanabe
f906075a15
dissect-image: introduce dissected_image_relinquish()
2022-09-18 23:47:20 +09:00
Yu Watanabe
d50c55bd43
udev: do not ignore -ENOENT from sd_device_get_devname() for block device
...
We already checked that the sd_device object 'dev' is for a whole block
device. So, -ENOENT should not be triggeered here, and if it is, there
exists something spurious. Hence we should not ignore the failure.
2022-09-18 23:32:24 +09:00
Yu Watanabe
8f71534e06
udev: use block_device_get_whole_disk()
...
This should not change anything effectively.
2022-09-18 23:30:21 +09:00
Yu Watanabe
6d42138593
udev-node: use symlink_atomic_full_label() to create devlink
...
If the filename of a device symlink is too long, then the temporary
filename may become invalid, and we fail to create symlink.
The function `tempfn_random()` used in symlink_atomic_full() generates
a safe temporary filename.
Note that, thanks to the PR #23043 , now only one worker can handle
the same symlink simultaneously. Hence, the device ID based temporary
filename is not necessary.
2022-09-18 23:23:23 +09:00
Yu Watanabe
5a27af52c7
blockdev-util: change return value when a partition device is passed to partition_enumerator_new()
...
To make it consistent what returned by block_device_get_whole_disk().
2022-09-18 22:54:20 +09:00
Yu Watanabe
55a437f8b2
blockdev-util: introduce block_device_get_whole_disk()
2022-09-18 22:54:20 +09:00
Yu Watanabe
c07186ec03
blockdev-util: split-out block_device_is_whole_disk()
...
No functional changes, just preparation for later commits.
2022-09-18 22:54:20 +09:00
Yu Watanabe
8b6a70f699
Merge pull request #24719 from yuwata/dissect-image-dissected-image-new
...
dissect-image: introduce dissected_image_new()
2022-09-18 22:41:49 +09:00
Yu Watanabe
23d3dfc369
sd-device: refuse block device without subsystem
...
Previously, even if sd_device_get_subsystem() returns -ENOENT for block
device, we accepted that. This makes the check slightly stricter.
2022-09-18 15:35:56 +02:00
Yu Watanabe
0f75b0c589
dissect-image: free crypt_device object before trying to activate with unique name
...
Otherwise we get error from libcryptsetup like the following:
systemd[1234]: Cannot use device /dev/loop5 which is in use (already mapped or mounted).
2022-09-18 11:19:33 +02:00
Yu Watanabe
a1c3628b19
udev: downgrade log level when device node is already removed
...
Follow-up for 790da548b0 .
2022-09-18 10:51:25 +02:00
Yu Watanabe
babd5b08b5
dissect-image: introduce DISSECTED_PARTITION_NULL
...
Currently, it is not necessary to set partno or architecture in
dissect_image_new(), but just for safety.
Preparation for later commits.
2022-09-18 17:26:22 +09:00
Yu Watanabe
00e295055b
dissect-image: split out dissected_image_new()
...
To make dissect_image() shorter.
No functional changes, just refactoring.
2022-09-18 17:26:22 +09:00
Yu Watanabe
1e63dc4f1c
dissect-image: take a reference of LoopDevice into DissectedImage
...
To make LoopDevice object freed after DissectedImage is freed.
At least currently, this should not change anything. Preparation for
later commits.
2022-09-18 07:56:32 +09:00
Yu Watanabe
36d5eb0bff
loop-util: introduce reference counter for LoopDevice
2022-09-18 07:56:32 +09:00
Yu Watanabe
ac1e1b5fd7
dissect-image: take reference of DecryptedImage into DissectedImage
...
No functional changes. Preparation for later commits.
2022-09-18 07:56:32 +09:00
Yu Watanabe
9321ad5118
dissect-image: introduce reference counter for DecryptedImage
2022-09-18 07:56:32 +09:00
Yu Watanabe
ea16d7f48e
dissect-image: lazily deactivate decrypted DM volumes
...
The DM block device may be still used by other processes.
2022-09-18 07:27:22 +09:00
Yu Watanabe
cf610e1d87
cryptsetup-util: introduce crypt_free_and_replace()
2022-09-18 04:57:10 +09:00
Yu Watanabe
d3fcb73678
test-50-dissect: do not fail test on cleanup
...
These paths are read-only mount points. Hence, we cannot remove the
contents.
2022-09-17 21:36:18 +09:00
Yu Watanabe
759b4b4a2a
test-50-dissect: check mount destination instead of mount source
...
And rebreak long lines.
This should take no effective change, just refactoring.
2022-09-17 21:36:18 +09:00
Yu Watanabe
ee3455cf11
fd-util: rename CLOSE_AND_REPLACE() -> close_and_replace()
...
We have free_and_replace() and friends, they are all named with lower
letters, even they are macros, not functions.
For consistency, let's rename CLOSE_AND_REPLACE() with lower letters.
This also mekes the macro used more places.
2022-09-17 09:54:41 +02:00
Yu Watanabe
9972e6d6ed
dissect-image: make verity_partition() actually fail when all attempts of activation failed
2022-09-17 05:18:25 +09:00
Yu Watanabe
ad361a50fb
dissect-image: split out verity_timeout()
...
To make verity_partition() shorten. No functional changes, just
refactoring.
2022-09-17 05:18:25 +09:00
Yu Watanabe
cb19517490
man: explicitly document that "reboot -f" is different from "systemctl reboot -f"
...
Closes #24696 .
2022-09-17 05:15:36 +09:00
Yu Watanabe
dd35a61caf
sd-netlink: unexport sd-netlink
...
This effectively reverts 84e1001541 .
The sd-netlink library has several issues, and we should not export it
without solving them. See issues #24258 and #24124 .
2022-09-17 01:31:57 +09:00
Yu Watanabe
54ee1cd69d
Merge pull request #24692 from yuwata/dissect-image-fix-memleak
...
dissect-image: fix memleak
2022-09-17 01:31:32 +09:00
Yu Watanabe
ab8e6464b5
Merge pull request #24664 from yuwata/watchdog
...
watchdog: open /dev/watchdog0 only if it exists
2022-09-17 00:18:53 +09:00
Yu Watanabe
e99b370ccb
Merge pull request #24688 from yuwata/watchdog-dbus-properties-follow-ups
...
pid1: follow-ups for watchdog DBus properties
2022-09-17 00:18:05 +09:00
Yu Watanabe
e9fe11090e
Merge pull request #24685 from yuwata/uid-range
...
uid-range: several cleanups
2022-09-17 00:16:07 +09:00
Yu Watanabe
5bf5013fc9
dissect-image: handle all non-negative return values as success
...
No functional changes, just coding syle update.
2022-09-16 23:11:09 +09:00
Yu Watanabe
041e2edac8
dissect-image: fix memleak on failure
2022-09-16 23:11:09 +09:00
Yu Watanabe
69928b4f15
udev-node: do not create symlink to a non-existing device node
...
Previously, the stack directory contains empty regular files named with
device ID, and we create sd_device object from the device name.
Hence, we implicitly checked the existence of the device node.
However, now the files in the stack directory are symlink, and we
retrieve the path to the device node and its priority from the symlink.
Hence, the existence of the device node is not checked.
Let's check if the device node is still exist.
2022-09-16 23:08:07 +09:00
Yu Watanabe
13271e2dde
udev-node: split out stack_directory_read_one()
...
No functional changes, just refactoring.
2022-09-16 23:07:31 +09:00
Yu Watanabe
a6b7ebaafa
watchdog: use /dev/watchdog0 only if it exists
...
Fixes #24661 .
2022-09-16 22:34:37 +09:00
Yu Watanabe
3e911a0d0e
pid1: drop redundant DBus properties
...
Follow-up for 10f3f4ed01 .
We already have RuntimeWatchdogUSec or friends. Let's not introduce
redundant properties.
Also, drop the const qualifier for WatchdogLastPingTimestamp, as they
are actually not constant.
2022-09-16 21:53:28 +09:00
Yu Watanabe
9341f41801
watchdog: explicitly initialize global variable
...
No functional change, as they were implicitly initialized with zero.
2022-09-16 21:48:39 +09:00
Yu Watanabe
269073fda6
test: add tests for uid_range_coalesce()
2022-09-16 21:11:19 +09:00
Yu Watanabe
8dcc66cefc
uid-range: tie up number and array of uid range entries
...
This renames UidRange -> UidRangeEntry, and reintroduces UidRange which
contains the array of UidRangeEntry and its size.
No fucntional changes, just refactoring.
2022-09-16 20:56:58 +09:00
Yu Watanabe
6cc6cd9289
uid-range: make uid_range_intersect() take two UidRange objects
...
No functional changes, just refactoring.
2022-09-16 20:52:47 +09:00
Yu Watanabe
f6c13f9f95
uid-range: optimize to load uid_map file
...
If uid_map contains many lines, then the previous logic takes O(n^2 log n),
This makes O(n log n).
2022-09-16 20:52:36 +09:00
Yu Watanabe
b5739767da
uid-range: escape from loop earlier
...
The array of uid range entries are already sorted. Hence, if x and y are
does not have intersection, then the remaining entries neither have
intersection with x.
2022-09-16 20:50:00 +09:00
Yu Watanabe
34eeba475d
uid-range: sort uid range entries in uid_range_coalesce()
...
As the logic in uid_range_coalesce() assumes the array of entries are
already sorted.
No functional changes, just refactoring.
2022-09-16 20:49:55 +09:00
Yu Watanabe
7cf337c50f
uid-range: use parse_uid_range()
2022-09-16 20:48:53 +09:00
Yu Watanabe
fb76e6a710
userdbctl: fix arrow direction
2022-09-16 20:48:53 +09:00
Yu Watanabe
3498609f08
userdbctl: do not show meaningless boundaries when no uid range available
2022-09-16 20:48:53 +09:00
Yu Watanabe
f91c23f785
sd-device-monitor: do not trigger assertion when uid_map is not empty
...
Follow-up for c0aa23cf1e .
2022-09-16 13:05:51 +02:00
Yu Watanabe
8cfde28b61
update TODO
2022-09-16 04:18:58 +09:00
Yu Watanabe
f562abe296
unit: drop ProtectClock=yes from systemd-udevd.service
...
This partially reverts cabc1c6d7a .
The setting ProtectClock= implies DeviceAllow=, which is not suitable
for udevd. Although we are slowly removing cgropsv1 support, but
DeviceAllow= with cgroupsv1 is necessarily racy, and reloading PID1
during the early boot process may cause issues like #24668 .
Let's disable ProtectClock= for udevd. And, if necessary, let's
explicitly drop CAP_SYS_TIME and CAP_WAKE_ALARM (and possibly others)
by using CapabilityBoundingSet= later.
Fixes #24668 .
2022-09-16 03:41:29 +09:00
Yu Watanabe
88ffd21014
test-date: do not fail even on ~50 years later
...
Fixes #16181 .
2022-09-15 13:48:55 +01:00
Yu Watanabe
a900274915
test-seccomp: support systems that sched_setscheduler() is already limited
...
Fixes #17078 .
2022-09-15 13:47:17 +01:00
Yu Watanabe
f539452505
Merge pull request #24671 from mrc0mmand/even-more-codeql
...
ci: enable a couple more possibly useful CodeQL queries
2022-09-15 06:22:36 +09:00
Yu Watanabe
af3d387365
tree-wide: fix typo
2022-09-15 06:03:57 +09:00
Yu Watanabe
10f3f4ed01
pid1: introduce dbus properties WatchdogDevice and friends
...
Closes #24665 .
2022-09-14 13:13:59 +01:00
Yu Watanabe
908eb7be58
Merge pull request #24669 from dtardon/nested-asserts
...
Use nested ASSERT_PTR
2022-09-14 20:27:07 +09:00
Yu Watanabe
590d81002b
fs-util,label: introduce symlink_atomic_full() and symlink_atomic_full_label()
...
These new functions optionally create symlink of relative path.
2022-09-14 06:22:09 +09:00
Yu Watanabe
449375d2ad
fs-util: use path_make_relative_parent() at one more place
2022-09-14 06:22:09 +09:00
Yu Watanabe
c9bc7a449c
Merge pull request #24663 from mrc0mmand/codeql-follow-up
...
A couple of CodeQL tweaks and follow ups
2022-09-14 05:31:10 +09:00
Yu Watanabe
d0b387b617
Merge pull request #24662 from mrc0mmand/test-exec-deserialization-tweaks
...
test: drop the use of `tempfile.mktemp()`
2022-09-14 05:29:00 +09:00
Yu Watanabe
6f2d367e49
Merge pull request #24272 from dtardon/asserts
...
Use ASSERT_PTR more
2022-09-13 21:08:10 +09:00
Yu Watanabe
63d18b6cd0
boot: fix missing initialization
...
Fixes CID#1497847.
2022-09-13 21:06:05 +09:00
Yu Watanabe
e51bea3433
Merge pull request #24651 from yuwata/openssl-util
...
openssl-util: trivial cleanups
2022-09-13 21:05:42 +09:00
Yu Watanabe
35aefda35f
creds-util: fix NULL pointer dereference
...
Fixes CID#1497840.
2022-09-13 21:05:16 +09:00
Yu Watanabe
2e64df07b8
openssl-util: use assert() if no side effect
2022-09-13 17:03:34 +09:00
Yu Watanabe
d39929d96d
openssl-util: drop meaningless assertion
...
As the type of 'msz' is int.
Fixes CID#1497842.
2022-09-13 17:03:18 +09:00
Yu Watanabe
6d64cb0625
Merge pull request #23087 from yuwata/udev-watch
...
udev: resolve race in saving inotify watch handle
2022-09-12 23:41:00 +09:00
Yu Watanabe
75a5a143bb
Merge pull request #23043 from yuwata/udev-node-use-flock
...
udev-node: use flock() for symlink stack directory
2022-09-12 23:40:34 +09:00
Yu Watanabe
ee27501225
test: add testcase for udev-watch
2022-09-12 01:36:06 +09:00
Yu Watanabe
3fb94c7062
sd-device: move device_new_from_watch_handle_at() to udev-watch.c
...
And drop unused watch handle related functions.
2022-09-12 01:36:06 +09:00
Yu Watanabe
790da548b0
udev: warn on udev_watch_{begin,end}() failure
2022-09-12 01:36:06 +09:00
Yu Watanabe
4443b1857b
udev: drop unnecessary call of udev_watch_end()
...
As it is already called by udev_event_execute_rules().
2022-09-12 01:36:06 +09:00
Yu Watanabe
2369152394
udev: use rm_rf() to remove old watch directory
2022-09-12 01:36:02 +09:00
Yu Watanabe
691a596da1
udev-watch: remove symlink for saving inotify watch handle only when it is owned by the processing device
...
Before removing symlinks that stores watch handles, this makes udev
worker check if the symlink is owned by the processing device.
Then, we can avoid TOCTOU and drop the try-and-wait loop.
This partially reverts 2d3af41f0e .
2022-09-12 01:32:32 +09:00
Yu Watanabe
cd66f972d1
udev: ignore IN_IGNORED inotify event earlier
2022-09-12 01:23:08 +09:00
Yu Watanabe
ea8213dc47
udev: not necessary to return 1 from on_inotify()
2022-09-12 01:23:08 +09:00
Yu Watanabe
03f48fc7c3
Merge pull request #24637 from mrc0mmand/TEST-75-tweaks
...
test: make the resolved notifications check a bit more robust
2022-09-12 01:17:36 +09:00
Yu Watanabe
706c9a30ac
test-29-portable: set timeout for 'portablectl reattach'
...
Then, the test can fail earlier than the timeout of the whole test
specified by $QEMU_TIMEOUT=.
This is useful when we try to run the test multiple times.
Workaround for issue #24147 .
2022-09-10 08:00:44 +00:00
Yu Watanabe
43be6d59bd
udev: use read_virtual_file() at one more place
2022-09-10 07:16:57 +09:00
Yu Watanabe
32703bd14c
udev: always open with O_NOCTTY
...
All files or device nodes opened here should not be console tty.
Let's open it the flags for safety.
2022-09-10 07:16:43 +09:00
Yu Watanabe
9a18458834
Merge pull request #24618 from yuwata/udev-split-synthesizing
...
udev: shorten synthesize_change() a bit
2022-09-10 02:52:54 +09:00
Yu Watanabe
86f9b69a6a
blockdev-util: split out blockdev_reread_partition_table()
...
No functional changes, just refactoring.
2022-09-10 01:19:41 +09:00
Yu Watanabe
9409174ee7
udevd: use partition enumerator at one more place
...
No functional changes, just refactoring.
2022-09-10 00:48:34 +09:00
Yu Watanabe
e97589cf38
Merge pull request #24609 from yuwata/sd-device-enumerator-check-sysname
...
sd-device-enumerator: check sysname earlier
2022-09-09 23:32:15 +09:00
Yu Watanabe
9cce72ee5d
Merge pull request #24611 from yuwata/loop-util-refactoring
...
loop-util: several cleanups
2022-09-09 23:31:19 +09:00
Yu Watanabe
e0993236d3
blockdevi-util: also check sysname when enumerating partitions
2022-09-09 22:30:19 +09:00
Yu Watanabe
88b5080ea9
sd-device-enumerator: use _cleanup_free_ attribute for safety
...
No functional changes, just improve readability.
Suggested by https://github.com/systemd/systemd/pull/24601#discussion_r966883459 .
2022-09-09 21:16:37 +09:00
Yu Watanabe
89ad604839
sd-device-enumerator: always ignore ENOENT from opendir()
...
But logs all errors.
2022-09-09 21:16:37 +09:00
Yu Watanabe
0f519b9c2e
sd-device-enumerator: check sysname earlier
2022-09-09 21:16:32 +09:00
Yu Watanabe
761787fc88
Merge pull request #24557 from yuwata/repart
...
repart: fix partition size calculation
2022-09-09 09:32:07 +09:00
Yu Watanabe
3b19e16056
test-58-repart: add test case for issue #24553
2022-09-09 05:53:01 +09:00
Yu Watanabe
9ccceb9d2b
repart: make existing partition can be also 'dropped'
...
Previously, when an existing partition cannot grow, then entire process
fails. This makes such an existing partion handled as an foreign
partition, i.e. it is not managed by us.
2022-09-09 05:52:57 +09:00
Yu Watanabe
cdbcc33952
repart: check if existing partitions can grow
...
Fixes #24553 .
2022-09-09 05:49:00 +09:00