Index: random/rndunix.c =================================================================== --- random/rndunix.c +++ random/rndunix.c @@ -87,6 +87,7 @@ #include #include #include +#include /* OS-specific includes */ @@ -737,6 +738,15 @@ if( i != n1 && i != n2 && i != pipefd ) close(i); } + + /* Reopen standard files (only if needed) so that NetBSD does not + complain about executing set[ug]id programs with descriptors 0 + and/or 1 closed. At this point, 2 is still open. */ + if ((i = open("/dev/null", O_RDONLY)) != STDIN_FILENO) + close(i); + if ((i = open("/dev/null", O_WRONLY)) != STDOUT_FILENO) + close(i); + errno = 0; } @@ -764,6 +774,10 @@ #endif fclose(stderr); /* Arrghh!! It's Stuart code!! */ + { + int i = open("/dev/null", O_WRONLY); + assert(i == STDERR_FILENO); + } for(;;) { GATHER_MSG msg;