Uprating of the passphrase pixie.
[u/mdw/catacomb] / passphrase.c
index 0b8ddcf..410b7af 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: passphrase.c,v 1.6 2004/04/08 01:36:15 mdw Exp $
+ * $Id$
  *
  * Reading of passphrases (Unix-specific)
  *
  *
  * Reading of passphrases (Unix-specific)
  *
@@ -50,28 +50,37 @@ static unsigned flags = 0;
 
 /*----- Main code ---------------------------------------------------------*/
 
 
 /*----- Main code ---------------------------------------------------------*/
 
-/* --- @pconn@ --- *
+/* --- @passphrase_connect@ ---
  *
  *
- * Arguments:  ---
+ * Arguments:  @const char *sock@ = socket name to connect to, or null for
+ *             default
  *
  * Returns:    Zero if OK, nonzero if it failed
  *
  * Use:                Attempts to connect to the passphrase pixie.
  */
 
  *
  * Returns:    Zero if OK, nonzero if it failed
  *
  * Use:                Attempts to connect to the passphrase pixie.
  */
 
-static int pconn(void)
+int passphrase_connect(const char *sock)
 {
   if (fd != -1)
 {
   if (fd != -1)
-    return (0);
-  if (flags & f_fail)
-    return (-1);
-  if ((fd = pixie_open(0)) < 0) {
+    close(fd);
+  if ((fd = pixie_open(sock)) < 0) {
     flags |= f_fail;
     return (-1);
   }
     flags |= f_fail;
     return (-1);
   }
+  flags &= ~f_fail;
   return (0);
 }
 
   return (0);
 }
 
+static int pconn(void)
+{
+  if (fd != -1)
+    return (0);
+  if (flags & f_fail)
+    return (-1);
+  return (passphrase_connect(0));
+}
+
 /* --- @passphrase_read@ --- *
  *
  * Arguments:  @const char *tag@ = pointer to passphrase tag string
 /* --- @passphrase_read@ --- *
  *
  * Arguments:  @const char *tag@ = pointer to passphrase tag string