]> err.no Git - yubikey-personalization/commitdiff
fixup logic for import with targetConfig
authorKlas Lindfors <klas@yubico.com>
Thu, 2 May 2013 13:38:59 +0000 (15:38 +0200)
committerKlas Lindfors <klas@yubico.com>
Thu, 2 May 2013 13:38:59 +0000 (15:38 +0200)
ykpers-json.c

index 232f7d5f874f6b7a2a176d172124153ce5071e2a..9e683c9a737b40dcdd49a396630438df345b3ad2 100644 (file)
@@ -199,12 +199,18 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
                jtarget = json_object_object_get(yprod_json, "targetConfig");
                if(jtarget) {
                        int target_config = json_object_get_int(jtarget);
-                       if(target_config == 1 &&
-                                       cfg->command != SLOT_CONFIG) {
+                       int command;
+                       if(target_config == 1) {
+                               command = SLOT_CONFIG;
+                       } else if(target_config == 2) {
+                               command = SLOT_CONFIG2;
+                       } else {
                                ykp_errno = YKP_EINVAL;
                                goto out;
-                       } else if(target_config == 2 &&
-                                       cfg->command != SLOT_CONFIG2) {
+                       }
+                       if(ykp_command(cfg) == 0) {
+                               ykp_configure_command(cfg, command);
+                       } else if(ykp_command(cfg) != command) {
                                ykp_errno = YKP_EINVAL;
                                goto out;
                        }