瀏覽代碼

Pass the version number up.

Werner Koch 16 年之前
父節點
當前提交
8428e54961
共有 7 個文件被更改,包括 76 次插入8 次删除
  1. 12 0
      ChangeLog
  2. 3 1
      NEWS
  3. 1 1
      configure.ac
  4. 43 0
      src/agent.c
  5. 3 0
      src/agent.h
  6. 14 4
      src/p11-getslotinfo.c
  7. 0 2
      src/settings.h

+ 12 - 0
ChangeLog

@@ -1,5 +1,17 @@
 2009-06-19  Werner Koch  <wk@g10code.com>
 
+	Release 1.3.0.
+
+	* src/settings.h (SLOT_FIRMWARE_VERSION_MAJOR)
+	(SLOT_FIRMWARE_VERSION_MINOR, SLOT_HARDWARE_VERSION_MAJOR)
+	(SLOT_HARDWARE_VERSION_MINOR): Remove.
+	* src/p11-getslotinfo.c (CK_DEFINE_FUNCTION): Set firmware version
+	to Scute version and agent version to hardware version.
+	* src/agent.c (read_version_cb): New.
+	(agent_configure): Call that.
+	(agent_version_major, agent_version_minor): New.
+	(scute_agent_get_agent_version): New.
+
 	* src/agent.c (SIG_LEN_2): Fix stupid c+p bug.
 
 2009-06-19  Marcus Brinkmann  <marcus@g10code.de>

+ 3 - 1
NEWS

@@ -1,8 +1,10 @@
-Noteworthy changes in version 1.3.0 (unreleased)
+Noteworthy changes in version 1.3.0 (2009-06-19)
 ------------------------------------------------
 
  * Scute can read certificates directly from the OpenPGP 2.0 cards.
 
+ * Support for 2048 bit keys.
+
 
 Noteworthy changes in version 1.2.0 (2008-09-02)
 ------------------------------------------------

+ 1 - 1
configure.ac

@@ -47,7 +47,7 @@ min_automake_version="1.9.3"
 # running a "make distcheck".
 
 m4_define([my_version], [1.3.0])
-m4_define([my_issvn], [yes])
+m4_define([my_issvn], [no])
 
 m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))

+ 43 - 0
src/agent.c

@@ -58,6 +58,11 @@
 /* The global agent context.  */
 static assuan_context_t agent_ctx = NULL;
 
+/* The version number of the agent.  */
+static int agent_version_major;
+static int agent_version_minor;
+
+
 
 /* Hack required for Windows.  */
 void 
@@ -412,6 +417,26 @@ agent_simple_cmd (assuan_context_t ctx, const char *fmt, ...)
       
   return err;
 }
+
+
+/* Read and stroe the agent's version number.  */
+static gpg_error_t
+read_version_cb (void *opaque, const void *buffer, size_t length)
+{
+  char version[20];
+  const char *s;
+  
+  if (length > sizeof (version) -1)
+    length = sizeof (version) - 1;
+  strncpy (version, buffer, length);
+  version[length] = 0;
+
+  agent_version_major = atoi (version);
+  s = strchr (version, '.');
+  agent_version_minor = s? atoi (s+1) : 0;
+
+  return 0;
+}
   
 
 /* Configure the GPG agent at connection CTX.  */
@@ -517,6 +542,15 @@ agent_configure (assuan_context_t ctx)
   else if (err)
     return err;
 
+  err = assuan_transact (ctx, "GETINFO version",
+                         read_version_cb, NULL,
+                         NULL, NULL, NULL, NULL);
+  if (gpg_err_code (err) == GPG_ERR_UNKNOWN_OPTION)
+    err = 0;
+  else if (err)
+    return err;
+
+
   return err;
 }
 
@@ -546,6 +580,15 @@ scute_agent_initialize (void)
   return err;
 }
 
+
+int
+scute_agent_get_agent_version (int *minor)
+{
+  *minor = agent_version_minor;
+  return agent_version_major;
+}
+
+
 
 /* Return a new malloced string by unescaping the string S.  Escaping
    is percent escaping and '+'/space mapping.  A binary nul will

+ 3 - 0
src/agent.h

@@ -78,6 +78,9 @@ struct agent_card_info_s
    initial greeting.  */
 gpg_error_t scute_agent_initialize (void);
 
+/* Return the major and minor version of the agent.  */
+int scute_agent_get_agent_version (int *minor);
+
 /* Tear down the agent connection and release all associated
    resources.  */
 void scute_agent_finalize (void);

+ 14 - 4
src/p11-getslotinfo.c

@@ -31,6 +31,8 @@
 #include <config.h>
 #endif
 
+#include <string.h>
+
 #include "cryptoki.h"
 
 #include "locking.h"
@@ -44,6 +46,8 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetSlotInfo)
 {
   CK_RV err = CKR_OK;
   slot_iterator_t slot;
+  const char *s;
+  int minor;
 
   err = scute_global_lock ();
   if (err)
@@ -64,10 +68,16 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetSlotInfo)
   pInfo->flags = CKF_REMOVABLE_DEVICE | CKF_HW_SLOT;
   if (slot_token_present (slot))
     pInfo->flags |= CKF_TOKEN_PRESENT;
-  pInfo->hardwareVersion.major = SLOT_HARDWARE_VERSION_MAJOR;
-  pInfo->hardwareVersion.minor = SLOT_HARDWARE_VERSION_MINOR;
-  pInfo->firmwareVersion.major = SLOT_FIRMWARE_VERSION_MAJOR;
-  pInfo->firmwareVersion.minor = SLOT_FIRMWARE_VERSION_MINOR;
+
+  /* Use the gpg-agent version for the hardware version.. */
+  pInfo->hardwareVersion.major = scute_agent_get_agent_version (&minor);
+  pInfo->hardwareVersion.minor = minor;
+
+  /* Use Scute version as Firmware version.  */
+  s = PACKAGE_VERSION;
+  pInfo->firmwareVersion.major = atoi (s);
+  s = strchr (s, '.');
+  pInfo->firmwareVersion.minor = s? atoi (s+1): 0;
 
  out:
   scute_global_unlock ();

+ 0 - 2
src/settings.h

@@ -49,7 +49,5 @@
 #define SLOT_MANUFACTURER_ID "g10 Code GmbH"
 #define SLOT_HARDWARE_VERSION_MAJOR 0
 #define SLOT_HARDWARE_VERSION_MINOR 0
-#define SLOT_FIRMWARE_VERSION_MAJOR 0
-#define SLOT_FIRMWARE_VERSION_MINOR 0
 
 #endif	/* !SETTINGS_H */