]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/main.c
ITS#2851
[openldap] / servers / slurpd / main.c
index c12f9e9022ebcc227f5ab6ee9930e409702b732c..5418ef79d105342ef05cfff0f7d93613350ade42 100644 (file)
@@ -1,10 +1,18 @@
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2003 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>.
  */
-/*
- * Copyright (c) 1996 Regents of the University of Michigan.
+/* Portions Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * 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).  Additional significant contributors
+ * include:
+ *     Howard Chu
+ */
 
 
 /* 
@@ -161,7 +175,7 @@ int main( int argc, char **argv )
      */
     if ( sglob->st->st_read( sglob->st )) {
        fprintf( stderr, "Malformed slurpd status file \"%s\"\n",
-               sglob->slurpd_status_file, 0, 0 );
+               sglob->slurpd_status_file );
        SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 17 );
        rc = 1;
        goto stop;
@@ -178,42 +192,43 @@ int main( int argc, char **argv )
     }
 
 
-    if ( slurpd_pid_file != NULL ) {
-       FILE *fp = fopen( slurpd_pid_file, "w" );
+    /*
+     * Detach from the controlling terminal
+     * unless the -d flag is given or in one-shot mode.
+     */
+#ifndef HAVE_WINSOCK
+       if ( ! (sglob->no_detach || sglob->one_shot_mode) ) {
+               lutil_detach( 0, 0 );
+       }
+#endif
+
+       if ( slurpd_pid_file != NULL ) {
+               FILE *fp = fopen( slurpd_pid_file, "w" );
 
-       if( fp != NULL ) {
-               fprintf( fp, "%d\n", (int) getpid() );
-               fclose( fp );
+               if( fp != NULL ) {
+                       fprintf( fp, "%d\n", (int) getpid() );
+                       fclose( fp );
 
-       } else {
+               } else {
                free(slurpd_pid_file);
                slurpd_pid_file = NULL;
+               }
        }
-    }
-
-    if ( slurpd_args_file != NULL ) {
-       FILE *fp = fopen( slurpd_args_file, "w" );
 
-       if( fp != NULL ) {
-               for ( i = 0; i < argc; i++ ) {
-                       fprintf( fp, "%s ", argv[i] );
+       if ( slurpd_args_file != NULL ) {
+               FILE *fp = fopen( slurpd_args_file, "w" );
+
+               if( fp != NULL ) {
+                       for ( i = 0; i < argc; i++ ) {
+                               fprintf( fp, "%s ", argv[i] );
+                       }
+                       fprintf( fp, "\n" );
+                       fclose( fp );
+               } else {
+                       free(slurpd_args_file);
+                       slurpd_args_file = NULL;
                }
-               fprintf( fp, "\n" );
-               fclose( fp );
-       } else {
-               free(slurpd_args_file);
-               slurpd_args_file = NULL;
        }
-    }
-
-    /*
-     * Detach from the controlling terminal
-     * unless the -d flag is given or in one-shot mode.
-     */
-#ifndef HAVE_WINSOCK
-    if ( ! (sglob->no_detach || sglob->one_shot_mode) )
-       lutil_detach( 0, 0 );
-#endif
 
     if ( (rc = lutil_pair( sglob->wake_sds )) < 0 ) {
        SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
@@ -287,6 +302,10 @@ stop:
     /* destroy the thread package */
     ldap_pvt_thread_destroy();
 
+#ifdef HAVE_TLS
+    ldap_pvt_tls_destroy();
+#endif
+
 #ifdef NEW_LOGGING
        LDAP_LOG ( SLURPD, RESULTS, "main: slurpd terminated\n", 0, 0, 0 );
 #else