1 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 * Copyright 2004-2008 The OpenLDAP Foundation.
4 * Portions Copyright 2004 Pierangelo Masarati.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * This work was initially developed by Pierangelo Masarati for inclusion
17 * in OpenLDAP Software.
24 #include <ac/stdlib.h>
27 #include <ac/string.h>
28 #include <ac/socket.h>
29 #include <sys/types.h>
31 #include <ac/unistd.h>
38 #include "slapcommon.h"
41 test_file( const char *fname
, const char *ftype
)
46 switch ( stat( fname
, &st
) ) {
48 if ( !( st
.st_mode
& S_IWRITE
) ) {
49 Debug( LDAP_DEBUG_ANY
, "%s file "
50 "\"%s\" exists, but user does not have access\n",
59 if ( save_errno
== ENOENT
) {
60 FILE *fp
= fopen( fname
, "w" );
65 Debug( LDAP_DEBUG_ANY
, "unable to open file "
68 save_errno
, strerror( save_errno
) );
77 Debug( LDAP_DEBUG_ANY
, "unable to stat file "
80 save_errno
, strerror( save_errno
) );
88 slaptest( int argc
, char **argv
)
90 int rc
= EXIT_SUCCESS
;
91 const char *progname
= "slaptest";
93 slap_tool_init( progname
, SLAPTEST
, argc
, argv
);
95 if ( slapd_pid_file
!= NULL
) {
96 if ( test_file( slapd_pid_file
, "pid" ) ) {
101 if ( slapd_args_file
!= NULL
) {
102 if ( test_file( slapd_args_file
, "args" ) ) {
108 fprintf( stderr
, "config file testing succeeded\n");