Portability cleanups

This commit is contained in:
Howard Chu 2006-09-14 07:29:46 +00:00
parent 811a90d5e1
commit 3f4e196beb
6 changed files with 23 additions and 10 deletions

View File

@ -32,7 +32,9 @@
#include <ac/assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#include <fcntl.h>
#ifdef _WIN32

View File

@ -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;

View File

@ -36,7 +36,14 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef S_ISREG
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "slap.h"
#ifdef LDAP_SLAPI

View File

@ -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

View File

@ -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;

View File

@ -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 );