[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Notes on gnu-latest and Debian GNU/Hurd



On Thu, Jun 06, 2002 at 02:09:30PM +0530, Kapil Hari Paranjape wrote:
>    However, this is entirely a hack---so I would welcome pointers
>    on how to improve on this.

Someone needs to add a random device to OSKit (don't bother with gnumach < 2.0).
This random device can then be polled by /dev/random.  Actually, someone
should implemented libchannel, and then /dev/random can poll any character source
(like a tcp port, whatever).  But the random kernel device is needed either
way.

This is not so hard.  And now that we talk about it, I remember that Derek
Davies who already did some work on this sent me his patches for review a
month ago, and I completely forgot about it until right now!  Sorry Derek!
I will try to get a look at it soon.

> For example, I could not figure out
>    from the mailing lists any way of feeding this random device
>    entropy out of "egd" except to read data periodically from
>    egd's socket and push it into /dev/{,u}random---I could not figure
>    a neat way to do this either.

There is another random translator not written by me out there doing a much
better job at integration with egd.  Google links to it :)
[random+egd+hurd, probably]

>    (I read about libchannel but that
>    is beyond my current luser status). Also the seed files are 
>    unused.

If the seed files are not used, then it is a bug :)  And a most obvious one,
too.  Can you please try the below patch?

> 3. The "man" program often hangs. Perhaps this is GNU's way
>    of making sure that we use "info" instead ;-)

On my system man segfaults after a second or so, and it seems to be a
binaryc ompatibility problem with db2.  This also occurs on some GNU/Linux
systems (sparc I think).
 
> 4.
>    Still, currently gnumach-1.3.gz wins out on usability.

No way? :)

Following below is the patch for seed file support.

Thanks,
Marcus

2002-06-08  Marcus Brinkmann  <marcus@g10code.de>

        * gnu/hurd/random2/gnupg-random.c (set_random_seed_file)
        [__HURD__]: Don't trigger assertion if seed_file_name is set, but
        free its memory.
        (get_random_seed_file): Added yet another accessor function.
        * gnu/hurd/random2/gnupg-random.h [__HURD__]: Add prototype for
        get_random_seed_file.
        * gnu/hurd/random2/random.c (seed_file): Variable removed.
        (sigterm_handler): Take global lock while updating seed file.
        (trivfs_goaway): Likewise.
        (S_startup_dosync): Likewise.
        (parse_opt): Don't initialize seed_file, take global lock while
        setting seed file.
        (trivfs_append_args): Use get_random_seed_file to get seed file
        name.


diff -rup random/gnupg-random.c random2/gnupg-random.c
--- random/gnupg-random.c	Sat Jun 23 16:10:41 2001
+++ random2/gnupg-random.c	Sat Jun  8 02:29:04 2002
@@ -310,9 +310,21 @@ void
 set_random_seed_file( const char *name )
 {
     if( seed_file_name )
+#if __HURD__
+      m_free (seed_file_name);
+#else
 	BUG();
+#endif
     seed_file_name = m_strdup( name );
 }
+
+#if __HURD__
+char *
+get_random_seed_file (void)
+{
+  return seed_file_name;
+}
+#endif
 
 /****************
  * Read in a seed form the random_seed file
diff -rup random/gnupg-random.h random2/gnupg-random.h
--- random/gnupg-random.h	Sat Jun 23 15:06:49 2001
+++ random2/gnupg-random.h	Sat Jun  8 02:28:57 2002
@@ -32,6 +32,9 @@ int readable_pool (size_t, int);
 void random_dump_stats(void);
 void secure_random_alloc(void);
 void set_random_seed_file(const char *);
+#if __HURD__
+char *get_random_seed_file (void);
+#endif
 void update_random_seed_file(void);
 int  quick_random_gen( int onoff );
 int  random_is_faked(void);
Only in random2: gnupg-random.h~
diff -rup random/random.c random2/random.c
--- random/random.c	Sat Jun 23 15:50:16 2001
+++ random2/random.c	Sat Jun  8 02:24:49 2002
@@ -53,8 +53,6 @@ struct condition select_alert;	/* For re
 #define DEFAULT_LEVEL 2
 static int level = DEFAULT_LEVEL;
 
-/* Name of file to use as seed.  */
-static char *seed_file;
 
 /* The random bytes we collected.  */
 char gatherbuf[GATHERBUFSIZE];
@@ -129,7 +127,9 @@ trivfs_modify_stat (struct trivfs_protid
 error_t
 trivfs_goaway (struct trivfs_control *cntl, int flags)
 {
+  mutex_lock (&global_lock);
   update_random_seed_file ();
+  mutex_unlock (&global_lock);
   exit (0);
 }
 
@@ -457,8 +457,9 @@ parse_opt (int opt, char *arg, struct ar
       }
     case 'S':
       {
-	seed_file = strdup (arg);
+	mutex_lock (&global_lock);
 	set_random_seed_file (arg);
+	mutex_unlock (&global_lock);
       }
     }
   return 0;
@@ -495,9 +496,9 @@ trivfs_append_args (struct trivfs_contro
   if (level != DEFAULT_LEVEL)
     err = argz_add (argz, argz_len, opt);
 
-  if (!err && seed_file)
+  if (!err && get_random_seed_file ())
     {
-      if (asprintf (&opt, "--seed-file=%s", seed_file) < 0)
+      if (asprintf (&opt, "--seed-file=%s", get_random_seed_file (arg)) < 0)
 	err = ENOMEM;
       else
 	{
@@ -531,14 +532,18 @@ S_startup_dosync (mach_port_t handle)
   if (!inpi)
     return EOPNOTSUPP;
 
+  mutex_lock (&global_lock);
   update_random_seed_file ();
+  mutex_unlock (&global_lock);
   return 0;
 }
 
 void
 sigterm_handler (int signo)
 {
+  mutex_lock (&global_lock);
   update_random_seed_file ();
+  mutex_unlock (&global_lock);
   signal (SIGTERM, SIG_DFL);
   raise (SIGTERM);
 }

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de


-- 
To UNSUBSCRIBE, email to debian-hurd-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: