Browse Source

Add -i, --interactive option to gfsec-split

This patch is the first step toward the implementation of an
interactive mode for gfsec-split, which will allow the user to
choose which external devices she want to create a share onto.
develop
Damien Goutte-Gattat 5 years ago
parent
commit
6e367eb3de
  1. 24
      src/gfsec-split.c

24
src/gfsec-split.c

@ -52,7 +52,8 @@ Split the specified file for later use with gfsec-use.\n");
-n, --threshold N Specify the minimal number of shares\n\
required to re-assemble the secret.\n\
Default is 2.\n\
-s, --share URI Add a share.\n");
-s, --share URI Add a share.\n\
-i, --interactive Prompt the user for share URIs.\n");
puts("\
-c, --config FILE Write configuration to the specified\n\
@ -85,6 +86,13 @@ See the COPYING file or <http://www.gnu.org/licenses/gpl.html>.\n\
exit(EXIT_SUCCESS);
}
static void
interactive_loop(gfsec_secret_t *cfg)
{
errno = ENOSYS;
err(EXIT_FAILURE, "Cannot enter interactive loop");
}
static unsigned
get_uinteger_or_die(const char *arg)
{
@ -102,7 +110,7 @@ get_uinteger_or_die(const char *arg)
int
main(int argc, char **argv)
{
int c, list_mode;
int c, list_mode, interactive;
unsigned threshold, keep_original;
char *config_path, *secret_file;
gfsec_secret_t *cfg;
@ -112,6 +120,7 @@ main(int argc, char **argv)
{ "version", 0, NULL, 'v' },
{ "treshold", 1, NULL, 'n' },
{ "share", 1, NULL, 's' },
{ "interactive", 0, NULL, 'i' },
{ "config", 1, NULL, 'c' },
{ "keep", 0, NULL, 'k' },
{ "list-supports", 0, NULL, 'l' },
@ -120,14 +129,14 @@ main(int argc, char **argv)
setprogname(argv[0]);
threshold = 2;
keep_original = list_mode = 0;
keep_original = list_mode = interactive = 0;
config_path = NULL;
srandom(time(NULL));
cfg = gfsec_secret_new();
while ( (c = getopt_long(argc, argv, "hvn:s:c:kl",
while ( (c = getopt_long(argc, argv, "hvn:s:ic:kl",
options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
@ -151,6 +160,10 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "Cannot add share: %s", gfsec_error_string(c));
break;
case 'i':
interactive = 1;
break;
case 'c':
config_path = optarg;
break;
@ -200,6 +213,9 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "Cannot add share: %s", gfsec_error_string(c));
}
if ( interactive )
interactive_loop(cfg);
if ( (c = gfsec_secret_split(cfg, threshold)) != 0 )
errx(EXIT_FAILURE, "Cannot split secret: %s", gfsec_error_string(c));

Loading…
Cancel
Save