]> err.no Git - yubikey-personalization.old/commitdiff
Stop bailing out on unknown firmwares
authorTollef Fog Heen <tfheen@gmail.com>
Thu, 28 Jan 2010 22:43:09 +0000 (22:43 +0000)
committerTollef Fog Heen <tfheen@gmail.com>
Thu, 28 Jan 2010 22:43:09 +0000 (22:43 +0000)
Previously, we would bail out if we saw an unsupported firmware.  Stop
doing that and instead write out a warning message saying not all
features might be supported.

configure.ac
libykpers-1.map
ykcore/ykcore.c
ykcore/ykcore.h
ykpersonalize.c

index b20ae7047c728e64b0544d3757bb89471aeea778..6d9df4d0c644955abdb5d40dbd7ae0d415398efc 100644 (file)
@@ -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, 1)
-AC_SUBST(LT_REVISION, 7)
-AC_SUBST(LT_AGE, 0)
+AC_SUBST(LT_CURRENT, 2)
+AC_SUBST(LT_REVISION, 0)
+AC_SUBST(LT_AGE, 1)
 
 AM_INIT_AUTOMAKE([-Wall -Werror])
 AC_PROG_CC
index f7c84433451e3bbe7f09570686add8e05e19ba32..2f07de596262d44dd458b59cbcd4f02080a005f6 100644 (file)
@@ -29,6 +29,7 @@
 LIBYKPERS_1.0 {
   global:
 # Functions:
+    yk_check_firmware_version;
     yk_close_key;
     yk_endian_swap_16;
     yk_force_key_update;
index 1f611068b747da57275ceaec296837123caec5e1..36ffe7dbbe8c2e07a8f6827caef4eeb13e39b699 100644 (file)
@@ -62,19 +62,6 @@ YK_KEY *yk_open_first_key(void)
                        rc = yk_errno;
                        yk_close_key(yk);
                        yk = NULL;
-               } else {
-                       if (!((st.versionMajor == 1 &&
-                              (st.versionMinor == 0 ||
-                               st.versionMinor == 1 ||
-                               st.versionMinor == 2 ||
-                               st.versionMinor == 3)) ||
-                             (st.versionMajor == 2 &&
-                              (st.versionMinor == 0 ||
-                               st.versionMinor == 1)))) {
-                               rc = YK_EFIRMWARE;
-                               yk_close_key(yk);
-                               yk = NULL;
-                       }
                }
        }
        yk_errno = rc;
@@ -86,6 +73,26 @@ int yk_close_key(YK_KEY *yk)
        return _ykusb_close_device(yk);
 }
 
+int yk_check_firmware_version(YK_KEY *k)
+{
+       YK_STATUS st;
+
+       if (!yk_get_status(k, &st))
+               return 0;
+       if (!((st.versionMajor == 1 &&
+              (st.versionMinor == 0 ||
+               st.versionMinor == 1 ||
+               st.versionMinor == 2 ||
+               st.versionMinor == 3)) ||
+             (st.versionMajor == 2 &&
+              (st.versionMinor == 0 ||
+               st.versionMinor == 1)))) {
+               yk_errno = YK_EFIRMWARE;
+               return 0;
+       }
+       return 1;
+}
+
 int yk_get_status(YK_KEY *k, YK_STATUS *status)
 {
        unsigned int status_count = 0;
index 01f4fac076b5975d052c24f7bc47b317f9be7110..8468d86b78fe826beff0be8e141be349dc21cd02 100644 (file)
@@ -81,6 +81,8 @@ extern int yk_close_key(YK_KEY *k);           /* closes a previously opened key */
  ****/
 /* fetches key status into the structure given by `status' */
 extern int yk_get_status(YK_KEY *k, YK_STATUS *status /*, int forceUpdate */);
+/* checks that the firmware revision of the key is supported */
+extern int yk_check_firmware_version(YK_KEY *k);
 
 /*************************************************************************
  *
index effd8d08c6d7f7298db994db21e35fc69b492c25..06cc0973215de93f181ab427abe16f966636f3ba 100644 (file)
@@ -217,6 +217,15 @@ int main(int argc, char **argv)
        else
                printf("Unconfigured\n");
 
+       if (!(yk_check_firmware_version(yk))) {
+               if (yk_errno == YK_EFIRMWARE) {
+                       printf("Unsupported firmware revision - some "
+                              "features may not be available\n");
+               } else {
+                       goto err;
+               }
+       }
+
        if (!ykp_configure_for(cfg, 1, st))
                goto err;