From: Klas Lindfors Date: Mon, 15 Apr 2013 06:44:21 +0000 (+0200) Subject: add MODE_ALL instead of letting 0 mean all X-Git-Tag: v1.13.0~41 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ee055eb309f4031529c2cd41c7e173f7e5800fa;p=yubikey-personalization add MODE_ALL instead of letting 0 mean all --- diff --git a/ykpers-json.c b/ykpers-json.c index d114464..dc5c569 100644 --- a/ykpers-json.c +++ b/ykpers-json.c @@ -127,7 +127,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) { if(!p->json_text) { continue; } - if(!p->mode || (p->mode && (mode & p->mode) == mode)) { + if(p->mode && (mode & p->mode) == mode) { int set = (ycfg.tktFlags & p->flag) == p->flag; json_object *jsetting = json_object_new_boolean(set); json_object_object_add(options_json, p->json_text, jsetting); @@ -138,7 +138,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) { if(!p->json_text) { continue; } - if(!p->mode || (p->mode && (mode & p->mode) == mode)) { + if(p->mode && (mode & p->mode) == mode) { int set = (ycfg.cfgFlags & p->flag) == p->flag; json_object *jsetting = json_object_new_boolean(set); json_object_object_add(options_json, p->json_text, jsetting); @@ -149,7 +149,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) { if(!p->json_text) { continue; } - if(!p->mode || (p->mode && (mode & p->mode) == mode)) { + if(p->mode && (mode & p->mode) == mode) { int set = (ycfg.extFlags & p->flag) == p->flag; json_object *jsetting = json_object_new_boolean(set); json_object_object_add(options_json, p->json_text, jsetting); diff --git a/ykpers.c b/ykpers.c index bd8233d..61fc16b 100644 --- a/ykpers.c +++ b/ykpers.c @@ -941,7 +941,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len for (p = _ticket_flags_map; p->flag; p++) { if ((ycfg.tktFlags & p->flag) == p->flag && p->capability(cfg) - && (!p->mode || (mode & p->mode) == mode)) { + && (mode & p->mode) == mode) { if (*buffer) { strcat(buffer, str_flags_separator); strcat(buffer, p->flag_text); @@ -958,7 +958,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len for (p = _config_flags_map; p->flag; p++) { if ((t_flags & p->flag) == p->flag && p->capability(cfg) - && (!p->mode || (mode & p->mode) == mode)) { + && (mode & p->mode) == mode) { if (*buffer) { strcat(buffer, str_flags_separator); strcat(buffer, p->flag_text); @@ -978,7 +978,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len for (p = _extended_flags_map; p->flag; p++) { if ((ycfg.extFlags & p->flag) == p->flag && p->capability(cfg) - && (!p->mode || (mode & p->mode) == mode)) { + && (mode & p->mode) == mode) { if (*buffer) { strcat(buffer, str_flags_separator); strcat(buffer, p->flag_text); diff --git a/ykpers_lcl.c b/ykpers_lcl.c index 4b2f13a..b361d95 100644 --- a/ykpers_lcl.c +++ b/ykpers_lcl.c @@ -37,7 +37,7 @@ struct map_st _ticket_flags_map[] = { { TKTFLAG_APPEND_DELAY1,"APPEND_DELAY1","appendDelay1", capability_has_ticket_mods, MODE_OUTPUT }, /* XXX: name? */ { TKTFLAG_APPEND_DELAY2,"APPEND_DELAY2","appendDelay2", capability_has_ticket_mods, MODE_OUTPUT }, /* XXX: name? */ { TKTFLAG_APPEND_CR, "APPEND_CR", "appendCR", capability_has_ticket_mods, MODE_OUTPUT }, - { TKTFLAG_PROTECT_CFG2, "PROTEXT_CFG2", "protectSecond",capability_has_slot_two, 0 }, + { TKTFLAG_PROTECT_CFG2, "PROTEXT_CFG2", "protectSecond",capability_has_slot_two, MODE_ALL }, { TKTFLAG_OATH_HOTP, "OATH_HOTP", 0, capability_has_oath, MODE_OATH_HOTP }, { TKTFLAG_CHAL_RESP, "CHAL_RESP", 0, capability_has_chal_resp, MODE_CHAL_RESP }, { 0, 0, 0, 0, 0 } @@ -65,14 +65,14 @@ struct map_st _config_flags_map[] = { }; struct map_st _extended_flags_map[] = { - { EXTFLAG_SERIAL_BTN_VISIBLE, "SERIAL_BTN_VISIBLE", "serialBtnVisible", capability_has_serial, 0 }, - { EXTFLAG_SERIAL_USB_VISIBLE, "SERIAL_USB_VISIBLE", "serialUsbVisible", capability_has_serial, 0 }, - { EXTFLAG_SERIAL_API_VISIBLE, "SERIAL_API_VISIBLE", "serialApiVisible", capability_has_serial_api, 0 }, - { EXTFLAG_USE_NUMERIC_KEYPAD, "USE_NUMERIC_KEYPAD", "useNumericKeypad", capability_has_numeric, 0 }, - { EXTFLAG_FAST_TRIG, "FAST_TRIG", "fastTrig", capability_has_fast, 0 }, - { EXTFLAG_ALLOW_UPDATE, "ALLOW_UPDATE", "allowUpdate", capability_has_update, 0 }, - { EXTFLAG_DORMANT, "DORMANT", "dormant", capability_has_dormant, 0 }, - { EXTFLAG_LED_INV, "LED_INV", "ledInverted", capability_has_led_inv, 0 }, + { EXTFLAG_SERIAL_BTN_VISIBLE, "SERIAL_BTN_VISIBLE", "serialBtnVisible", capability_has_serial, MODE_ALL }, + { EXTFLAG_SERIAL_USB_VISIBLE, "SERIAL_USB_VISIBLE", "serialUsbVisible", capability_has_serial, MODE_ALL }, + { EXTFLAG_SERIAL_API_VISIBLE, "SERIAL_API_VISIBLE", "serialApiVisible", capability_has_serial_api, MODE_ALL }, + { EXTFLAG_USE_NUMERIC_KEYPAD, "USE_NUMERIC_KEYPAD", "useNumericKeypad", capability_has_numeric, MODE_ALL }, + { EXTFLAG_FAST_TRIG, "FAST_TRIG", "fastTrig", capability_has_fast, MODE_ALL }, + { EXTFLAG_ALLOW_UPDATE, "ALLOW_UPDATE", "allowUpdate", capability_has_update, MODE_ALL }, + { EXTFLAG_DORMANT, "DORMANT", "dormant", capability_has_dormant, MODE_ALL }, + { EXTFLAG_LED_INV, "LED_INV", "ledInverted", capability_has_led_inv, MODE_ALL }, { 0, 0, 0, 0, 0 } }; diff --git a/ykpers_lcl.h b/ykpers_lcl.h index d51922c..fd531c4 100644 --- a/ykpers_lcl.h +++ b/ykpers_lcl.h @@ -85,6 +85,7 @@ extern struct map_st _modes_map[]; #define MODE_CHAL_RESP MODE_CHAL_YUBICO | MODE_CHAL_HMAC #define MODE_OUTPUT MODE_STATIC_TICKET | MODE_OTP_YUBICO | MODE_OATH_HOTP +#define MODE_ALL 0xff # ifdef __cplusplus }