From: Klas Lindfors Date: Wed, 17 Oct 2012 10:40:26 +0000 (+0200) Subject: don't use pre-constructed default structs and ykcore-lcl.h X-Git-Tag: v1.8.2~2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dd637910f6a14a060955b540d099296659abfb0;p=yubikey-personalization don't use pre-constructed default structs and ykcore-lcl.h use the set functions we provide to set up our defaults instead. --- diff --git a/ykpers-args.c b/ykpers-args.c index 123d662..f577cbc 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -37,7 +37,6 @@ #include #include -#include #include #include /* To get yubikey_modhex_encode and yubikey_hex_encode */ #include @@ -147,46 +146,6 @@ const char *usage = ; const char *optstring = "u12xa:c:n:t:hi:o:s:vy"; -static const YK_CONFIG default_config1 = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fixed */ - { 0, 0, 0, 0, 0, 0 }, /* uid */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* key */ - { 0, 0, 0, 0, 0, 0 }, /* accCode */ - 0, /* fixedSize */ - 0, /* extFlags */ - TKTFLAG_APPEND_CR, /* tktFlags */ - 0, /* cfgFlags */ - {0}, /* ctrOffs */ - 0 /* crc */ -}; - -static const YK_CONFIG default_config2 = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fixed */ - { 0, 0, 0, 0, 0, 0 }, /* uid */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* key */ - { 0, 0, 0, 0, 0, 0 }, /* accCode */ - 0, /* fixedSize */ - 0, /* extFlags */ - TKTFLAG_APPEND_CR, /* tktFlags */ - /* cfgFlags */ - CFGFLAG_STATIC_TICKET | CFGFLAG_STRONG_PW1 | CFGFLAG_STRONG_PW2 | CFGFLAG_MAN_UPDATE, - {0}, /* ctrOffs */ - 0 /* crc */ -}; - -static const YK_CONFIG default_update = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fixed */ - { 0, 0, 0, 0, 0, 0 }, /* uid */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* key */ - { 0, 0, 0, 0, 0, 0 }, /* accCode */ - 0, /* fixedSize */ - EXTFLAG_ALLOW_UPDATE, /* extFlags */ - TKTFLAG_APPEND_CR, /* tktFlags */ - 0, /* cfgFlags */ - {0}, /* ctrOffs */ - 0 /* crc */ -}; - static int _set_fixed(char *opt, YKP_CONFIG *cfg); static int _format_decimal_as_hex(uint8_t *dst, size_t dst_len, uint8_t *src); static int _format_oath_id(uint8_t *dst, size_t dst_len, uint8_t vendor, uint8_t type, uint32_t mui); @@ -352,8 +311,9 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, *exit_code = 1; return 0; } + ykp_set_tktflag_APPEND_CR(cfg, true); if (update_seen) { - memcpy(ycfg, &default_update, sizeof(default_update)); + ykp_set_extflag_ALLOW_UPDATE(cfg, true); if(c == '1') { command = SLOT_UPDATE1; } else if(c == '2') { @@ -361,10 +321,13 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, } } else if (c == '1') { command = SLOT_CONFIG; - memcpy(ycfg, &default_config1, sizeof(default_config1)); } else if (c == '2') { command = SLOT_CONFIG2; - memcpy(ycfg, &default_config2, sizeof(default_config2)); + ykp_set_cfgflag_STATIC_TICKET(cfg, true); + ykp_set_cfgflag_STRONG_PW1(cfg, true); + ykp_set_cfgflag_STRONG_PW2(cfg, true); + ykp_set_cfgflag_MAN_UPDATE(cfg, true); + } if (!ykp_configure_command(cfg, command)) return 0;