Просмотр исходного кода

Use scandir64() if available.

Required on current AIX for include directory processing.
Doug Nazar 2 недель назад
Родитель
Сommit
bc384547fd
4 измененных файлов с 1519 добавлено и 18 удалено
  1. 1392 7
      configure
  2. 4 1
      configure.ac
  3. 104 1
      include/config.h.in
  4. 19 9
      src/nrpe.c

Разница между файлами не показана из-за своего большого размера
+ 1392 - 7
configure


+ 4 - 1
configure.ac

@@ -50,6 +50,9 @@ AC_SUBST(TARGET_OS)
 AC_SUBST(TARGET_ARCH)
 AC_SUBST(TARGET_PLATFORM)
 
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
+
 dnl Figure out how to invoke "install" and what install options to use.
 AC_PROG_INSTALL
 
@@ -257,7 +260,7 @@ if test x$check_for_tcpd != xno; then
 	])
 fi
 
-AC_CHECK_FUNCS(strdup strstr strtoul strtok_r initgroups closesocket sigaction scandir)
+AC_CHECK_FUNCS(strdup strstr strtoul strtok_r initgroups closesocket sigaction scandir scandir64)
 
 dnl socklen_t check - from curl
 AC_CHECK_TYPE([socklen_t], ,[

+ 104 - 1
include/config.h.in

@@ -27,10 +27,110 @@
 #ifndef _CONFIG_H
 #define _CONFIG_H
 
+
+
+/* Enable extensions on AIX, Interix, z/OS.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable general extensions on macOS.  */
+#ifndef _DARWIN_C_SOURCE
+# undef _DARWIN_C_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable X/Open compliant socket functions that do not require linking
+   with -lxnet on HP-UX 11.11.  */
+#ifndef _HPUX_ALT_XOPEN_SOCKET_API
+# undef _HPUX_ALT_XOPEN_SOCKET_API
+#endif
+/* Identify the host operating system as Minix.
+   This macro does not affect the system headers' behavior.
+   A future release of Autoconf may stop defining this macro.  */
+#ifndef _MINIX
+# undef _MINIX
+#endif
+/* Enable general extensions on NetBSD.
+   Enable NetBSD compatibility extensions on Minix.  */
+#ifndef _NETBSD_SOURCE
+# undef _NETBSD_SOURCE
+#endif
+/* Enable OpenBSD compatibility extensions on NetBSD.
+   Oddly enough, this does nothing on OpenBSD.  */
+#ifndef _OPENBSD_SOURCE
+# undef _OPENBSD_SOURCE
+#endif
+/* Define to 1 if needed for POSIX-compatible behavior.  */
+#ifndef _POSIX_SOURCE
+# undef _POSIX_SOURCE
+#endif
+/* Define to 2 if needed for POSIX-compatible behavior.  */
+#ifndef _POSIX_1_SOURCE
+# undef _POSIX_1_SOURCE
+#endif
+/* Enable POSIX-compatible threading on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-5:2014.  */
+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-1:2014.  */
+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
+# undef __STDC_WANT_IEC_60559_BFP_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-2:2015.  */
+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
+# undef __STDC_WANT_IEC_60559_DFP_EXT__
+#endif
+/* Enable extensions specified by C23 Annex F.  */
+#ifndef __STDC_WANT_IEC_60559_EXT__
+# undef __STDC_WANT_IEC_60559_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-4:2015.  */
+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
+# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
+#endif
+/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015.  */
+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
+# undef __STDC_WANT_IEC_60559_TYPES_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TR 24731-2:2010.  */
+#ifndef __STDC_WANT_LIB_EXT2__
+# undef __STDC_WANT_LIB_EXT2__
+#endif
+/* Enable extensions specified by ISO/IEC 24747:2009.  */
+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
+# undef __STDC_WANT_MATH_SPEC_FUNCS__
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable X/Open extensions.  Define to 500 only if necessary
+   to make mbstate_t available.  */
+#ifndef _XOPEN_SOURCE
+# undef _XOPEN_SOURCE
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define to 1 on platforms where this makes off_t a 64-bit type. */
+#undef _LARGE_FILES
+
+
 #include <stdio.h>
 #include <stdlib.h>
 
-
 /* Default port for NRPE daemon */
 #undef DEFAULT_SERVER_PORT
 
@@ -79,6 +179,9 @@
 /* Define to 1 if you have the `scandir' function. */
 #undef HAVE_SCANDIR
 
+/* Define to 1 if you have the `scandir64' function. */
+#undef HAVE_SCANDIR64
+
 /* Set to 1 if you have rfc931_timeout */
 #undef HAVE_RFC931_TIMEOUT
 

+ 19 - 9
src/nrpe.c

@@ -1022,22 +1022,32 @@ int read_config_file(char *filename)
 /* process all config files in a specific config directory (with directory recursion) */
 int read_config_dir(char *dirname)
 {
-	struct dirent *dirfile;
-#ifdef HAVE_SCANDIR
-	struct dirent **dirfiles;
-	int       x, i, n;
+#if defined(HAVE_SCANDIR64) || defined(HAVE_SCANDIR)
+#if defined(HAVE_SCANDIR64)
+	struct dirent64 **dirfiles;
+	struct dirent64 *dirfile;
 #else
-	DIR      *dirp;
-	int       x;
+	struct dirent **dirfiles;
+	struct dirent *dirfile;
+#endif
+	int i, n;
+
+#else // opendir
+	DIR				*dirp;
+	struct dirent	*dirfile;
 #endif
 	struct stat buf;
 	char      config_file[MAX_FILENAME_LENGTH];
 	int       result = OK;
-	int rc;
+	int x, rc;
 
-#ifdef HAVE_SCANDIR
+#if defined(HAVE_SCANDIR64) || defined(HAVE_SCANDIR)
 	/* read and sort the directory contents */
+#if defined(HAVE_SCANDIR64)
+	n = scandir64(dirname, &dirfiles, 0, alphasort64);
+#else
 	n = scandir(dirname, &dirfiles, 0, alphasort);
+#endif
 	if (n < 0) {
 		logit(LOG_ERR, "Could not open config directory '%s' for reading.\n", dirname);
 		return ERROR;
@@ -1091,7 +1101,7 @@ int read_config_dir(char *dirname)
 		}
 	}
 
-#ifdef HAVE_SCANDIR
+#if defined(HAVE_SCANDIR64) || defined(HAVE_SCANDIR)
 	for (i = 0; i < n; i++)
 		free(dirfiles[i]);
 	free(dirfiles);

Некоторые файлы не были показаны из-за большого количества измененных файлов