Commit Graph
903 Commits
Author SHA1 Message Date
scarlet-storm 48b9d7e980 Use sectorsize for partition tables on block devs
Fix for specific case #30393 where 4k sector luks container is created
on a 512b device. In this case the partition table needs to be 512b,
else the kernel will not be able to find the partition, and we will
have to create a loop device to translate the partition table to 4k.
2026-02-17 18:23:35 +05:30
scarlet-storm 6a389701b2 homework: Ensure we don't stack block devices
Ensure we don't create a loop device on top of a physical block device.
This leads to huge performance degradation of discard operations if the
physical device does not support discard_on_zeroes.

- loop device historical semantics dictates that when the device is
  discarded, it needs to return zero data on read. This can be
  implemented easily on a filesystem. since fallocate zero-range
  would return immediately & the holes are handled at the filesystem
  level to return zero data on read.
- For a raw block device, the feature (discard_zeroes_data) depends on
  the capabilities of the physical device that is exposed to the
  block layer by the driver. This means that to guarantee that the loop
  device stacked on a block device returns zero on discarded data,
  it needs to convert discarded range into write_zero op on the block device.
  https://github.com/torvalds/linux/blob/63676eefb7a026d04b51dcb7aaf54f358517a2ec/drivers/block/loop.c#L773

For example on one of my local nvme I can see the following:
cat /sys/class/block/nvme1n1/queue/write_zeroes_max_bytes
131072
cat /sys/class/block/nvme0n1/queue/discard_max_hw_bytes
2199023255040

This means maximum size of a write_zero operation can be 128KiB &
maximum size of discard operation can be 2TiB on the block device.
So discarding for example 1TB of data, which would be a single block
device operation, gets split into 8.3 million block device operations
when issued on top of stacked loop device.
2026-02-17 18:23:35 +05:30
scarlet-storm 292525dd20 homework: Use same sector size when probing the device
If there is an explicit sector size specified in the user record,
use the same when probing the file using libblkid. The default
is 512 bytes, which will not be able to find the signatures, if the
partition table on regular file was created assuming 4k sectors
2026-02-17 18:23:35 +05:30
scarlet-storm 118cccf97f homework: Align partitions to 1MiB
Align partitions to 1MiB for consistency with regular partition tools
which use 1MiB alignment by default
2026-02-17 18:23:35 +05:30
scarlet-storm fc280b64e8 homework: Auto-probe luks sector size
Auto-probe the luks sector size, if not explicitly
specified in the home record
2026-02-17 18:23:35 +05:30
scarlet-storm a24f11798b homework: Remove zeroing of PMBR
Remove zeroing of PMBR before writing out the new partition table.
There is no reason, to do this explicitly ?
2026-02-17 18:23:35 +05:30
scarlet-storm 2790a782ce homework: Use same sector size as fdisk context
Ensure we use the same sector size as used in the created
fdisk context when converting between sectors and bytes.
2026-02-17 18:23:35 +05:30
Yu Watanabe da86da21e9 Fixes for option parsing (#40641)
Preparatory work split out of #40624.
2026-02-14 04:58:50 +09:00
Zbigniew Jędrzejewski-Szmek 952f3a5dbf homectl: drop --and-resize and --and-change-password
The two options are were not documented or ever used in the codebase.
Additionally, the parser expected an argumentless option, while the option
table declared a required argument. So I think this was added for debugging
and never excercised properly. Since there was no public documentation for
those, it's as if they never existed, so it should be fine to drop them.
2026-02-13 11:07:26 +01:00
Daan De Meyer 4f5d44ef53 tree-wide: Migrate to varlink_set_sentinel() 2026-02-11 14:25:36 +01:00
Luca Boccassi 75cb25c0b9 firstboot/homectl: hide plymouth splashscreen when asking questions
When plymouth is enabled, the screen gets all garbled when firstboot
runs and asks questions. Disable the splash screen, but only when
actually asking questions.
2026-02-03 13:21:03 +01:00
Luca Boccassi 7f7622285d homectl: trim some trailing whitespace 2026-02-03 12:47:12 +01:00
Vunny Sodhi db4b6b7043 pam_systemd_home: Use PAM_TEXT_INFO for token prompts
The prompts asking the user to physically authenticate
or confirm presence on a security token are informational
requests for action, not error conditions.

This commit changes the message type to PAM_TEXT_INFO,
which is more appropriate for guiding the user through
the authentication process.
2026-01-21 14:18:15 +01:00
Yu Watanabe 2aa496312e conf-files: introduce CONF_FILES_WARN flag and set it at various places
Closes #40285.
2026-01-16 23:05:33 +09:00
Zbigniew Jędrzejewski-Szmek 3a5b37e162 Split up the giant switch statement in homectl's parse_argv (#40059)
This is in preparation for later changes. The 1500+ line switch statement was very
hard to work with and had quite a bit of duplicated code. This is a rework that
splits outs parts into functions. I split this up into a bunch of commits so that it
can be reasonably reviewed. When viewed as one giant commit, diff just shows
a giant block of removed code and a giant block of added code.

In some cases I wasn't sure why one or the other of the identity arrays is used…
I preserved existing behaviour in all cases.
2026-01-16 14:31:08 +01:00
Zbigniew Jędrzejewski-Szmek f2c3ef9678 homectl: add argument comments 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek edd2a2a006 homectl: let drop_from_identity take multiple args
The only functional change should be that we deduplicate arg_identity_filter.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 37ad119451 homectl: trivial simplification 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek ed646a8d47 homectl: split out helpers parse_uid_field
Yet another very similar function, but without generics it's hard to deduplicate
those.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 47f631fda5 homectl: split out helpers parse_{fido2_device,pkcs11_token_uri}_field
Both implement the 'list' verb.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek b078b7f055 homectl: split out helper parse_tmpfs_limit_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 3f9c133922 homectl: split out helper parse_capability_set_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 0c2199b4cc homectl: split out helper parse_rebalance_weight 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek a161867b00 homectl: split out helper parse_auto_resize_mode_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek ed93b1ed14 homectl: split out helpers parse_{time,timestamp}_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 316e9887f2 homectl: split out helper parse_group_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 65cf26c72d homectl: split out helper parse_weight_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 12771c0cc6 homectl: split out helpers parse_{disk,sector}_size_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 873d38eac9 homectl: split out helper parse_language_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 0126bebccb homectl: split out helper parse_environment_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 47749fa762 homectl: split out helper parse_rlimit_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 2ef165ba1c homectl: fix confusion between "FOO" and "RLIMIT_FOO" as json keys
We parse RLIMIT_FOO, FOO, and LimitFOO all the same. But the keys in the
JSON dict are supposed to be "RLIMIT_FOO". We were creating such keys,
but then filtering them using "FOO", i.e. the filtering was not effective.

Using strjoina since both strings are under our control.
2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 56c05601f4 homectl: split out helper parse_nice_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 5db63f9de8 homectl: split out helpers that extend parse_string_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 9f4c9a6cd9 homectl: split out helper parse_mode_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek 2bcf520f31 homectl: split out helper parse_boolean_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek b1982aada6 homectl: split out helpers parse_{unsigned,u64,size}_field 2026-01-13 17:59:54 +01:00
Zbigniew Jędrzejewski-Szmek d7a4dfb8b2 homectl: split out helper parse_string_field 2026-01-12 12:24:51 +01:00
Zbigniew Jędrzejewski-Szmek fbd7ca0ef0 homectl: split out parser parse_ssh_authorized_keys
The idea is to split out helpers to make parse_argv() itself more
manageable. If possible, the helpers will be reused in many places. But
even if not, as in this case, it seems good to split out the code for a
specific option. Always, the sd_json_variant** pointer or pointers that
are operated on are selected in the caller. This way it is easier to see
which of the identity variables is used and if two different ones are
used.
2026-01-12 12:24:34 +01:00
Yu Watanabe 30b9fa495c clang-tidy: Enable more warnings (#39910) 2026-01-03 06:00:30 +09:00
Daan De Meyer 52ecf376fa tree-wide: Migrate to pidref_safe_fork()
Let's migrate all remaining callers of safe_fork()
to pidref_safe_fork() and get rid of safe_fork().
2026-01-02 20:08:41 +01:00
Daan De Meyer e6703a9aa4 process-util: Use ret as output parameter name
There's only one output parameter for all these
functions, so let's just name it ret following the
coding style.
2026-01-02 19:44:18 +01:00
Daan De Meyer 18842be4be tree-wide: Various coding style cleanups 2026-01-02 09:22:59 +01:00
Daan De Meyer 944ae1286b tree-wide: Use pamh as pam_handle_t parameter name
libpam uses pamh in its function declarations for
the plugin API so let's use the same name in our
tree as well.

Making sure the plugin function definitions match
the plugin function declarations is required to
enable clang-tidy's
readability-inconsistent-declaration-parameter-name
check, but to keep things consistent everywhere we
opt to use pamh tree-wide.
2026-01-02 09:21:43 +01:00
Yu Watanabe d0b224f845 libcrypt-util: turn into dlopen() dependency
Note, this drops logging only test case for crypt_preferred_method(),
as that requires explicitly dlopen() the library. But, we should test
that make_salt() and friends automatically dlopen() it.
2026-01-02 13:06:14 +09:00
Daan De Meyer aec52c1e6e string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends
Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
2026-01-02 04:05:45 +09:00
Daan De Meyer daff8ea8bb tree-wide: Introduce DECLARE_TRIVIAL_REF_UNREF_FUNC() and friends 2026-01-02 04:04:19 +09:00
Daan De Meyer f9708c53aa Follow ups for #39806
We drop the optimization for verify_sigchld as the
check differs based on the options passed and the
extra syscalls are certainly not going to matter
compared to the cost of forking a child process.

Fixes #40166
2025-12-21 08:16:03 +01:00
Daan De Meyer 29d1df4b03 tree-wide: Remove unnecessary SIGCHLD blocking
Now that sd-event doesn't insist on blocking
SIGCHLD anymore when watching for process exit,
let's stop blocking SIGCHLD tree-wide where not
required anymore.
2025-12-20 15:50:47 +01:00
Daan De Meyer fbd276cb86 tree-wide: Use pidref_wait_for_terminate_and_check()
Let's use the pidref variants for waiting and
checking a process everywhere and get rid of the
non pidref variants.
2025-12-20 15:50:47 +01:00