]> err.no Git - yubikey-personalization/commitdiff
add ykp_clear_config() for clearing all config flags
authorKlas Lindfors <klas@yubico.com>
Tue, 30 Apr 2013 11:31:19 +0000 (13:31 +0200)
committerKlas Lindfors <klas@yubico.com>
Tue, 30 Apr 2013 11:31:19 +0000 (13:31 +0200)
NEWS
configure.ac
libykpers-1.map
ykpers-args.c
ykpers-json.c
ykpers.c
ykpers.h
ykpersonalize.c

diff --git a/NEWS b/NEWS
index 36d7b5d2478e484940cb90f22dcd2f0661aac833..18a0eabf34b6a2477097d90907eab714ba2b3668 100644 (file)
--- 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)
 
index 5536073d391300d9d7585273077f25b134295247..e9c8a550d9a0eb7ea80ea88ffe93dd83b3dbefc4 100644 (file)
@@ -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])
index 2b32bdd0e469b9b43e7b52c66ea55b970a6b3e90..f080efa3f8c403f5d9d465128227e47953751ba2 100644 (file)
@@ -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;
index 7402d8fd57a434aeaa187b3eece06e333fb56291..b651a1bcb7b2d06a4ba4f266697bf0b0822ee6f6 100644 (file)
@@ -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;
                        }
index 5425f756e27664f66d20cf71f1a5409e56e2b142..d47f8f3c8a97c0eb96f54fc5096a8e7f7aebd167 100644 (file)
@@ -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;
index 1f83981bd2b2258d87de544ae3f9bd02699bb9fa..8ec394e0775ec47ce6addefdb455cfa113a19346 100644 (file)
--- 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;
index 3584e6737fd631e2d32433aa6c396e5d4dcd3504..0bab83cb0e1d6d4fe64fe150970a06ceecf468da 100644 (file)
--- 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),
index e4c3fb2618031486f998c00934e0ea6dce7871e8..0605542ddfe2f1ae942b0029163e67f3c061b3c6 100644 (file)
@@ -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))