X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d03ab969116fe715d569304c1c474749b2f64529..92090e34f3c26412359b44640064fef767b3a57d:/noise.c diff --git a/noise.c b/noise.c index 094447c..ed2d83c 100644 --- a/noise.c +++ b/noise.c @@ -1,8 +1,8 @@ /* -*-c-*- * - * $Id: noise.c,v 1.1 1999/09/03 08:41:12 mdw Exp $ + * $Id: noise.c,v 1.5 1999/12/22 15:57:55 mdw Exp $ * - * Acquisition of environmental noise (Unix specific) + * Acquisition of environmental noise (Unix-specific) * * (c) 1998 Straylight/Edgeware */ @@ -30,6 +30,18 @@ /*----- Revision history --------------------------------------------------* * * $Log: noise.c,v $ + * Revision 1.5 1999/12/22 15:57:55 mdw + * Label system-specific parts more clearly. + * + * Revision 1.4 1999/12/10 23:25:15 mdw + * Bug fix: remove old spurious fflush. + * + * Revision 1.3 1999/12/10 23:24:11 mdw + * Bug fix: flush buffers before forking. + * + * Revision 1.2 1999/11/11 00:59:08 mdw + * A bit of reformatting. Initialize the uid and gid correctly. + * * Revision 1.1 1999/09/03 08:41:12 mdw * Initial import. * @@ -37,9 +49,7 @@ /*----- Header files ------------------------------------------------------*/ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include #include @@ -81,8 +91,8 @@ static unsigned long noise_diff; /* Last first order difference */ /* --- Setuid program handling --- */ -static uid_t noise_uid; /* Uid to set to spawn processes */ -static gid_t noise_gid; /* Gid to set to spawn processes */ +static uid_t noise_uid = NOISE_NOSETUID; /* Uid to set to spawn processes */ +static gid_t noise_gid = NOISE_NOSETGID; /* Gid to set to spawn processes */ /*----- Main code ---------------------------------------------------------*/ @@ -199,7 +209,7 @@ int noise_devrandom(rand_pool *r) * Use: Sets the user and group ids to be used by @noise_filter@ * when running child processes. This is useful to avoid * giving shell commands (even carefully written ones) undue - * privileges. + * privileges. This interface is Unix-specific */ void noise_setid(uid_t uid, gid_t gid) @@ -227,6 +237,8 @@ void noise_setid(uid_t uid, gid_t gid) * fails to complete within a short time period, it is killed. * Paranoid use of close-on-exec flags for file descriptors is * recommended. + * + * This interface is Unix-specific. */ int noise_filter(rand_pool *r, int good, const char *c) @@ -253,6 +265,7 @@ int noise_filter(rand_pool *r, int good, const char *c) /* --- Fork a child off --- */ + fflush(0); kid = fork(); if (kid < 0) { close(fd[0]); @@ -262,7 +275,6 @@ int noise_filter(rand_pool *r, int good, const char *c) /* --- Handle the child end of the deal --- */ - fflush(0); if (kid == 0) { int f;