Browse Source

gfsec-split: Call the delete command if specified.

If the user specified a delete command using --destroy-cmd option,
call that command at the end to delete the original secret.
master
Damien Goutte-Gattat 4 years ago
parent
commit
e4d59f2b63
  1. 19
      src/gfsec-split.c

19
src/gfsec-split.c

@ -70,10 +70,8 @@ Split the specified file for later use with gfsec-use.\n"));
be reconstructed by gfsec-use. The default\n\
is to reconstruct the file at its original\n\
location.\n\
-r, --restore-cmd CMD Specify the command that gfsec-use will\n\
call to restore the secret.\n\
-d, --destroy-cmd CMD Specify the command that gfsec-use will\n\
call to delete the secret.\n"));
-r, --restore-cmd CMD Specify the command to restore the secret.\n\
-d, --destroy-cmd CMD Specify the command to delete the secret.\n"));
puts(_("\
-l, --list-supports List available supports and exit.\n"));
@ -400,9 +398,18 @@ main(int argc, char **argv)
gfsec_secret_free(cfg);
if ( ! keep_original )
if ( ! keep_original ) {
if ( cfg->destroy ) {
int status;
status = system(cfg->destroy);
if ( ! WIFEXITED(status) )
errx(EXIT_FAILURE, _("Delete command terminated anormally"));
}
if ( unlink(secret_file) == -1 )
err(EXIT_FAILURE, _("Cannot delete original file"));
err(EXIT_FAILURE, _("Cannot delete original file"));
}
return EXIT_SUCCESS;
}

Loading…
Cancel
Save