From 81fda4fe51fdfba9ccbac24a0224327251eb7646 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Tue, 15 Nov 2011 22:18:17 +0000 Subject: [PATCH] Enable POSIX signatures on Solaris, and fix Unix directory parsing. --- configure.ac | 21 +++++++++-------- .../saml2/metadata/impl/FolderMetadataProvider.cpp | 27 ++++++++++++++-------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 8ed1f41..1f22150 100644 --- a/configure.ac +++ b/configure.ac @@ -49,17 +49,20 @@ if test "$GCC" = "yes" ; then # ]) CFLAGS="$GCC_CFLAGS" CXXFLAGS="$GCC_CXXFLAGS" -else -# Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993 - case "${host_cpu}-${host_os}" in - *solaris*) - if test "$CXX" = "CC" ; then - CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp" - fi - ;; - esac fi +# Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993 +# Also enables POSIX semantics for some functions. +case "${host_cpu}-${host_os}" in + *solaris*) + CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" + CXXFLAGS="$CXXFLAGS -D_POSIX_PTHREAD_SEMANTICS" + if test "$CXX" = "CC" ; then + CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp" + fi + ;; +esac + # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T diff --git a/saml/saml2/metadata/impl/FolderMetadataProvider.cpp b/saml/saml2/metadata/impl/FolderMetadataProvider.cpp index 1203d31..46bbc31 100644 --- a/saml/saml2/metadata/impl/FolderMetadataProvider.cpp +++ b/saml/saml2/metadata/impl/FolderMetadataProvider.cpp @@ -37,11 +37,12 @@ #include #ifndef WIN32 -# ifdef HAVE_SYS_TYPES_H && HAVE_DIRENT_H -# include +# if defined(HAVE_SYS_TYPES_H) && defined(HAVE_DIRENT_H) # include +# include +# include # else -# #error Unsupported directory library headers. +# error Unsupported directory library headers. # endif #endif @@ -112,14 +113,22 @@ namespace opensaml { if (!d) { throw MetadataException("Folder MetadataProvider unable to open directory ($1)", params(1, loc.c_str())); } - struct dirent* ent; - while(readdir_r(d, ent, &ent) == 0 && ent) { - if (ent->d_type & DT_DIR) { - if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) - log.warn("nested folders not supported, skipping (%s)", ent->d_name); + char dir_buf[sizeof(struct dirent) + PATH_MAX]; + struct dirent* ent = (struct dirent*)dir_buf; + struct dirent* entptr = nullptr; + while(readdir_r(d, ent, &entptr) == 0 && entptr) { + if (!strcmp(entptr->d_name, ".") || !strcmp(entptr->d_name, "..")) + continue; + fullname = loc + '/' + entptr->d_name; + struct stat stat_buf; + if (stat(fullname.c_str(), &stat_buf) != 0) { + log.warn("unable to access (%s)", entptr->d_name); + continue; + } + else if (S_ISDIR(stat_buf.st_mode)) { + log.warn("nested folders not supported, skipping (%s)", entptr->d_name); continue; } - fullname = loc + '/' + ent->d_name; log.info("will create metadata source from (%s)", fullname.c_str()); auto_ptr_XMLCh entry(fullname.c_str()); #endif -- 2.1.4