From: Klas Lindfors Date: Tue, 30 Apr 2013 11:31:19 +0000 (+0200) Subject: add ykp_clear_config() for clearing all config flags X-Git-Tag: v1.14.0~15 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85078db234c74259e116714718ffb3f0dd64b9fa;p=yubikey-personalization add ykp_clear_config() for clearing all config flags --- diff --git a/NEWS b/NEWS index 36d7b5d..18a0eab 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ Yubikey-personalize NEWS -- History of user-visible changes. -*- outline -*- -* Version 1.13.1 (unreleased) +* Version 1.14.0 (unreleased) * Version 1.13.0 (released 2013-04-22) diff --git a/configure.ac b/configure.ac index 5536073..e9c8a55 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -AC_INIT([yubikey-personalization], [1.13.1], +AC_INIT([yubikey-personalization], [1.14.0], [yubico-devel@googlegroups.com], [ykpers], [http://code.google.com/p/yubikey-personalization/]) AC_CONFIG_AUX_DIR([build-aux]) @@ -36,9 +36,9 @@ AC_CONFIG_MACRO_DIR([m4]) # Interfaces changed/added/removed: CURRENT++ REVISION=0 # Interfaces added: AGE++ # Interfaces removed: AGE=0 -AC_SUBST(LT_CURRENT, 14) -AC_SUBST(LT_REVISION, 1) -AC_SUBST(LT_AGE, 13) +AC_SUBST(LT_CURRENT, 15) +AC_SUBST(LT_REVISION, 0) +AC_SUBST(LT_AGE, 14) AM_INIT_AUTOMAKE([1.11.3 -Wall -Werror]) AM_SILENT_RULES([yes]) diff --git a/libykpers-1.map b/libykpers-1.map index 2b32bdd..f080efa 100644 --- a/libykpers-1.map +++ b/libykpers-1.map @@ -198,3 +198,10 @@ LIBYKPERS_1.13 { ykp_import_config; # Variables: } LIBYKPERS_1.12; + +LIBYKPERS_1.14 { + global: +# Functions: + ykp_clear_config; +# Variables: +} LIBYKPERS_1.13; diff --git a/ykpers-args.c b/ykpers-args.c index 7402d8f..b651a1b 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -278,9 +278,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, * we reset them here and, as a consequence of that, require the * mode choosing options to be specified before any other. */ - ycfg->tktFlags = 0; - ycfg->cfgFlags = 0; - ycfg->extFlags = 0; + ykp_clear_config(cfg); mode_chosen = 1; } diff --git a/ykpers-json.c b/ykpers-json.c index 5425f75..d47f8f3 100644 --- a/ykpers-json.c +++ b/ykpers-json.c @@ -190,11 +190,6 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) { const char *raw_mode; int mode = MODE_OTP_YUBICO; struct map_st *p; - YK_CONFIG ycfg; - - ycfg.tktFlags = 0; - ycfg.extFlags = 0; - ycfg.cfgFlags = 0; if(!jobj || !yprod_json || !jmode || !options) { ykp_errno = YKP_EINVAL; diff --git a/ykpers.c b/ykpers.c index 1f83981..8ec394e 100644 --- a/ykpers.c +++ b/ykpers.c @@ -143,6 +143,17 @@ int ykp_free_config(YKP_CONFIG *cfg) return 0; } +int ykp_clear_config(YKP_CONFIG *cfg) +{ + if(cfg) { + cfg->ykcore_config.tktFlags = 0; + cfg->ykcore_config.cfgFlags = 0; + cfg->ykcore_config.extFlags = 0; + return 1; + } + return 0; +} + void ykp_configure_version(YKP_CONFIG *cfg, YK_STATUS *st) { cfg->yk_major_version = st->versionMajor; diff --git a/ykpers.h b/ykpers.h index 3584e67..0bab83c 100644 --- a/ykpers.h +++ b/ykpers.h @@ -124,6 +124,8 @@ int ykp_set_extflag_ALLOW_UPDATE (YKP_CONFIG *cfg, bool state); int ykp_set_extflag_DORMANT (YKP_CONFIG *cfg, bool state); int ykp_set_extflag_LED_INV (YKP_CONFIG *cfg, bool state); +int ykp_clear_config(YKP_CONFIG *cfg); + int ykp_write_config(const YKP_CONFIG *cfg, int (*writer)(const char *buf, size_t count, void *userdata), diff --git a/ykpersonalize.c b/ykpersonalize.c index e4c3fb2..0605542 100644 --- a/ykpersonalize.c +++ b/ykpersonalize.c @@ -176,6 +176,8 @@ int main(int argc, char **argv) } if (inf) { + if(!ykp_clear_config(cfg)) + goto err; if(!fread(data, 1, 1024, inf)) goto err; if (!ykp_import_config(cfg, data, strlen(data), data_format))