From: Klas Lindfors Date: Wed, 11 Apr 2012 08:49:10 +0000 (+0200) Subject: rules for combinations with -n X-Git-Tag: v1.7.0~1^2~36 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1348ea90142bb2b3ac542343b5c78ea1a56dcd41;p=yubikey-personalization rules for combinations with -n --- diff --git a/ykpers-args.c b/ykpers-args.c index 5ff61a6..4b64899 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -301,16 +301,21 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, switch (c) { case 'u': - if(slot_chosen) { + if (slot_chosen) { fprintf(stderr, "You must use update before slot (-1 / -2).\n"); *exit_code = 1; return 0; } - if(swap_seen) { + if (swap_seen) { fprintf(stderr, "Update (-u) and swap (-x) can't be combined.\n"); *exit_code = 1; return 0; } + if (ndef_seen) { + fprintf(stderr, "Update (-u) can not be combined with ndef (-n).\n"); + *exit_code = 1; + return 0; + } update_seen = true; break; case '1': @@ -330,6 +335,11 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, *exit_code = 1; return 0; } + if (ndef_seen) { + fprintf(stderr, "Slot (-1 / -2) can not be combined with ndef (-n)\n"); + *exit_code = 1; + return 0; + } int command; if (update_seen) { memcpy(ycfg, &default_update, sizeof(default_update)); @@ -366,6 +376,11 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, *exit_code = 1; return 0; } + if (ndef_seen) { + fprintf(stderr, "Swap (-x) can not be combined with ndef (-n).\n"); + *exit_code = 1; + return 0; + } if (!ykp_configure_command(cfg, SLOT_SWAP)) { return 0; } @@ -401,7 +416,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, break; } case 'n': - if (slot_chosen || swap_seen || update_seen) { + if (slot_chosen || swap_seen || update_seen || option_seen) { fprintf(stderr, "Ndef (-n) must be used on it's own.\n"); *exit_code = 1; return 0;