]> err.no Git - yubikey-personalization/commitdiff
rules for combinations with -n
authorKlas Lindfors <klas@yubico.com>
Wed, 11 Apr 2012 08:49:10 +0000 (10:49 +0200)
committerKlas Lindfors <klas@yubico.com>
Wed, 11 Apr 2012 08:49:10 +0000 (10:49 +0200)
ykpers-args.c

index 5ff61a658d971b74341c102ee018387cbf255391..4b64899254922f25f95ffb6afa23cce6f468e82b 100644 (file)
@@ -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;