MozNSS Compat. Layer: fix recursive directory deletion
- ad #1516409#c7 case 2 (cherry picked from commit c66191c12b1bf372204cf3bf0b31759e7b0bd133) (originally #1516409) Related: #1400570
This commit is contained in:
parent
716f3439ac
commit
e6c4c72153
@ -1,7 +1,7 @@
|
|||||||
MozNSS Interception Code
|
MozNSS Interception Code
|
||||||
|
|
||||||
Author: Matus Honek <mhonek@redhat.com>
|
Author: Matus Honek <mhonek@redhat.com>
|
||||||
Date: Thu Jan 11 01:00:55 CET 2018
|
Date: Tue Jan 30 17:46:02 CET 2018
|
||||||
diff --git a/configure.in b/configure.in
|
diff --git a/configure.in b/configure.in
|
||||||
--- a/configure.in
|
--- a/configure.in
|
||||||
+++ b/configure.in
|
+++ b/configure.in
|
||||||
@ -283,7 +283,7 @@ diff --git a/libraries/libldap/tls_mc.c b/libraries/libldap/tls_mc.c
|
|||||||
new file mode 100644
|
new file mode 100644
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/libraries/libldap/tls_mc.c
|
+++ b/libraries/libldap/tls_mc.c
|
||||||
@@ -0,0 +1,1308 @@
|
@@ -0,0 +1,1316 @@
|
||||||
+#include "portable.h"
|
+#include "portable.h"
|
||||||
+
|
+
|
||||||
+#ifdef HAVE_MOZNSS_COMPATIBILITY
|
+#ifdef HAVE_MOZNSS_COMPATIBILITY
|
||||||
@ -294,6 +294,7 @@ new file mode 100644
|
|||||||
+#include <ac/errno.h>
|
+#include <ac/errno.h>
|
||||||
+#include <ac/termios.h>
|
+#include <ac/termios.h>
|
||||||
+#include <fcntl.h>
|
+#include <fcntl.h>
|
||||||
|
+#include <dirent.h>
|
||||||
+
|
+
|
||||||
+#include <nspr/nspr.h>
|
+#include <nspr/nspr.h>
|
||||||
+#include <nspr/private/pprio.h>
|
+#include <nspr/private/pprio.h>
|
||||||
@ -392,50 +393,56 @@ new file mode 100644
|
|||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
+int
|
+static int
|
||||||
+tlsmc_remove_dir_recursively( char *dir_name )
|
+tlsmc_remove_dir_recursively( const char *dir_name )
|
||||||
+{
|
+{
|
||||||
+ int rv = 0;
|
+ int rv = 0;
|
||||||
+ PRDir *dir = NULL;
|
+ DIR *dir = NULL;
|
||||||
+ PRDirEntry *entry = NULL;
|
+ struct dirent *entry = NULL;
|
||||||
+ char *full_path = NULL;
|
+ char *full_path = NULL;
|
||||||
+
|
+
|
||||||
+ Debug( LDAP_DEBUG_TRACE,
|
+ Debug( LDAP_DEBUG_TRACE,
|
||||||
+ "tlsmc_remove_dir_recursively: INFO: starting recursively removing directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: INFO: starting recursively removing directory `%s'.\n",
|
||||||
+ dir_name, 0, 0 );
|
+ dir_name, 0, 0 );
|
||||||
+ if ( NULL == ( dir = PR_OpenDir( dir_name ) ) ) {
|
+ if ( NULL == ( dir = opendir( dir_name ) ) ) {
|
||||||
+ Debug( LDAP_DEBUG_ANY,
|
+ Debug( LDAP_DEBUG_ANY,
|
||||||
+ "tlsmc_remove_dir_recursively: WARN: could not open directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: ERROR: could not open the directory (errno %d: %s).\n",
|
||||||
+ dir_name, 0, 0 );
|
+ errno, strerror( errno ), 0 );
|
||||||
+ rv = 0;
|
|
||||||
+ goto bail;
|
+ goto bail;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ while ( NULL != ( entry = PR_ReadDir( dir, PR_SKIP_BOTH ) ) ) {
|
+ while ( NULL != ( entry = readdir( dir ) ) ) {
|
||||||
+ PRFileInfo info;
|
+ struct stat info;
|
||||||
+ PRStatus prv;
|
|
||||||
+
|
+
|
||||||
+ full_path = NULL;
|
+ full_path = NULL;
|
||||||
+ full_path = PR_smprintf( "%s/%s", dir_name, entry->name );
|
+ full_path = PR_smprintf( "%s/%s", dir_name, entry->d_name );
|
||||||
+
|
+
|
||||||
+ if ( ( PR_SUCCESS == ( prv = PR_GetFileInfo( full_path, &info ) ) ) ) {
|
+ if ( 0 != strcmp( entry->d_name, "." ) && 0 != strcmp( entry->d_name, ".." ) ) {
|
||||||
+ if ( PR_FILE_DIRECTORY == info.type ) {
|
+ if ( 0 == lstat( full_path, &info ) ) {
|
||||||
|
+ if ( S_ISDIR( info.st_mode ) ) {
|
||||||
+ Debug( LDAP_DEBUG_TRACE,
|
+ Debug( LDAP_DEBUG_TRACE,
|
||||||
+ "tlsmc_remove_dir_recursively: INFO: stepping in directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: INFO: stepping into directory `%s'.\n",
|
||||||
+ full_path, 0, 0 );
|
+ entry->d_name, 0, 0 );
|
||||||
+ if ( 0 == tlsmc_remove_dir_recursively( full_path ) ) {
|
+ if ( 0 == tlsmc_remove_dir_recursively( full_path ) ) {
|
||||||
+ rv = 0;
|
+ goto bail_and_close_dir;
|
||||||
+ goto bail;
|
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ Debug( LDAP_DEBUG_TRACE,
|
+ Debug( LDAP_DEBUG_TRACE,
|
||||||
+ "tlsmc_remove_dir_recursively: INFO: removing file `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: INFO: removing file `%s'.\n",
|
||||||
+ full_path, 0, 0 );
|
+ entry->d_name, 0, 0 );
|
||||||
+ if ( PR_FAILURE == PR_Delete( full_path ) ) {
|
+ if ( 0 != remove( full_path ) ) {
|
||||||
+ rv = 0;
|
+ Debug( LDAP_DEBUG_ANY,
|
||||||
+ goto bail;
|
+ "tlsmc_remove_dir_recursively: ERROR: could not remove the file (errno %d: %s).\n",
|
||||||
|
+ errno, strerror( errno ), 0 );
|
||||||
|
+ goto bail_and_close_dir;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ Debug( LDAP_DEBUG_ANY,
|
||||||
|
+ "tlsmc_remove_dir_recursively: ERROR: could not stat `%s', (errno %d: %s).\n",
|
||||||
|
+ full_path, errno, strerror( errno ) );
|
||||||
|
+ goto bail_and_close_dir;
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if ( full_path ) {
|
+ if ( full_path ) {
|
||||||
@ -445,29 +452,30 @@ new file mode 100644
|
|||||||
+
|
+
|
||||||
+ }
|
+ }
|
||||||
+ Debug( LDAP_DEBUG_TRACE,
|
+ Debug( LDAP_DEBUG_TRACE,
|
||||||
+ "tlsmc_remove_dir_recursively: INFO: stepping out of directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: INFO: stepping out of the directory.\n",
|
||||||
+ dir_name, 0, 0 );
|
+ 0, 0, 0 );
|
||||||
+ if ( PR_FAILURE == PR_CloseDir( dir ) ) {
|
+ if ( 0 != closedir( dir ) ) {
|
||||||
+ Debug( LDAP_DEBUG_ANY,
|
+ Debug( LDAP_DEBUG_ANY,
|
||||||
+ "tlsmc_remove_dir_recursively: WARN: could not close directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: WARN: could not close the directory (errno %d: %s).\n",
|
||||||
+ dir_name, 0, 0 );
|
+ errno, strerror( errno ), 0 );
|
||||||
+ rv = 0;
|
|
||||||
+ goto bail;
|
+ goto bail;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ Debug( LDAP_DEBUG_TRACE,
|
+ Debug( LDAP_DEBUG_TRACE,
|
||||||
+ "tlsmc_remove_dir_recursively: INFO: removing the directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: INFO: removing the directory itself.\n",
|
||||||
+ dir_name, 0, 0 );
|
+ 0, 0, 0 );
|
||||||
+ if ( PR_FAILURE == PR_RmDir( dir_name ) ) {
|
+ if ( 0 != remove( dir_name ) ) {
|
||||||
|
+ PRErrorCode errcode = PR_GetError();
|
||||||
+ Debug( LDAP_DEBUG_ANY,
|
+ Debug( LDAP_DEBUG_ANY,
|
||||||
+ "tlsmc_remove_dir_recursively: WARN: could not remove the directory `%s'.\n",
|
+ "tlsmc_remove_dir_recursively: ERROR: could not remove the directory (errno %d: %s).\n",
|
||||||
+ dir_name, 0, 0 );
|
+ errno, strerror( errno ), 0 );
|
||||||
+ rv = 0;
|
|
||||||
+ goto bail;
|
+ goto bail;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ rv = 1;
|
+ rv = 1;
|
||||||
+
|
+ goto bail;
|
||||||
|
+bail_and_close_dir:
|
||||||
|
+ closedir( dir );
|
||||||
+bail:
|
+bail:
|
||||||
+ if ( full_path ) PR_smprintf_free( full_path );
|
+ if ( full_path ) PR_smprintf_free( full_path );
|
||||||
+ return rv;
|
+ return rv;
|
||||||
|
@ -518,6 +518,7 @@ exit 0
|
|||||||
%changelog
|
%changelog
|
||||||
* Wed Feb 7 2018 Matus Honek <mhonek@redhat.com> - 2.4.45-7
|
* Wed Feb 7 2018 Matus Honek <mhonek@redhat.com> - 2.4.45-7
|
||||||
- MozNSS Compat. Layer fixes (#1400570)
|
- MozNSS Compat. Layer fixes (#1400570)
|
||||||
|
- fix recursive directory deletion (orig. #1516409)
|
||||||
- Ensure consistency of a PEM dir before usage (orig. #1516409)
|
- Ensure consistency of a PEM dir before usage (orig. #1516409)
|
||||||
+ Warn just before use of a PIN about key file extraction
|
+ Warn just before use of a PIN about key file extraction
|
||||||
- Enable usage of NSS DB with PEM cert/key (orig. #1525485)
|
- Enable usage of NSS DB with PEM cert/key (orig. #1525485)
|
||||||
|
Loading…
Reference in New Issue
Block a user