generator: Rename password arg

This function does not expect a password, but a key file path. The
cryptsetup helper binary even calls it that.

No Code changes.

Follow up on: 6e41f4dd91
Fixes: https://github.com/systemd/systemd/security/code-scanning/81
This commit is contained in:
Jan Janssen
2022-02-19 10:15:38 +01:00
committed by Zbigniew Jędrzejewski-Szmek
parent 915e2786f4
commit b7de9651db
3 changed files with 18 additions and 18 deletions
+10 -10
View File
@@ -277,7 +277,7 @@ static int print_dependencies(FILE *f, const char* device_path) {
static int create_disk(
const char *name,
const char *device,
const char *password,
const char *key_file,
const char *keydev,
const char *headerdev,
const char *options,
@@ -285,7 +285,7 @@ static int create_disk(
_cleanup_free_ char *n = NULL, *d = NULL, *u = NULL, *e = NULL,
*keydev_mount = NULL, *keyfile_timeout_value = NULL,
*filtered = NULL, *u_escaped = NULL, *name_escaped = NULL, *header_path = NULL, *password_buffer = NULL,
*filtered = NULL, *u_escaped = NULL, *name_escaped = NULL, *header_path = NULL, *key_file_buffer = NULL,
*tmp_fstype = NULL, *filtered_header = NULL, *headerdev_mount = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *dmname;
@@ -350,9 +350,9 @@ static int create_disk(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
if (keydev && !password)
if (keydev && !key_file)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Key device is specified, but path to the password file is missing.");
"Key device is specified, but path to the key file is missing.");
r = generator_open_unit_file(arg_dest, NULL, n, &f);
if (r < 0)
@@ -388,11 +388,11 @@ static int create_disk(
if (r < 0)
return log_error_errno(r, "Failed to generate keydev umount unit: %m");
password_buffer = path_join(keydev_mount, password);
if (!password_buffer)
key_file_buffer = path_join(keydev_mount, key_file);
if (!key_file_buffer)
return log_oom();
password = password_buffer;
key_file = key_file_buffer;
fprintf(f, "After=%s\n", unit);
if (keyfile_can_timeout > 0)
@@ -462,8 +462,8 @@ static int create_disk(
"Before=%s\n",
netdev ? "remote-cryptsetup.target" : "cryptsetup.target");
if (password && !keydev) {
r = print_dependencies(f, password);
if (key_file && !keydev) {
r = print_dependencies(f, key_file);
if (r < 0)
return r;
}
@@ -495,7 +495,7 @@ static int create_disk(
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
r = generator_write_cryptsetup_service_section(f, name, u, password, filtered);
r = generator_write_cryptsetup_service_section(f, name, u, key_file, filtered);
if (r < 0)
return r;