1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Revert "cryptsetup: support keyfile-timeout for using a device as the key file"

This reverts commit 64f0e53851.

On Wed, Dec 21, 2022 at 06:19:08PM +0100, Marius Schwarz wrote:
> That patch made things worse and is disfunctional for both, usb drive and
> password.
>
> No idea if more patches are needed, but this build does not unlock a drive
> at all, if usb is configured.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-12-22 17:30:53 +01:00
parent 64f0e53851
commit 253cc95c64
2 changed files with 8 additions and 21 deletions

View File

@ -232,8 +232,8 @@
<term><option>keyfile-timeout=</option></term>
<listitem><para> Specifies the timeout for the device on
which the key file resides or the device used as the key file,
and falls back to a password if it could not be accessed. See
which the key file resides and falls back to a password if
it could not be mounted. See
<citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
for key files on external devices.
</para></listitem>

View File

@ -227,11 +227,9 @@ static int generate_device_umount(const char *name,
return 0;
}
static int print_dependencies(FILE *f, const char* device_path, const char* timeout_value, bool canfail) {
static int print_dependencies(FILE *f, const char* device_path) {
int r;
assert(!canfail || timeout_value);
if (STR_IN_SET(device_path, "-", "none"))
/* None, nothing to do */
return 0;
@ -261,16 +259,9 @@ static int print_dependencies(FILE *f, const char* device_path, const char* time
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
fprintf(f, "After=%1$s\n", unit);
if (canfail) {
fprintf(f, "Wants=%1$s\n", unit);
r = write_drop_in_format(arg_dest, unit, 90, "device-timeout",
"# Automatically generated by systemd-cryptsetup-generator \n\n"
"[Unit]\nJobRunningTimeoutSec=%s", timeout_value);
if (r < 0)
return log_error_errno(r, "Failed to write device drop-in: %m");
} else
fprintf(f, "Requires=%1$s\n", unit);
fprintf(f,
"After=%1$s\n"
"Requires=%1$s\n", unit);
} else {
/* Regular file, add mount dependency */
_cleanup_free_ char *escaped_path = specifier_escape(device_path);
@ -472,18 +463,14 @@ static int create_disk(
netdev ? "remote-cryptsetup.target" : "cryptsetup.target");
if (key_file && !keydev) {
r = print_dependencies(f, key_file,
keyfile_timeout_value,
/* canfail= */ keyfile_can_timeout > 0);
r = print_dependencies(f, key_file);
if (r < 0)
return r;
}
/* Check if a header option was specified */
if (detached_header > 0 && !headerdev) {
r = print_dependencies(f, header_path,
NULL,
/* canfail= */ false); /* header is always necessary */
r = print_dependencies(f, header_path);
if (r < 0)
return r;
}