mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
cryptsetup-generator: auto add deps for device as password
If the password is a device file, we can add Requires/After dependencies on the device rather than requiring the user to do so.
This commit is contained in:
parent
2ba110900a
commit
66a5dbdf28
@ -130,11 +130,21 @@ static int create_disk(
|
||||
streq(password, "/dev/random") ||
|
||||
streq(password, "/dev/hw_random"))
|
||||
fputs("After=systemd-random-seed.service\n", f);
|
||||
else if (!streq(password, "-") &&
|
||||
!streq(password, "none"))
|
||||
fprintf(f,
|
||||
"RequiresMountsFor=%s\n",
|
||||
password);
|
||||
|
||||
else if (!streq(password, "-") && !streq(password, "none")) {
|
||||
_cleanup_free_ char *uu = fstab_node_to_udev_node(password);
|
||||
if (uu == NULL)
|
||||
return log_oom();
|
||||
|
||||
if (is_device_path(uu)) {
|
||||
_cleanup_free_ char *dd = unit_name_from_path(uu, ".device");
|
||||
if (dd == NULL)
|
||||
return log_oom();
|
||||
|
||||
fprintf(f, "After=%1$s\nRequires=%1$s\n", dd);
|
||||
} else
|
||||
fprintf(f, "RequiresMountsFor=%s\n", password);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_device_path(u))
|
||||
|
Loading…
x
Reference in New Issue
Block a user