@@ -281,7 +281,7 @@ line_worker(char *line, const char *cachefile)
281
281
282
282
if (strcmp (p_encroot , "-" ) != 0 ) {
283
283
char * keyloadunit =
284
- systemd_escape (p_encroot , "zfs-load-key- " , ".service" );
284
+ systemd_escape (p_encroot , "zfs-load-key@ " , ".service" );
285
285
286
286
if (strcmp (dataset , p_encroot ) == 0 ) {
287
287
const char * keymountdep = NULL ;
@@ -360,33 +360,27 @@ line_worker(char *line, const char *cachefile)
360
360
"# dataset is a parent of the root filesystem.\n"
361
361
"StandardOutput=null\n"
362
362
"StandardError=null\n"
363
- "ExecStart=/bin/sh -c '"
364
- "set -eu;"
365
- "keystatus=\"$$(" ZFS " get -H -o value keystatus \"%s\")\";"
366
- "[ \"$$keystatus\" = \"unavailable\" ] || exit 0;" ,
363
+ "ExecStart=/bin/sh -euc '"
364
+ "[ \"$$(" ZFS " get -H -o value keystatus \"%s\")\" = \"unavailable\" ] || exit 0;" ,
367
365
dataset );
368
366
if (is_prompt )
369
367
fprintf (keyloadunit_f ,
370
- "count=0;"
371
- "while [ $$count -lt 3 ]; do "
368
+ "for i in 1 2 3; do "
372
369
"systemd-ask-password --id=\"zfs:%s\" \"Enter passphrase for %s:\" |"
373
370
"" ZFS " load-key \"%s\" && exit 0;"
374
- "count=$$((count + 1));"
375
371
"done;"
376
372
"exit 1" ,
377
373
dataset , dataset , dataset );
378
374
else
379
375
fprintf (keyloadunit_f ,
380
- "" ZFS " load-key \"%s\"" ,
376
+ "exec " ZFS " load-key \"%s\"" ,
381
377
dataset );
382
378
383
379
fprintf (keyloadunit_f ,
384
380
"'\n"
385
- "ExecStop=/bin/sh -c '"
386
- "set -eu;"
387
- "keystatus=\"$$(" ZFS " get -H -o value keystatus \"%s\")\";"
388
- "[ \"$$keystatus\" = \"available\" ] || exit 0;"
389
- "" ZFS " unload-key \"%s\""
381
+ "ExecStop=/bin/sh -euc '"
382
+ "[ \"$$(" ZFS " get -H -o value keystatus \"%s\")\" = \"available\" ] || exit 0;"
383
+ "exec " ZFS " unload-key \"%s\""
390
384
"'\n" ,
391
385
dataset , dataset );
392
386
/* END CSTYLED */
0 commit comments