From 880f50a1e6176cbdaa56232ba5b6d100f344fa26 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 20 Jun 2002 01:19:51 +0000 Subject: [PATCH] Protect both the socket and fifo tests with #ifdef's. --- lib/isc/unix/entropy.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/isc/unix/entropy.c b/lib/isc/unix/entropy.c index eedd1fd438..21a797a3c5 100644 --- a/lib/isc/unix/entropy.c +++ b/lib/isc/unix/entropy.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: entropy.c,v 1.67 2002/06/05 02:20:59 marka Exp $ */ +/* $Id: entropy.c,v 1.68 2002/06/20 01:19:51 marka Exp $ */ /* * This is the system depenedent part of the ISC entropy API. @@ -467,7 +467,7 @@ isc_result_t isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) { int fd; struct stat _stat; - isc_boolean_t is_usocket; + isc_boolean_t is_usocket = ISC_FALSE; isc_boolean_t is_connected = ISC_FALSE; isc_result_t ret; isc_entropysource_t *source; @@ -490,17 +490,18 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) { * the program to look at an actual FIFO as its source of * entropy. */ - if ((_stat.st_mode & S_IFMT) == S_IFSOCK -#ifdef _SOCKET_IS_FIFO - || (_stat.st_mode & S_IFMT) == S_IFIFO -#endif - ) { - fd = socket(PF_UNIX, SOCK_STREAM, 0); +#if defined(S_ISSOCK) + if (S_ISSOCK(_stat.st_mode)) is_usocket = ISC_TRUE; - } else { +#endif +#if defined(S_ISFIFO) + if (S_ISFIFO(_stat.st_mode)) + is_usocket = ISC_TRUE; +#endif + if (is_usocket) + fd = socket(PF_UNIX, SOCK_STREAM, 0); + else fd = open(fname, O_RDONLY | O_NONBLOCK, 0); - is_usocket = ISC_FALSE; - } if (fd < 0) { ret = isc__errno2result(errno);