[openssh-commits] [openssh] 01/06: Move USE_SYSTEM_GLOB into a glob.h compat shim.
git+noreply at mindrot.org
git+noreply at mindrot.org
Mon Feb 9 04:37:54 AEDT 2026
This is an automated email from the git hooks/post-receive script.
dtucker pushed a commit to branch master
in repository openssh.
commit ecaaa4f9e44764e55c152a84af3d7efb63c50ce7
Author: Darren Tucker <dtucker at dtucker.net>
AuthorDate: Sun Feb 8 11:30:21 2026 +1100
Move USE_SYSTEM_GLOB into a glob.h compat shim.
This moves the logic for selecting whether or not we can use the system
glob into configure, and if either don't have glob or can't use it, we
create the shim. Removes several diffs vs upstream.
---
auth2-pubkey.c | 6 +-----
configure.ac | 44 ++++++++++++++++++++++++++++++++++++--------
defines.h | 7 -------
readconf.c | 6 +-----
scp.c | 6 +-----
servconf.c | 6 +-----
sftp-client.h | 6 ------
sftp-glob.c | 1 +
sftp-usergroup.c | 1 +
sftp.c | 2 +-
10 files changed, 43 insertions(+), 42 deletions(-)
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 5d5d79196..be378f266 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -32,6 +32,7 @@
#include <errno.h>
#include <paths.h>
#include <pwd.h>
+#include <glob.h>
#include <signal.h>
#include <stdio.h>
#include <stdarg.h>
@@ -39,11 +40,6 @@
#include <time.h>
#include <unistd.h>
#include <limits.h>
-#ifdef USE_SYSTEM_GLOB
-# include <glob.h>
-#else
-# include "openbsd-compat/glob.h"
-#endif
#include "xmalloc.h"
#include "ssh.h"
diff --git a/configure.ac b/configure.ac
index 60d45716b..a8823d68b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -464,7 +464,6 @@ AC_CHECK_HEADERS([ \
floatingpoint.h \
fnmatch.h \
getopt.h \
- glob.h \
ia.h \
iaf.h \
inttypes.h \
@@ -553,7 +552,6 @@ AC_CHECK_HEADERS([ \
*) ;;
esac >"$header"
])
-AC_SUBST([COMPATINCLUDES])
AC_CHECK_DECLS([le32toh, le64toh, htole64], [], [], [
#ifdef HAVE_SYS_TYPES_H
@@ -805,7 +803,7 @@ int main(void) { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE([SETEUID_BREAKS_SETUID])
AC_DEFINE([BROKEN_SETREUID])
AC_DEFINE([BROKEN_SETREGID])
- AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
+ broken_glob=yes # OS X glob does not do what we expect
AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
[Define if your resolver libs need this for getrrsetbyname])
AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
@@ -1123,7 +1121,7 @@ mips-sony-bsd|mips-sony-newsos4)
[Use tunnel device compatibility to OpenBSD])
AC_CHECK_HEADER([net/if_tap.h], ,
AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
- AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
+ broken_glob=yes # FreeBSD glob does not do what we need
TEST_MALLOC_OPTIONS="AJRX"
# Preauth crypto occasionally uses file descriptors for crypto offload
# and will crash if they cannot be opened.
@@ -1678,6 +1676,15 @@ else
[Define to rpl_calloc if the replacement function should be used.])
fi
+dnl Figure out if we have a system glob, and if so if we can use it.
+AC_CHECK_FUNCS([glob],
+ [ AC_CHECK_HEADERS([glob.h],
+ [use_system_glob=yes],
+ [use_system_glob=no])
+ ],
+ use_system_glob=no
+)
+
# Check for ALTDIRFUNC glob() extension
AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
AC_EGREP_CPP([FOUNDIT],
@@ -1695,6 +1702,7 @@ AC_EGREP_CPP([FOUNDIT],
],
[
AC_MSG_RESULT([no])
+ use_system_glob=no
]
)
@@ -1709,7 +1717,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
-])
+ use_system_glob=no
+ ]
+)
# Check for g.gl_statv glob() extension
AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
@@ -1727,10 +1737,28 @@ g.gl_statv = NULL;
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
+ use_system_glob=no
+ ]
+)
-])
+AC_CHECK_DECLS([GLOB_NOMATCH], , [use_system_glob=no], [#include <glob.h>])
-AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
+if test "x$broken_glob" = "xyes"; then
+ AC_DEFINE([BROKEN_GLOB], [1], [Do not use system glob])
+ use_system_glob=no
+fi
+
+dnl If we don't have a system glob, or we do but we're not using it, then
+dnl create a glob.h shim so we don't have to sprinkle ifdefs everywhere.
+AC_MSG_CHECKING([if we can use the system glob])
+if test "x$use_system_glob" = "xyes" ; then
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([no])
+ COMPATINCLUDES="openbsd-compat/include"
+ mkdir -p "$COMPATINCLUDES"
+ echo '# include "openbsd-compat/glob.h"' >$COMPATINCLUDES/glob.h
+fi
AC_CHECK_DECL([VIS_ALL], ,
AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
@@ -2089,7 +2117,6 @@ AC_CHECK_FUNCS([ \
getrandom \
getsid \
getttyent \
- glob \
group_from_gid \
inet_aton \
inet_ntoa \
@@ -5830,6 +5857,7 @@ LDFLAGS_NOPIE=`echo "$LDFLAGS" | sed 's/^-pie //;s/ -pie//g'`
CFLAGS_NOPIE=`echo "$CFLAGS" | sed 's/^-fPIE //;s/ -fPIE//g'`
AC_SUBST([LDFLAGS_NOPIE])
AC_SUBST([CFLAGS_NOPIE])
+AC_SUBST([COMPATINCLUDES])
AC_EXEEXT
AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
diff --git a/defines.h b/defines.h
index 8901da47a..1988b730c 100644
--- a/defines.h
+++ b/defines.h
@@ -979,13 +979,6 @@ struct winsize {
# endif /* gcc version */
#endif /* __predict_true */
-#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \
- defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \
- defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 && \
- !defined(BROKEN_GLOB)
-# define USE_SYSTEM_GLOB
-#endif
-
/*
* sntrup761 uses variable length arrays and c99-style declarations after code,
* so only enable if the compiler supports them.
diff --git a/readconf.c b/readconf.c
index 48529540a..580026431 100644
--- a/readconf.c
+++ b/readconf.c
@@ -28,6 +28,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#include <glob.h>
#include <ifaddrs.h>
#include <limits.h>
#include <netdb.h>
@@ -38,11 +39,6 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#ifdef USE_SYSTEM_GLOB
-# include <glob.h>
-#else
-# include "openbsd-compat/glob.h"
-#endif
#include <util.h>
#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) && !defined(BROKEN_STRNVIS)
# include <vis.h>
diff --git a/scp.c b/scp.c
index 86418d85e..f27c8fe3f 100644
--- a/scp.c
+++ b/scp.c
@@ -87,11 +87,7 @@
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
-#ifdef USE_SYSTEM_GLOB
-# include <glob.h>
-#else
-# include "openbsd-compat/glob.h"
-#endif
+#include <glob.h>
#include <libgen.h>
#include <limits.h>
#include <util.h>
diff --git a/servconf.c b/servconf.c
index 75f3f5dbd..be9cc827b 100644
--- a/servconf.c
+++ b/servconf.c
@@ -26,6 +26,7 @@
#endif
#include <ctype.h>
+#include <glob.h>
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
@@ -37,11 +38,6 @@
#include <stdarg.h>
#include <errno.h>
#include <util.h>
-#ifdef USE_SYSTEM_GLOB
-# include <glob.h>
-#else
-# include "openbsd-compat/glob.h"
-#endif
#include "openbsd-compat/sys-queue.h"
#include "xmalloc.h"
diff --git a/sftp-client.h b/sftp-client.h
index 873ad3849..7b2a94af8 100644
--- a/sftp-client.h
+++ b/sftp-client.h
@@ -21,12 +21,6 @@
#ifndef _SFTP_CLIENT_H
#define _SFTP_CLIENT_H
-#ifdef USE_SYSTEM_GLOB
-# include <glob.h>
-#else
-# include "openbsd-compat/glob.h"
-#endif
-
typedef struct SFTP_DIRENT SFTP_DIRENT;
struct SFTP_DIRENT {
diff --git a/sftp-glob.c b/sftp-glob.c
index e054e75e8..a8d3e07fc 100644
--- a/sftp-glob.c
+++ b/sftp-glob.c
@@ -21,6 +21,7 @@
#include <sys/stat.h>
#include <dirent.h>
+#include <glob.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
diff --git a/sftp-usergroup.c b/sftp-usergroup.c
index 93396ffc6..3cfcefea5 100644
--- a/sftp-usergroup.c
+++ b/sftp-usergroup.c
@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <openbsd-compat/sys-tree.h>
+#include <glob.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
diff --git a/sftp.c b/sftp.c
index b5adc09de..1e509f897 100644
--- a/sftp.c
+++ b/sftp.c
@@ -28,7 +28,7 @@
#include <ctype.h>
#include <errno.h>
-
+#include <glob.h>
#include <paths.h>
#include <libgen.h>
#ifdef HAVE_LOCALE_H
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list