]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/sanity.c
syncinfo_free must be able to free multiple syncinfos
[openldap] / servers / slurpd / sanity.c
index 240e479e4a69bf1bcebedb80a07e71990d616492..56d1ed3d6704ef1195a75c511db73288f5340eff 100644 (file)
@@ -1,5 +1,18 @@
-/*
- * Copyright (c) 1996 Regents of the University of Michigan.
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2007 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* Portions Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
@@ -9,6 +22,10 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).
+ */
 
 
 /*
 #include "portable.h"
 
 #include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+
+#include <ac/stdlib.h>
+#include <ac/unistd.h>
+#include <ac/string.h>
 
 #include "slurp.h"
 #include "globals.h"
-#include "portable.h"
 
 #define FC_DIRBAD      1
 #define FC_DIRUNREAD   2
 /*
  * Forward declarations
  */
-#ifdef NEEDPROTOS
-static unsigned int filecheck( char * );
-#else /* NEEDPROTOS */
-static unsigned int filecheck();
-#endif /* NEEDPROTOS */
+static unsigned int filecheck LDAP_P(( char * ));
 
 
 
@@ -60,7 +74,7 @@ static unsigned int filecheck();
  */
 
 int
-sanity()
+sanity( void )
 {
     int        err = 0;
     int rc;
@@ -69,7 +83,7 @@ sanity()
      * Are there any replicas listed in the slapd config file?
      */
     if ( sglob->replicas == NULL ) {
-       fprintf( stderr, "No replicas in slapd config file \"%s\"!\n",
+       fprintf( stderr, "No replicas in slapd.conf file \"%s\"!\n",
            sglob->slapd_configfile );
        err++;
     }
@@ -79,20 +93,24 @@ sanity()
      * that the slapd replogfile is readable, if it exists.
      */
     if ( sglob->slapd_replogfile == NULL ) {
-       fprintf( stderr, "Fatal error: no \"replogfile\" directive given\n" );
+       fprintf( stderr, "Fatal error: no \"replogfile\" "
+               "slapd.conf directive given\n" );
        err++;
     } else {
        rc = filecheck( sglob->slapd_replogfile );
        if ( rc & FC_DIRBAD ) {
-           fprintf( stderr, "Error: %s: directory does not exist\n", 
+           fprintf( stderr, "Error: %s: directory specified in "
+                       "\"replogfile\" slapd.conf directive does not exist\n", 
                    sglob->slapd_replogfile );
            err++;
        } else if ( rc & FC_DIRUNREAD ) {
-           fprintf( stderr, "Error: %s: directory not readable\n", 
+           fprintf( stderr, "Error: %s: directory specified in "
+                       "\"replogfile\" slapd.conf directive is not readable\n", 
                    sglob->slapd_replogfile );
            err++;
        } else if (!( rc & FC_FILEBAD) && ( rc & FC_FILEUNREAD )) {
-           fprintf( stderr, "Error: %s: file not readable\n", 
+           fprintf( stderr, "Error: %s: file specified in "
+                       "\"replogfile\" slapd.conf directive is not readable\n", 
                    sglob->slapd_replogfile );
            err++;
        }
@@ -108,19 +126,21 @@ sanity()
     } else {
        rc = filecheck( sglob->slurpd_replogfile );
        if ( rc & FC_DIRBAD ) {
-           fprintf( stderr, "Error: %s: directory does not exist\n", 
+           fprintf( stderr, "Error: %s: slurpd \"replogfile\" "
+                       "directory does not exist\n", 
                    sglob->slurpd_replogfile );
            err++;
        } else if ( rc & FC_DIRUNREAD ) {
-           fprintf( stderr, "Error: %s: directory not readable\n", 
+           fprintf( stderr, "Error: %s: slurpd \"replogfile\" "
+                       "directory not readable\n", 
                    sglob->slurpd_replogfile );
            err++;
        } else if ( !( rc & FC_FILEBAD ) && ( rc & FC_FILEUNREAD )) {
-           fprintf( stderr, "Error: %s: file not readable\n", 
+           fprintf( stderr, "Error: %s: slurpd \"replogfile\" not readable\n", 
                    sglob->slurpd_replogfile );
            err++;
        } else if ( !( rc & FC_FILEBAD ) && ( rc & FC_FILEUNWRITE )) {
-           fprintf( stderr, "Error: %s: file not writeable\n", 
+           fprintf( stderr, "Error: %s: slurpd \"replogfile\" not writeable\n", 
                    sglob->slurpd_replogfile );
            err++;
        }
@@ -132,19 +152,19 @@ sanity()
      */
     rc = filecheck( sglob->slurpd_status_file );
     if ( rc & FC_DIRBAD ) {
-       fprintf( stderr, "Error: %s: directory does not exist\n", 
+       fprintf( stderr, "Error: %s: status directory does not exist\n", 
                sglob->slurpd_status_file );
        err++;
     } else if ( rc & FC_DIRUNREAD ) {
-       fprintf( stderr, "Error: %s: directory not readable\n", 
+       fprintf( stderr, "Error: %s: status directory not readable\n", 
                sglob->slurpd_status_file );
        err++;
     } else if ( !( rc & FC_FILEBAD ) && ( rc & FC_FILEUNREAD )) {
-       fprintf( stderr, "Error: %s: file not readable\n", 
+       fprintf( stderr, "Error: %s: status file not readable\n", 
                sglob->slurpd_status_file );
        err++;
     } else if ( !( rc & FC_FILEBAD ) && ( rc & FC_FILEUNWRITE )) {
-       fprintf( stderr, "Error: %s: file not writeable\n", 
+       fprintf( stderr, "Error: %s: status file not writeable\n", 
                sglob->slurpd_status_file );
        err++;
     }
@@ -177,8 +197,8 @@ filecheck(
     char               *p;
     unsigned int       ret = 0;
 
-    strcpy( dir, sglob->slapd_replogfile );
-    p = strrchr( dir, '/' );
+       snprintf( dir, sizeof dir, "%s", f );
+    p = strrchr( dir, LDAP_DIRSEP[0] );
     if ( p != NULL ) {
        *p = '\0';
     }
@@ -203,4 +223,3 @@ filecheck(
 
     return ret;
 }
-