Module Name:    othersrc
Committed By:   lukem
Date:           Sat Sep 23 04:28:10 UTC 2023

Modified Files:
        othersrc/libexec/tnftpd: configure.ac tnftpd.h

Log Message:
configure: only replace glob if required GLOB_ flags aren't available

Use system glob() if it provides the flags we use:
        GLOB_BRACE|GLOB_LIMIT|GLOB_NOCHECK|GLOB_TILDE


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 othersrc/libexec/tnftpd/configure.ac
cvs rdiff -u -r1.39 -r1.40 othersrc/libexec/tnftpd/tnftpd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/libexec/tnftpd/configure.ac
diff -u othersrc/libexec/tnftpd/configure.ac:1.50 othersrc/libexec/tnftpd/configure.ac:1.51
--- othersrc/libexec/tnftpd/configure.ac:1.50	Sat Sep 23 04:12:32 2023
+++ othersrc/libexec/tnftpd/configure.ac	Sat Sep 23 04:28:10 2023
@@ -1,4 +1,4 @@
-# $NetBSD: configure.ac,v 1.50 2023/09/23 04:12:32 lukem Exp $
+# $NetBSD: configure.ac,v 1.51 2023/09/23 04:28:10 lukem Exp $
 #
 # Process this file with autoconf to produce a configure script.
 
@@ -95,6 +95,8 @@ AH_TEMPLATE([USE_BLOCKLIST],
             [Define if using blocklist.])
 AH_TEMPLATE([USE_BLACKLIST],
             [Define if using blacklist.])
+AH_TEMPLATE([USE_GLOB_H],
+            [Define if using system <glob.h> instead of local glob.])
 AH_TEMPLATE([USE_INET6],
             [Define if using IPv6 support.])
 AH_TEMPLATE([USE_PAM],
@@ -301,9 +303,22 @@ have_dirfd_as_macro
                      AC_DEFINE([HAVE_DIRFD_AS_MACRO], [1])],
                     [AC_MSG_RESULT([no])])])
 
-# Always replace glob(); the vendor's may not be secure.
+# Use system glob if required GLOB_ flags are available.
 #
-AC_LIBOBJ([glob])
+use_local_glob=yes
+AC_CHECK_HEADER([glob.h],
+                [AC_MSG_CHECKING([glob supports required flags])
+                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <glob.h>]], [[
+int f = GLOB_BRACE|GLOB_LIMIT|GLOB_NOCHECK|GLOB_TILDE;
+]])],
+                         [AC_MSG_RESULT([yes])
+			  use_local_glob=no],
+                         [AC_MSG_RESULT([no - using local version])],
+                         [AC_MSG_RESULT([unknown - cross-compiling])])])
+AS_IF([test "$use_local_glob" = yes],
+      [AC_LIBOBJ([glob])],
+      [AC_DEFINE([USE_GLOB_H], [1])])
 
 # Replace fnmatch() if FNM_CASEFOLD is not supported.
 #

Index: othersrc/libexec/tnftpd/tnftpd.h
diff -u othersrc/libexec/tnftpd/tnftpd.h:1.39 othersrc/libexec/tnftpd/tnftpd.h:1.40
--- othersrc/libexec/tnftpd/tnftpd.h:1.39	Sat Sep 23 04:00:21 2023
+++ othersrc/libexec/tnftpd/tnftpd.h	Sat Sep 23 04:28:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: tnftpd.h,v 1.39 2023/09/23 04:00:21 lukem Exp $ */
+/* $NetBSD: tnftpd.h,v 1.40 2023/09/23 04:28:10 lukem Exp $ */
 
 #define	FTPD_VERSION	PACKAGE_STRING
 
@@ -173,7 +173,11 @@ struct pollfd {
 # include <err.h>
 #endif
 
-#include "ftpglob.h"
+#if defined(USE_GLOB_H)
+# include <glob.h>
+#else
+# include "ftpglob.h"
+#endif
 
 #if defined(HAVE_FNMATCH_H) && HAVE_DECL_FNM_CASEFOLD
 # include <fnmatch.h>

Reply via email to