diff options
Diffstat (limited to 'src/cryptsetup/cryptsetup-generator.c')
-rw-r--r-- | src/cryptsetup/cryptsetup-generator.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index da16324599..3233e15f4e 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -30,6 +30,8 @@ #include "strv.h" #include "fileio.h" #include "path-util.h" +#include "dropin.h" +#include "generator.h" static const char *arg_dest = "/tmp"; static bool arg_enabled = true; @@ -73,7 +75,8 @@ static int create_disk( const char *password, const char *options) { - _cleanup_free_ char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *to = NULL, *e = NULL; + _cleanup_free_ char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *to = NULL, *e = NULL, + *filtered = NULL; _cleanup_fclose_ FILE *f = NULL; bool noauto, nofail, tmp, swap; char *from; @@ -172,6 +175,10 @@ static int create_disk( "RequiresMountsFor=%s\n", u); + r = generator_write_timeouts(arg_dest, device, name, options, &filtered); + if (r < 0) + return r; + fprintf(f, "\n[Service]\n" "Type=oneshot\n" @@ -179,7 +186,7 @@ static int create_disk( "TimeoutSec=0\n" /* the binary handles timeouts anyway */ "ExecStart=" SYSTEMD_CRYPTSETUP_PATH " attach '%s' '%s' '%s' '%s'\n" "ExecStop=" SYSTEMD_CRYPTSETUP_PATH " detach '%s'\n", - name, u, strempty(password), strempty(options), + name, u, strempty(password), strempty(filtered), name); if (tmp) @@ -239,17 +246,9 @@ static int create_disk( } if (!noauto && !nofail) { - - free(p); - p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf", NULL); - if (!p) - return log_oom(); - - mkdir_parents_label(p, 0755); - r = write_string_file(p, - "# Automatically generated by systemd-cryptsetup-generator\n\n" - "[Unit]\n" - "JobTimeoutSec=0\n"); /* the binary handles timeouts anyway */ + r = write_drop_in(arg_dest, name, 90, "device-timeout", + "# Automatically generated by systemd-cryptsetup-generator \n\n" + "[Unit]\nJobTimeoutSec=0"); if (r < 0) { log_error("Failed to write device drop-in: %s", strerror(-r)); return r; |