veritysetup: automatically generate unit name, instead of hardcoding it
This commit is contained in:
@@ -22,9 +22,6 @@
|
||||
#include "string-util.h"
|
||||
#include "unit-name.h"
|
||||
|
||||
#define SYSTEMD_VERITYSETUP_SERVICE_ROOT "systemd-veritysetup@root.service"
|
||||
#define SYSTEMD_VERITYSETUP_SERVICE_USR "systemd-veritysetup@usr.service"
|
||||
|
||||
static const char *arg_dest = NULL;
|
||||
static bool arg_enabled = true;
|
||||
static bool arg_read_veritytab = true;
|
||||
@@ -49,7 +46,6 @@ STATIC_DESTRUCTOR_REGISTER(arg_usr_options, freep);
|
||||
|
||||
static int create_special_device(
|
||||
const char *name,
|
||||
const char *service,
|
||||
const char *roothash,
|
||||
const char *data_what,
|
||||
const char *hash_what,
|
||||
@@ -62,7 +58,6 @@ static int create_special_device(
|
||||
/* Creates a systemd-veritysetup@.service instance for the special kernel cmdline specified root + usr devices. */
|
||||
|
||||
assert(name);
|
||||
assert(service);
|
||||
|
||||
/* If all three pieces of information are missing, then verity is turned off */
|
||||
if (!roothash && !data_what && !hash_what)
|
||||
@@ -79,6 +74,11 @@ static int create_special_device(
|
||||
if (!roothash || !data_what || !hash_what)
|
||||
return -EINVAL;
|
||||
|
||||
_cleanup_free_ char *service = NULL;
|
||||
r = unit_name_build("systemd-veritysetup", name, ".service", &service);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to generate unit name: %m");
|
||||
|
||||
log_debug("Using %s verity data device %s, hash device %s, options %s, and hash %s.", name, data_what, hash_what, options, roothash);
|
||||
|
||||
u = fstab_node_to_udev_node(data_what);
|
||||
@@ -126,11 +126,11 @@ static int create_special_device(
|
||||
}
|
||||
|
||||
static int create_root_device(void) {
|
||||
return create_special_device("root", SYSTEMD_VERITYSETUP_SERVICE_ROOT, arg_root_hash, arg_root_data_what, arg_root_hash_what, arg_root_options);
|
||||
return create_special_device("root", arg_root_hash, arg_root_data_what, arg_root_hash_what, arg_root_options);
|
||||
}
|
||||
|
||||
static int create_usr_device(void) {
|
||||
return create_special_device("usr", SYSTEMD_VERITYSETUP_SERVICE_USR, arg_usr_hash, arg_usr_data_what, arg_usr_hash_what, arg_usr_options);
|
||||
return create_special_device("usr", arg_usr_hash, arg_usr_data_what, arg_usr_hash_what, arg_usr_options);
|
||||
}
|
||||
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
|
||||
Reference in New Issue
Block a user