version 1.2, 2004/09/04 02:54:31
|
version 1.2.2.5, 2007/01/02 21:43:59
|
Line 1
|
Line 1
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2004 The OpenLDAP Foundation. |
* Copyright 2004-2007 The OpenLDAP Foundation. |
* Portions Copyright 2004 Pierangelo Masarati. |
* Portions Copyright 2004 Pierangelo Masarati. |
* All rights reserved. |
* All rights reserved. |
* |
* |
Line 26
|
Line 26
|
#include <ac/ctype.h> |
#include <ac/ctype.h> |
#include <ac/string.h> |
#include <ac/string.h> |
#include <ac/socket.h> |
#include <ac/socket.h> |
|
#include <sys/types.h> |
|
#include <sys/stat.h> |
#include <ac/unistd.h> |
#include <ac/unistd.h> |
|
#include <ac/errno.h> |
|
|
#include <lber.h> |
#include <lber.h> |
#include <ldif.h> |
#include <ldif.h> |
Line 34
|
Line 37
|
|
|
#include "slapcommon.h" |
#include "slapcommon.h" |
|
|
|
static int |
|
test_file( const char *fname, const char *ftype ) |
|
{ |
|
struct stat st; |
|
int save_errno; |
|
|
|
switch ( stat( fname, &st ) ) { |
|
case 0: |
|
if ( !( st.st_mode & S_IWUSR ) ) { |
|
Debug( LDAP_DEBUG_ANY, "%s file " |
|
"\"%s\" exists, but user does not have access\n", |
|
ftype, fname, 0 ); |
|
return -1; |
|
} |
|
break; |
|
|
|
case -1: |
|
default: |
|
save_errno = errno; |
|
if ( save_errno == ENOENT ) { |
|
FILE *fp = fopen( fname, "w" ); |
|
|
|
if ( fp == NULL ) { |
|
save_errno = errno; |
|
|
|
Debug( LDAP_DEBUG_ANY, "unable to open file " |
|
"\"%s\": %d (%s)\n", |
|
fname, |
|
save_errno, strerror( save_errno ) ); |
|
|
|
return -1; |
|
} |
|
unlink( fname ); |
|
break; |
|
} |
|
|
|
Debug( LDAP_DEBUG_ANY, "unable to stat file " |
|
"\"%s\": %d (%s)\n", |
|
slapd_pid_file, |
|
save_errno, strerror( save_errno ) ); |
|
return -1; |
|
} |
|
|
|
return 0; |
|
} |
|
|
int |
int |
slaptest( int argc, char **argv ) |
slaptest( int argc, char **argv ) |
{ |
{ |
Line 42 slaptest( int argc, char **argv )
|
Line 91 slaptest( int argc, char **argv )
|
|
|
slap_tool_init( progname, SLAPTEST, argc, argv ); |
slap_tool_init( progname, SLAPTEST, argc, argv ); |
|
|
|
if ( slapd_pid_file != NULL ) { |
|
if ( test_file( slapd_pid_file, "pid" ) ) { |
|
return EXIT_FAILURE; |
|
} |
|
} |
|
|
|
if ( slapd_args_file != NULL ) { |
|
if ( test_file( slapd_args_file, "args" ) ) { |
|
return EXIT_FAILURE; |
|
} |
|
} |
|
|
fprintf( stderr, "config file testing succeeded\n"); |
fprintf( stderr, "config file testing succeeded\n"); |
|
|
slap_tool_destroy(); |
slap_tool_destroy(); |