Browse Source

gfsec-split: Add the restore/destroy-cmd options.

These options allow to specify the RESTORE and DESTROY commands
to write to the configuration file, to be later used by gfsec-use.
master
Damien Goutte-Gattat 4 years ago
parent
commit
2b002f596c
  1. 18
      src/gfsec-split.c
  2. 7
      src/secretcfg.c

18
src/gfsec-split.c

@ -69,7 +69,11 @@ Split the specified file for later use with gfsec-use.\n"));
-o, --output FILE Specify the location where the file will\n\
be reconstructed by gfsec-use. The default\n\
is to reconstruct the file at its original\n\
location.\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"));
puts(_("\
-l, --list-supports List available supports and exit.\n"));
@ -259,6 +263,8 @@ main(int argc, char **argv)
{ "config", 1, NULL, 'c' },
{ "keep", 0, NULL, 'k' },
{ "output", 1, NULL, 'o' },
{ "restore-cmd", 1, NULL, 'r' },
{ "destroy-cmd", 1, NULL, 'd' },
{ "list-supports", 0, NULL, 'l' },
{ NULL, 0, NULL, 0 }
};
@ -276,7 +282,7 @@ main(int argc, char **argv)
cfg = gfsec_secret_new();
while ( (c = getopt_long(argc, argv, "hvn:s:ic:ko:l",
while ( (c = getopt_long(argc, argv, "hvn:s:ic:ko:r:d:l",
options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
@ -316,6 +322,14 @@ main(int argc, char **argv)
output_file = optarg;
break;
case 'r':
cfg->restore = xstrdup(optarg);
break;
case 'd':
cfg->destroy = xstrdup(optarg);
break;
case 'l':
list_mode = 1;
break;

7
src/secretcfg.c

@ -411,6 +411,13 @@ gfsec_write_config(gfsec_secret_t *cfg, const char *filename)
if ( cfg->filename )
fprintf(f, "OUTFILE=%s\n", cfg->filename);
if ( cfg->restore )
fprintf(f, "RESTORE=%s\n", cfg->restore);
if ( cfg->destroy )
fprintf(f, "DESTROY=%s\n", cfg->destroy);
fprintf(f, "MINSHARES=%u\n", cfg->threshold);
for ( n = 0; n < cfg->n_shares; n++ ) {

Loading…
Cancel
Save