[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fedora-directory-commits
Subject:    =?utf-8?q?=5B389-commits=5D?= ldap/servers
From:       Noriko Hosoi <nhosoi () fedoraproject ! org>
Date:       2016-07-27 19:05:09
Message-ID: 20160727190509.A03B560F03 () fedorahosted ! org
[Download RAW message or body]

 ldap/servers/slapd/detach.c |   45 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 4 deletions(-)

New commits:
commit 70d06dab96468e0c6712482186f22de8e2c33e17
Author: Noriko Hosoi <nhosoi@redhat.com>
Date:   Wed Jul 27 11:23:17 2016 -0700

    Ticket #48939 - nsslapd-workingdir is empty when ns-slapd is started by systemd
    
    Description: Thanks to tbordaz@redhat.com for suggesting to reset the
    working dir in the error cases.  I've added more error checks and
    resetting the nsslapd-workingdir values.
    
    https://fedorahosted.org/389/ticket/48939
    
    Reviewed by mreynolds@redhat.com (Thank you, Mark!!)

diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c
index cd13a99..2f5667f 100644
--- a/ldap/servers/slapd/detach.c
+++ b/ldap/servers/slapd/detach.c
@@ -59,14 +59,41 @@ set_workingdir()
 		errorlog = config_get_errorlog();
 		if (NULL == errorlog) {
 			rc = chdir("/");
+			if (0 == rc) {
+				if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, "/", errorbuf, 1) == \
LDAP_OPERATIONS_ERROR) { +					LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set workingdir \
failed with \"%s\"\n", errorbuf); +				}
+			} else {
+				LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: failed to chdir to %s\n", "/");
+			}
 		} else {
 			ptr = strrchr(errorlog, '/');
 			if (ptr) {
 				*ptr = '\0';
 			}
 			rc = chdir(errorlog);
-			if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, errorbuf, 1) == \
                LDAP_OPERATIONS_ERROR) {
-				LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set workingdir failed with \"%s\"\n", \
errorbuf); +			if (0 == rc) {
+				if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, errorbuf, 1) == \
LDAP_OPERATIONS_ERROR) { +					LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set workingdir \
failed with \"%s\"\n", errorbuf); +					rc = chdir("/");
+					if (0 == rc) {
+						if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, "/", errorbuf, 1) == \
LDAP_OPERATIONS_ERROR) { +							LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set \
workingdir failed with \"%s\"\n", errorbuf); +						}
+					} else {
+						LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: failed to chdir to %s\n", "/");
+					}
+				}
+			} else {
+				LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: failed to chdir to %s\n", errorlog);
+				rc = chdir("/");
+				if (0 == rc) {
+					if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, "/", errorbuf, 1) == \
LDAP_OPERATIONS_ERROR) { +						LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set workingdir \
failed with \"%s\"\n", errorbuf); +					}
+				} else {
+					LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: failed to chdir to %s\n", "/");
+				}
 			}
 			slapi_ch_free_string(&errorlog);
 		}
@@ -75,8 +102,18 @@ set_workingdir()
 		if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, workingdir, errorbuf, 0) == \
LDAP_OPERATIONS_ERROR) {  LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set workingdir \
failed with \"%s\"\n", errorbuf);  rc = chdir("/");
+			if (0 == rc) {
+				if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, "/", errorbuf, 1) == \
LDAP_OPERATIONS_ERROR) { +					LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: set workingdir \
failed with \"%s\"\n", errorbuf); +				}
+			} else {
+				LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: failed to chdir to %s\n", "/");
+			}
 		} else {
 			rc = chdir(workingdir);
+			if (rc) {
+				LDAPDebug1Arg(LDAP_DEBUG_ANY, "detach: failed to chdir to %s\n", workingdir);
+			}
 		}
 		slapi_ch_free_string(&workingdir);
 	}
@@ -115,7 +152,7 @@ detach( int slapd_exemode, int importexport_encrypt,
 		}
 
 		if (set_workingdir()) {
-			LDAPDebug0Args(LDAP_DEBUG_ANY, "detach: chdir to workingdir failed.\n");
+			LDAPDebug0Args(LDAP_DEBUG_ANY, "detach: set_workingdir failed.\n");
 		}
 
 		if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
@@ -142,7 +179,7 @@ detach( int slapd_exemode, int importexport_encrypt,
 			return 1;
 		}
 		if (set_workingdir()) {
-			LDAPDebug0Args(LDAP_DEBUG_ANY, "detach: chdir to workingdir failed.\n");
+			LDAPDebug0Args(LDAP_DEBUG_ANY, "detach: set_workingdir failed.\n");
 		}
 	}
 

--
389-commits mailing list
389-commits@lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/389-commits@lists.fedoraproject.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic