Browse Source

Change gfsec-split syntax

Do not use a -s option to specify share URIs; share URIs are
mandatory and should be specified instead as positional arguments.
develop
Damien Goutte-Gattat 5 years ago
parent
commit
b18609ac43
  1. 24
      src/gfsec-split.c

24
src/gfsec-split.c

@ -41,7 +41,7 @@
static void
usage(int status)
{
puts("Usage: gfsec-split [options] file\n\
puts("Usage: gfsec-split [options] file uri...\n\
Split the specified file for later use with gfsec-use.\n");
puts("Options:\n\
@ -51,8 +51,7 @@ Split the specified file for later use with gfsec-use.\n");
puts("\
-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");
Default is 2.\n");
puts("\
-c, --config FILE Write configuration to the specified\n\
@ -111,7 +110,6 @@ main(int argc, char **argv)
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ "treshold", 1, NULL, 'n' },
{ "share", 1, NULL, 's' },
{ "config", 1, NULL, 'c' },
{ "keep", 0, NULL, 'k' },
{ "list-supports", 0, NULL, 'l' },
@ -125,9 +123,7 @@ main(int argc, char **argv)
srandom(time(NULL));
cfg = gfsec_secret_new();
while ( (c = getopt_long(argc, argv, "hvn:s:c:kl",
while ( (c = getopt_long(argc, argv, "hvn:c:kl",
options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
@ -146,11 +142,6 @@ main(int argc, char **argv)
threshold = get_uinteger_or_die(optarg);
break;
case 's':
if ( (c = gfsec_parse_uri(optarg, cfg, 1)) != 0 )
errx(EXIT_FAILURE, "Cannot add share: %s", gfsec_error_string(c));
break;
case 'c':
config_path = optarg;
break;
@ -191,9 +182,16 @@ main(int argc, char **argv)
free(base);
}
if ( (c = gfsec_secret_set_secret_file(cfg, argv[optind])) != 0 )
cfg = gfsec_secret_new();
if ( (c = gfsec_secret_set_secret_file(cfg, argv[optind++])) != 0 )
errx(EXIT_FAILURE, "Cannot set secret: %s", gfsec_error_string(c));
while ( optind < argc ) {
if ( (c = gfsec_parse_uri(argv[optind++], cfg, 1)) != 0 )
errx(EXIT_FAILURE, "Cannot add share: %s", gfsec_error_string(c));
}
if ( (c = gfsec_secret_split(cfg, threshold)) != 0 )
errx(EXIT_FAILURE, "Cannot split secret: %s", gfsec_error_string(c));

Loading…
Cancel
Save