2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2004-2014 The OpenLDAP Foundation.
5 * Portions Copyright 2004 Pierangelo Masarati.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masarati for inclusion
18 * in OpenLDAP Software.
25 #include <ac/stdlib.h>
28 #include <ac/string.h>
29 #include <ac/socket.h>
30 #include <sys/types.h>
32 #include <ac/unistd.h>
39 #include "slapcommon.h"
42 #define S_IWRITE S_IWUSR
46 test_file( const char *fname, const char *ftype )
51 switch ( stat( fname, &st ) ) {
53 if ( !( st.st_mode & S_IWRITE ) ) {
54 Debug( LDAP_DEBUG_ANY, "%s file "
55 "\"%s\" exists, but user does not have access\n",
64 if ( save_errno == ENOENT ) {
65 FILE *fp = fopen( fname, "w" );
70 Debug( LDAP_DEBUG_ANY, "unable to open file "
73 save_errno, strerror( save_errno ) );
82 Debug( LDAP_DEBUG_ANY, "unable to stat file "
85 save_errno, strerror( save_errno ) );
93 slaptest( int argc, char **argv )
95 int rc = EXIT_SUCCESS;
96 const char *progname = "slaptest";
98 slap_tool_init( progname, SLAPTEST, argc, argv );
100 if ( slapd_pid_file != NULL ) {
101 if ( test_file( slapd_pid_file, "pid" ) ) {
106 if ( slapd_args_file != NULL ) {
107 if ( test_file( slapd_args_file, "args" ) ) {
113 fprintf( stderr, "config file testing succeeded\n");
116 if ( slap_tool_destroy())