]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slaptest.c
ITS#6150
[openldap] / servers / slapd / slaptest.c
index 245389223006170efbd49f1d80876b6e30ad5955..fc72e852c2b79eadd28ae6b1a91be29b5547c397 100644 (file)
@@ -1,6 +1,7 @@
+/* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004-2005 The OpenLDAP Foundation.
+ * Copyright 2004-2009 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -45,7 +46,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 );
@@ -69,6 +70,7 @@ test_file( const char *fname, const char *ftype )
 
                                return -1;
                        }
+                       fclose( fp );
                        unlink( fname );
                        break;
                }
@@ -79,6 +81,8 @@ test_file( const char *fname, const char *ftype )
                        save_errno, strerror( save_errno ) );
                return -1;
        }
+
+       return 0;
 }
 
 int
@@ -101,9 +105,12 @@ slaptest( int argc, char **argv )
                }
        }
 
-       fprintf( stderr, "config file testing succeeded\n");
+       if ( !quiet ) {
+               fprintf( stderr, "config file testing succeeded\n");
+       }
 
-       slap_tool_destroy();
+       if ( slap_tool_destroy())
+               rc = EXIT_FAILURE;
 
        return rc;
 }