Browse Source

Make sure to remove secret file after split

Commit b18609a, in which the syntax of the gfsec-split command was
changed, introduced a regression preventing the removal of the
original secret file once the shares have been generated. This is
because the code taking care of removing the file still assumed
the filename of the secret file was still the last argument of the
command line, which is not true anymore.

Incenp-bug-id: 4
master
Damien Goutte-Gattat 5 years ago
parent
commit
2b18a00f61
  1. 9
      src/gfsec-split.c

9
src/gfsec-split.c

@ -104,7 +104,7 @@ main(int argc, char **argv)
{
int c, list_mode;
unsigned threshold, keep_original;
char *config_path;
char *config_path, *secret_file;
gfsec_secret_t *cfg;
struct option options[] = {
@ -180,18 +180,19 @@ main(int argc, char **argv)
if ( optind >= argc )
errx(EXIT_FAILURE, "Missing secret file");
secret_file = argv[optind++];
if ( ! config_path ) {
char *base;
base = get_file_basename(argv[optind]);
base = get_file_basename(secret_file);
xasprintf(&config_path, "%s/gfsecret/%s.conf",
getenv("XDG_CONFIG_HOME"), base);
free(base);
}
if ( (c = gfsec_secret_set_secret_file(cfg, argv[optind++])) != 0 )
if ( (c = gfsec_secret_set_secret_file(cfg, secret_file)) != 0 )
errx(EXIT_FAILURE, "Cannot set secret: %s", gfsec_error_string(c));
while ( optind < argc ) {
@ -219,7 +220,7 @@ main(int argc, char **argv)
gfsec_secret_free(cfg);
if ( ! keep_original )
unlink(argv[optind]);
unlink(secret_file);
return EXIT_SUCCESS;
}

Loading…
Cancel
Save