GNUPG-1-9-BRANCH gnupg/agent (ChangeLog command-ssh.c)

cvs user mo cvs at cvs.gnupg.org
Fri Jan 28 20:48:30 CET 2005


    Date: Friday, January 28, 2005 @ 20:57:14
  Author: mo
    Path: /cvs/gnupg/gnupg/agent
     Tag: GNUPG-1-9-BRANCH

Modified: ChangeLog command-ssh.c

2005-01-28  Moritz Schulte  <moritz at g10code.com>

	* command-ssh.c (ssh_handler_add_identity): Pass ctrl to
	ssh_identity_register().
	(ssh_identity_register): New argument: ctrl; pass ctrl to
	get_passphrase().
	(get_passphrase): Pass ctrl instead of NULL to agent_askpin().
	(start_command_handler_ssh): Use agent_init_default_ctrl();
	deallocate structure members, which might be dynamically
	allocated.
	(lifetime_default): Removed variable.
	(ssh_handler_add_identity): Fix ttl handling; renamed variable
	`death' to `ttl'.
	(ssh_identity_register): Fix key grip handling.


---------------+
 ChangeLog     |   15 +++++++++++++++
 command-ssh.c |   38 ++++++++++++++++++++++----------------
 2 files changed, 37 insertions(+), 16 deletions(-)


Index: gnupg/agent/ChangeLog
diff -u gnupg/agent/ChangeLog:1.59.2.58 gnupg/agent/ChangeLog:1.59.2.59
--- gnupg/agent/ChangeLog:1.59.2.58	Wed Jan 26 23:33:11 2005
+++ gnupg/agent/ChangeLog	Fri Jan 28 20:57:14 2005
@@ -1,3 +1,18 @@
+2005-01-28  Moritz Schulte  <moritz at g10code.com>
+
+	* command-ssh.c (ssh_handler_add_identity): Pass ctrl to
+	ssh_identity_register().
+	(ssh_identity_register): New argument: ctrl; pass ctrl to
+	get_passphrase().
+	(get_passphrase): Pass ctrl instead of NULL to agent_askpin().
+	(start_command_handler_ssh): Use agent_init_default_ctrl();
+	deallocate structure members, which might be dynamically
+	allocated.
+	(lifetime_default): Removed variable.
+	(ssh_handler_add_identity): Fix ttl handling; renamed variable
+	`death' to `ttl'.
+	(ssh_identity_register): Fix key grip handling.
+
 2005-01-26  Moritz Schulte  <moritz at g10code.com>
 
 	* command-ssh.c (ssh_handler_sign_request): Confirm to agent
Index: gnupg/agent/command-ssh.c
diff -u gnupg/agent/command-ssh.c:1.1.4.2 gnupg/agent/command-ssh.c:1.1.4.3
--- gnupg/agent/command-ssh.c:1.1.4.2	Wed Jan 26 23:33:11 2005
+++ gnupg/agent/command-ssh.c	Fri Jan 28 20:57:14 2005
@@ -94,8 +94,6 @@
 
 
 
-static uint32_t lifetime_default;
-
 /* General utility functions.  */
 
 static void *
@@ -1725,7 +1723,8 @@
 }
 
 static gpg_error_t
-get_passphrase (const char *description, size_t passphrase_n, char *passphrase)
+get_passphrase (ctrl_t ctrl,
+		const char *description, size_t passphrase_n, char *passphrase)
 {
   struct pin_entry_info_s *pi;
   gpg_error_t err;
@@ -1747,7 +1746,7 @@
   pi->cb_errtext = NULL;
   pi->max_length = 100;
 
-  err = agent_askpin (NULL, description, NULL, pi);
+  err = agent_askpin (ctrl, description, NULL, pi);
   if (err)
     goto out;
 
@@ -1851,7 +1850,7 @@
 }
 
 static gpg_error_t
-ssh_identity_register (gcry_sexp_t key, int ttl)
+ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
 {
   unsigned char key_grip_raw[21];
   unsigned char *buffer;
@@ -1862,11 +1861,11 @@
   char key_grip[41];
   char *comment;
   gpg_error_t err;
-  
+  unsigned int i;
   int ret;
 
   if (DBG_COMMAND)
-    log_debug ("[ssh-agent] registering identity `%s'\n", key_grip);
+    log_debug ("[ssh-agent] registering identity\n");
 
   description = NULL;
   comment = NULL;
@@ -1898,7 +1897,7 @@
 	     "for protecting the received secret key `%s':",
 	     comment ? comment : "");
 
-  err = get_passphrase (description, sizeof (passphrase), passphrase);
+  err = get_passphrase (ctrl, description, sizeof (passphrase), passphrase);
   if (err)
     goto out;
 
@@ -1910,7 +1909,10 @@
   if (err)
     goto out;
 
-  err = agent_put_cache (key_grip_raw, passphrase, ttl);
+  for (i = 0; i < 20; i++)
+    sprintf (key_grip + 2 * i, "%02X", key_grip_raw[i]);
+
+  err = agent_put_cache (key_grip, passphrase, ttl);
   if (err)
     goto out;
 
@@ -1954,15 +1956,15 @@
   gcry_sexp_t key;
   byte_t b;
   int confirm;
-  int death;
+  int ttl;
   int bad;
   
   if (DBG_COMMAND)
     log_debug ("[ssh-agent] add identity\n");
 
   confirm = 0;
-  death = 0;
   key = NULL;
+  ttl = 0;
   bad = 0;
 
   /* FIXME?  */
@@ -1990,7 +1992,7 @@
 
 	    err = es_read_uint32 (request, &n);
 	    if (! err)
-	      death = time (NULL) + n;
+	      ttl = n;
 	    break;
 	  }
 
@@ -2008,12 +2010,9 @@
   if (err)
     goto out;
 
-  if (lifetime_default && (! death))
-    death = time (NULL) + lifetime_default;
-
   /* FIXME: are constraints used correctly?  */
 
-  err = ssh_identity_register (key, death);
+  err = ssh_identity_register (ctrl, key, ttl);
 
  out:
 
@@ -2217,6 +2216,7 @@
     log_debug ("[ssh-agent] Starting command handler\n");
 
   memset (&ctrl, 0, sizeof (ctrl));
+  agent_init_default_ctrl (&ctrl);
   ctrl.connection_fd = sock_client;
 
   stream_response = NULL;
@@ -2324,4 +2324,10 @@
 
   if (DBG_COMMAND)
     log_debug ("[ssh-agent] Leaving ssh command handler: %s\n", gpg_strerror (err));
+
+  free (ctrl.display);
+  free (ctrl.ttyname);
+  free (ctrl.ttytype);
+  free (ctrl.lc_ctype);
+  free (ctrl.lc_messages);
 }




More information about the Gnupg-commits mailing list