mrc0mmand / rpms / openldap

Forked from rpms/openldap 3 years ago
Clone

Blame SOURCES/openldap-nss-reregister-nss-shutdown-callback.patch

a3e6a8
NSS: re-register NSS_Shutdown callback
a3e6a8
a3e6a8
Original upstream comment:
a3e6a8
"""
a3e6a8
When there's a persistent daemon for auth and it sets LDAP_OPT_X_TLS_NEWCTX, it
a3e6a8
fails to auth at third login.
a3e6a8
a3e6a8
1. everything is good and destroyed after use but
a3e6a8
tlsm_register_shutdown_callonce.initialized=1.
a3e6a8
2. still good but because tlsm_register_shutdown_callonce.initialized==1, it
a3e6a8
fails to register shutdown function.
a3e6a8
   so pem_module is not destroyed at the end.
a3e6a8
3. pem_module is not NULL so it's not initialized again and not added to modules
a3e6a8
list. And Login fails.
a3e6a8
"""
a3e6a8
a3e6a8
Sent-By: soohoon.lee@f5.com
a3e6a8
Original-Name: soohoon-lee-160823.patch
a3e6a8
Upstream-ITS: 8484
a3e6a8
a3e6a8
diff --git a/libraries/libldap/tls_m.c b/libraries/libldap/tls_m.c
a3e6a8
index cdf7f8e..cf05914 100644
a3e6a8
--- a/libraries/libldap/tls_m.c
a3e6a8
+++ b/libraries/libldap/tls_m.c
a3e6a8
@@ -1145,6 +1145,8 @@ tlsm_auth_cert_handler(void *arg, PRFileDesc *fd,
a3e6a8
 	return ret;
a3e6a8
 }
a3e6a8
 
a3e6a8
+static PRCallOnceType tlsm_register_shutdown_callonce = {0,0};
a3e6a8
+
a3e6a8
 static SECStatus
a3e6a8
 tlsm_nss_shutdown_cb( void *appData, void *nssData )
a3e6a8
 {
a3e6a8
@@ -1157,10 +1159,15 @@ tlsm_nss_shutdown_cb( void *appData, void *nssData )
a3e6a8
 		SECMOD_DestroyModule( pem_module );
a3e6a8
 		pem_module = NULL;
a3e6a8
 	}
a3e6a8
+
a3e6a8
+	/* init callonce so it can be armed again for cases like persistent daemon with LDAP_OPT_X_TLS_NEWCTX */
a3e6a8
+	tlsm_register_shutdown_callonce.initialized = 0;
a3e6a8
+	tlsm_register_shutdown_callonce.inProgress = 0;
a3e6a8
+	tlsm_register_shutdown_callonce.status = 0;
a3e6a8
+
a3e6a8
 	return rc;
a3e6a8
 }
a3e6a8
 
a3e6a8
-static PRCallOnceType tlsm_register_shutdown_callonce = {0,0};
a3e6a8
 static PRStatus PR_CALLBACK
a3e6a8
 tlsm_register_nss_shutdown_cb( void )
a3e6a8
 {