2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2004-2009 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 test_file( const char *fname, const char *ftype )
47 switch ( stat( fname, &st ) ) {
49 if ( !( st.st_mode & S_IWRITE ) ) {
50 Debug( LDAP_DEBUG_ANY, "%s file "
51 "\"%s\" exists, but user does not have access\n",
60 if ( save_errno == ENOENT ) {
61 FILE *fp = fopen( fname, "w" );
66 Debug( LDAP_DEBUG_ANY, "unable to open file "
69 save_errno, strerror( save_errno ) );
78 Debug( LDAP_DEBUG_ANY, "unable to stat file "
81 save_errno, strerror( save_errno ) );
89 slaptest( int argc, char **argv )
91 int rc = EXIT_SUCCESS;
92 const char *progname = "slaptest";
94 slap_tool_init( progname, SLAPTEST, argc, argv );
96 if ( slapd_pid_file != NULL ) {
97 if ( test_file( slapd_pid_file, "pid" ) ) {
102 if ( slapd_args_file != NULL ) {
103 if ( test_file( slapd_args_file, "args" ) ) {
109 fprintf( stderr, "config file testing succeeded\n");
112 if ( slap_tool_destroy())