From 3f4e196beb91b8e965746d6660d08daa6f0e172e Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 14 Sep 2006 07:29:46 +0000 Subject: [PATCH] Portability cleanups --- servers/slapd/alock.c | 2 ++ servers/slapd/back-ldif/ldif.c | 2 +- servers/slapd/config.c | 7 +++++++ servers/slapd/overlays/retcode.c | 18 ++++++++++-------- servers/slapd/slapcommon.c | 2 ++ servers/slapd/slaptest.c | 2 +- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/servers/slapd/alock.c b/servers/slapd/alock.c index 83e0fbd37f..624e918185 100644 --- a/servers/slapd/alock.c +++ b/servers/slapd/alock.c @@ -32,7 +32,9 @@ #include #include #include +#if HAVE_SYS_FILE_H #include +#endif #include #ifdef _WIN32 diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index ca1d36bf63..6e78d87c8b 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -181,7 +181,7 @@ static int spew_entry(Entry * e, struct berval * path) { int entry_length; char * entry_as_string; - openres = open(path->bv_val, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR); + openres = open(path->bv_val, O_WRONLY|O_CREAT|O_TRUNC, S_IREAD | S_IWRITE); if(openres == -1) { if(errno == ENOENT) rs = LDAP_NO_SUCH_OBJECT; diff --git a/servers/slapd/config.c b/servers/slapd/config.c index dbc62367e1..1b612e8aab 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -36,7 +36,14 @@ #include #include + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif + +#if HAVE_UNISTD_H #include +#endif #include "slap.h" #ifdef LDAP_SLAPI diff --git a/servers/slapd/overlays/retcode.c b/servers/slapd/overlays/retcode.c index 81b0ae275d..3e5568552d 100644 --- a/servers/slapd/overlays/retcode.c +++ b/servers/slapd/overlays/retcode.c @@ -93,20 +93,22 @@ retcode_entry_response( Operation *op, SlapReply *rs, BackendInfo *bi, Entry *e static unsigned int retcode_sleep( int s ) { + unsigned int r = 0; + /* sleep as required */ if ( s < 0 ) { #if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */ - unsigned r = rand() % (-s); + r = rand() % (-s); #endif - unsigned r = ((double)(-s))*rand()/(RAND_MAX + 1.0); - return sleep( r ); + r = ((double)(-s))*rand()/(RAND_MAX + 1.0); + } else if ( s > 0 ) { + r = (unsigned int)s; + } + if ( r ) { + sleep( r ); } - if ( s > 0 ) { - return sleep( (unsigned int)s ); - } - - return 0; + return r; } static int diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index 7ba89edb5c..bad640605a 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -517,6 +517,7 @@ slap_tool_init( exit( EXIT_FAILURE ); } +#ifdef LDAP_SYSLOG if ( syslog_unknowns ) { rc = parse_debug_unknowns( syslog_unknowns, &ldap_syslog ); ldap_charray_free( syslog_unknowns ); @@ -524,6 +525,7 @@ slap_tool_init( if ( rc ) exit( EXIT_FAILURE ); } +#endif at_oc_cache = 1; diff --git a/servers/slapd/slaptest.c b/servers/slapd/slaptest.c index a1c6baba0f..6ad27ba7f0 100644 --- a/servers/slapd/slaptest.c +++ b/servers/slapd/slaptest.c @@ -45,7 +45,7 @@ test_file( const char *fname, const char *ftype ) switch ( stat( fname, &st ) ) { case 0: - if ( !( st.st_mode & S_IWUSR ) ) { + if ( !( st.st_mode & S_IWRITE ) ) { Debug( LDAP_DEBUG_ANY, "%s file " "\"%s\" exists, but user does not have access\n", ftype, fname, 0 );