allow setting of egd socket path

Peter O'Gorman gcrypt-devel at mlists.thewrittenword.com
Fri Apr 27 22:43:02 CEST 2007


On Fri, Apr 27, 2007 at 03:24:35PM -0500, Peter O'Gorman wrote:
> Hi,
[snipped]

Well, it helps if the patch builds on systems that do have
/dev/random.

Attept 2 attached.

Peter
-------------- next part --------------
Index: src/global.c
===================================================================
--- src/global.c	(revision 1234)
+++ src/global.c	(working copy)
@@ -354,6 +354,14 @@
       _gcry_use_random_daemon (!! va_arg (arg_ptr, int));
       break;
 
+    case GCRYCTL_SET_EGD_SOCKET_PATH:
+#if USE_RNDEGD
+      err = _gcry_set_egd_socket_path(va_arg (arg_ptr, const char *));
+#else 
+      err = GPG_ERR_NOT_IMPLEMENTED;
+#endif
+      break;
+
     default:
       err = GPG_ERR_INV_OP;
     }
Index: src/gcrypt.h.in
===================================================================
--- src/gcrypt.h.in	(revision 1234)
+++ src/gcrypt.h.in	(working copy)
@@ -355,7 +355,8 @@
     GCRYCTL_FAST_POLL = 48,
     GCRYCTL_SET_RANDOM_DAEMON_SOCKET = 49,
     GCRYCTL_USE_RANDOM_DAEMON = 50,
-    GCRYCTL_FAKED_RANDOM_P = 51
+    GCRYCTL_FAKED_RANDOM_P = 51,
+    GCRYCTL_SET_EGD_SOCKET_PATH = 52
   };
 
 /* Perform various operations defined by CMD. */
Index: cipher/rndegd.c
===================================================================
--- cipher/rndegd.c	(revision 1234)
+++ cipher/rndegd.c	(working copy)
@@ -39,7 +39,20 @@
 #endif
 
 static int egd_socket = -1;
+static char * user_egd_socket_path = NULL;
 
+int
+_gcry_set_egd_socket_path(const char * path)
+{
+  if ((NULL == user_egd_socket_path) && (egd_socket == -1))
+    {
+    user_egd_socket_path = gcry_xstrdup (path);
+    return 0;
+    }
+  return 1;
+}
+
+
 /* Allocate a new filename from FIRST_PART and SECOND_PART and to
    tilde expansion for first_part.  SECOND_PART might be NULL.
  */
@@ -141,6 +154,9 @@
   else
     name = my_make_filename (bname, NULL);
 
+  if (user_egd_socket_path)
+    name = user_egd_socket_path;
+
   if (strlen(name)+1 >= sizeof addr.sun_path)
     log_fatal ("EGD socketname is too long\n");
   
Index: cipher/random.h
===================================================================
--- cipher/random.h	(revision 1234)
+++ cipher/random.h	(working copy)
@@ -47,6 +47,8 @@
                                void *buffer, size_t length);
 #endif /*USE_RANDOM_DAEMON*/
 
+int _gcry_set_egd_socket_path(const char * path);
+
 #endif /*G10_RANDOM_H*/
 
 


More information about the Gcrypt-devel mailing list