From: Klas Lindfors Date: Thu, 2 May 2013 13:38:59 +0000 (+0200) Subject: fixup logic for import with targetConfig X-Git-Tag: v1.14.0~10 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9860e62f931ccbe5252e8f87d764dc58062f1b1e;p=yubikey-personalization fixup logic for import with targetConfig --- diff --git a/ykpers-json.c b/ykpers-json.c index 232f7d5..9e683c9 100644 --- a/ykpers-json.c +++ b/ykpers-json.c @@ -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; }