Commit Graph
8191 Commits
Author SHA1 Message Date
Mike Yuan 9d7b189bf3 fstab-util: make use of PROC_CMDLINE_TRUE_WHEN_MISSING 2023-08-13 12:52:15 +08:00
Daan De Meyer 1d117b068f mkfs-util: Pass sector size to mkfs.f2fs
Let's pass the sector size to mkfs.f2fs as well.
2023-08-12 13:29:50 +02:00
Daan De Meyer 89dfac6b8f mkfs-util: Set sector size environment variables when invoking mkfs.ext4
Let's inform mkfs.ext4 about the sector size we're using.
2023-08-12 13:28:10 +02:00
Michael A Cassaniti c2dfcbd48e file-io: Fix copying sparse files
This change makes sure a data copy using copy_bytes() does not exceed the
max_bytes value when using COPY_HOLES and max_bytes stops before the next
data section.
2023-08-11 14:30:54 +02:00
Lennart Poettering a74c99807f Merge pull request #28736 from poettering/polkit-tweaks
some minor polkit handling tweaks
2023-08-10 09:35:52 +02:00
Yu Watanabe 7a05926fbe udev: re-introduce symlinks for loopback block device
But the directories are changed from /dev/loop/by-ref/ -> /dev/disk/by-loop-ref/
and /dev/loop/by-inode/ -> /dev/disk/by-loop-inode/.
As /dev/loop/ is used by losetup command for other purpose.
See issue #28475.

This effectively reverts commits 9915cc6086,
5022fab15f, and
c0d998248e.
2023-08-10 07:05:47 +09:00
Luca Boccassi 4051fc1d54 Merge pull request #28734 from loongarch64/dev-wu-main
seccomp: add LoongArch 64bit support
2023-08-09 20:20:03 +01:00
Lennart Poettering d1e8e8b5ae tree-wide: drop _pure_ + _const_ from local, static functions
This is supposed to be a help for compilers to apply optimizations on
functions where they can't determine whether they are const/pure on
their own. For static, local functions the compiler can do this on its
own easily however, hence the decoration with pure/const is just noise.
Let's drop it, and let the compiler to its thing better.

(Use it for exported functions, since compilers can't 'reach-over' into
other modules to determine if they are pure, except if LTO is used)
2023-08-10 00:01:04 +08:00
Xiaotian Wu f106a63952 LoongArch: Replace __loongarch64 with __loongarch_lp64
`__loongarch64` is no longer used for historical reasons and should be replaced by `__loongarch_lp64` in new code.

https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html#_cc_preprocessor_built_in_macro_definitions
2023-08-09 20:44:57 +08:00
Lennart Poettering c1b2e1a89a polkit: move asserts up, so that they cover all reply codepaths 2023-08-09 11:02:51 +02:00
Lennart Poettering 0a901c71f5 polkit: use LIST_POP where appropriate 2023-08-09 11:02:51 +02:00
Yu Watanabe 1177373b6a fstab-util: introduce fstab_enabled() helper function
And refuse to parse fstab when 'fstab=no' is specified in the kernel
command line.

When 'fstab=no' is specified in the kernel command line, fstab-generator
does not parse fstab and will not create e.g. /boot or /efi mount entry
even if fstab contains entries for the mount points. However, gpt-auto
generator may parse fstab file, and adjust or ignore mounts for EFI or
XBOOTLDR partitions based on the fstab file.

This makes gpt-auto also ignore fstab entries if 'fstab=no' is set in
the kernel command line.
2023-08-09 17:53:46 +09:00
Yu Watanabe 3787934b54 proc-cmdline: make proc_cmdline_get_bool() take flags
All other command line parsers takes flags. Let's make
proc_cmdline_get_bool() also take flags. Though, currently,
no flag is set by the caller.
2023-08-09 17:46:41 +09:00
Yu Watanabe 685e0dd192 veritysetup-generator: fix ordering of generated units
Fixes a bug introduced by 08b04ec7e7 and
953006dcb0.

Fixes #28725.
2023-08-09 11:26:09 +09:00
Xiaotian Wu f9d3fb6b5e seccomp: add LoongArch 64bit support 2023-08-09 08:50:07 +08:00
Dan Streetman 60696b22d9 openssl: add log_openssl_errors()
Add a macro to log all errors in the openssl 'thread error queue'.

This consolidates all the openssl-generated errors to return -EIO and log at
debug level.

Also add a 'invalid' test in test-openssl, to allow manual verification that
the openssl error(s) are logged.
2023-08-08 19:40:37 +01:00
Lennart Poettering 5a96b32dea libfido2: pick up debug logging from libfido2, and funnel it through our log subsystem
Fixes: #27984
2023-08-08 15:41:43 +02:00
Lennart Poettering 3c8680585c varlink: don't allocate fd control buffer on each read()
We'll need this on each read() again, hence let's just allocate this
once and then reuse it for subsequent read()s.

Follow-up for: #28639
2023-08-07 20:57:45 +01:00
Mike Yuan cc1e1bb03e shared/fstab-util: use is_device_path instead of is_device_node
Follow-up for 99299d0d5a

is_device_node() calls lstat(), causing device node
symlinks under /dev/disk/ not being compared correctly
using devnode_same().

Fixes #28585
2023-08-05 22:39:46 +01:00
Dan Streetman 9afd4dde22 tpm2: use ELEMENTSOF() instead of sizeof() for TPML_PCR_SELECTION pcrSelections field
The count field indicates the number of elements in the pcrSelections field,
and the size of each elements is greater than 1 byte, so using sizeof() is
incorrect when verifying the count field is valid; instead ELEMENTSOF() should
be used.

Caught by coverity check: https://github.com/systemd/systemd/pull/26331#pullrequestreview-1556629586
2023-08-05 13:31:59 +09:00
Dan Streetman 9e4379945b tpm2: move policy calculation out of tpm2_seal()
Move the calculation of the sealed object policy hash out of the tpm2_seal()
function. Instead, callers of tpm2_seal() can directly call
tpm2_calculate_sealing_policy() and then provide the policy hash to
tpm2_seal().
2023-08-04 11:20:22 -04:00
Dan Streetman e3acb4d24c tpm2: add functions to convert TPM2B_PUBLIC to/from openssl pkey or PEM
Add functions to convert a PEM or pkey to TPM2B_PUBLIC, and functions to
convert TPM2B_PUBLIC to pkey or fingerprint.

Supports both RSA and ECC keys.

Add ECC support to some test-tpm2 tests, and tests to cover the newly added functions.
2023-08-04 11:19:54 -04:00
Dan Streetman 0fdcfa7812 test: add DEFINE_HEX_PTR() helper function
Use function in test-tpm2 to convert hex strings to void* and len vars.
2023-08-04 10:57:08 -04:00
Dan Streetman 900e73f80e openssl: add ecc_pkey_new(), ecc_pkey_from_curve_x_y(), ecc_pkey_to_curve_x_y()
Add function to create openssl pkey from ECC curve and point, and function to
get curve id and x/y point from existing ECC pkey. Also add function to create
new ECC key for specified curve.

Also add DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO() to handle case when func() is
a macro, not a function symbol; specifically in this case it is used for
OPENSSL_free() which is a macro.
2023-08-04 10:57:08 -04:00
Dan Streetman dcec950ca1 openssl: add rsa_pkey_new(), rsa_pkey_from_n_e(), rsa_pkey_to_n_e()
Add function to generate an EVP_PKEY for a specific 'n' and 'e', and function
to get 'n' and 'e' values from existing RSA public key. Also add a function to
generate a new RSA key with a specified number of bits.
2023-08-04 10:57:07 -04:00
Dan Streetman 4af788c70c openssl: add openssl_pkey_from_pem()
Add function to create EVP_PKEY from PEM buffer.
2023-08-04 10:57:07 -04:00
Dan Streetman b4a6fcd5c5 tpm2: add tpm2_pcr_read_missing_values()
Add function to read all unset values in an array of Tpm2PCRValue entries.

Also publish tpm2_pcr_read() in header.
2023-08-04 10:57:07 -04:00
Dan Streetman 53b91e1981 tpm2: add TPM2B_*_MAKE(), TPM2B_*_CHECK_SIZE() macros
The tpm2-tss library has many structs with only an array and size; these macros
make it easy to assign to these structs.
2023-08-04 10:57:07 -04:00
Dan Streetman 07c0406117 tpm2: change tpm2_parse_pcr_argument() parameters to parse to Tpm2PCRValue array
In order to allow users to specify expected PCR values, change the
tpm2_parse_pcr_argument() to parse the text argument into an array of
Tpm2PCRValue objects, which provide not only the selected PCR indexes, but also
(optionally) the hash algorithm and hash value for each PCR index.
2023-08-04 10:57:07 -04:00
Dan Streetman 6e8fb3ad5f tpm2: change tpm2_calculate_policy_pcr(), tpm2_calculate_sealing_policy() to use Tpm2PCRValue array
An array of Tpm2PCRValue objects effectively replaces a TPML_PCR_SELECTION
object combined with an array of (properly ordered) TPM2B_DIGEST objects.

Also update tpm2_calculate_sealing_policy() pin parameter to boolean use_pin,
since the function does not need to know the pin value, only if a pin is being
used.
2023-08-04 10:57:07 -04:00
Dan Streetman 75de375aaf tpm2: declare tpm2_log_debug_*() functions in tpm2_util.h
Allow other code to use the log debug functions; e.g. they are useful in test
code.
2023-08-04 10:57:07 -04:00
Dan Streetman e00f46ac7f tpm2: move declared functions in header lower down
Move some function declarations lower down, below the Tpm2Context and
Tpm2Handle typedefs; later commits will reference the typedefs in some of the
functions, so the typedefs need to come first in the header.

This only moves the declarations, none of the declarations are modified.
2023-08-04 10:57:07 -04:00
Dan Streetman 323eb4803a tpm2: add Tpm2PCRValue struct and associated functions
Add a new struct that can represent a PCR index, hash, and value all
together. This replaces code (e.g. the tpm2_pcr_read() parameters) that
required using both a TPML_PCR_SELECTION as well as array of TPM2B_DIGEST
entries, which was difficult to correlate the selection hash/index to each
digest.
2023-08-04 10:57:05 -04:00
Dan Streetman 13b551744b tpm2: add more helper functions for managing TPML_PCR_SELECTION and TPMS_PCR_SELECTION
Add more functions to help manage these objects.
2023-08-04 10:55:53 -04:00
Dan Streetman dbaae766c7 tpm2: change tpm2_tpm*_pcr_selection_to_mask() to return mask
This simplifies use of the functions, as well as avoiding the use of -ENOENT
from tpm2_tpml_pcr_selection_to_mask().
2023-08-04 10:55:53 -04:00
Dan Streetman c9df1fb119 tpm2: add tpm2_hash_alg_to_size()
Add function to get the hash size for a hash algorithm
2023-08-04 10:55:53 -04:00
Dan Streetman 240774f5ce tpm2: add debug logging to functions converting hash or asym algs to/from strings or ids
Add debug log message if the algorithm name or id is not known.
2023-08-04 10:55:53 -04:00
Dan Streetman aff853f8ea tpm2: use CreatePrimary() to create primary keys instead of Create()
Older versions used CreatePrimary() to create a transient primary key to use
when creating a sealed data object. That was changed in v254 to use Create()
instead, which should result in the same transient key, but it seems some
hardware TPMs refuse to allow using Create() to generate primary keys.

This reverts to using CreatePrimary() to create primary key.

Fixes: #28654
2023-08-04 10:13:27 +01:00
Mike Yuan 07bd7b3868 Merge pull request #28648 from yuwata/shutdown-skip-recursive-mount-run
shutdown: several fixlets
2023-08-04 12:45:32 +08:00
OMOJOLA JOSHUA fc7eb1325b Add tool to display emergency log message full-screen on boot failure. 2023-08-04 00:24:54 +01:00
Yu Watanabe 2159662608 switch-root: reopen target directory after it is mounted
Fixes a bug introduced by f717d7a40a.
2023-08-04 04:05:21 +09:00
Yu Watanabe 6b219b74de shutdown: do not umount recursively before MS_MOVE
Unmounting filesystem will be done gracefully by shutdown itself.

Follow-up for f2c1d491a5 and
268d1244e8.
2023-08-04 03:58:10 +09:00
Daan De Meyer 1f1efbbf55 Merge pull request #28632 from DaanDeMeyer/repart-synthesize
repart: Add --copy-from option
2023-08-03 13:49:31 +02:00
Khem Raj ac8db36cbc include missing sys/file.h for LOCK_EX 2023-08-02 14:45:27 -07:00
Frantisek Sumsal b456f2266a varlink: allocate the buffer for varlink FDs on the heap
Since it's ~16K, which might cause issues in environments with limited
stack space.

Resolves: #28635
2023-08-02 22:03:46 +01:00
Daan De Meyer 2d9b3468b2 sysupdate: Move fdisk partition flags helpers to fdisk-util.c 2023-08-01 22:32:38 +02:00
Daan De Meyer 77c6add182 creds-util: Add read_credential_bool() 2023-08-01 07:53:34 +02:00
Yu Watanabe 2668d040c1 fstab-util: use pointer returned by startswith() 2023-08-01 02:12:29 +09:00
Yu Watanabe c0af9dee0d udev: move declaration of ResolveNameTiming to udev-rules.c
It is only used by udevd and udevadm, not necessary in src/shared.

This also moves UDEV_NAME_SIZE and friends.
2023-07-31 23:23:00 +09:00
Yu Watanabe 04a1ee5867 udev: move udev_parse_config_full() to udevd.c
Then, rename it to manager_parse_udev_config().

No functional change, just refactoring.
2023-07-31 23:23:00 +09:00