]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Check for tcgetattr / tcsetattr before using it for readpassphrase implementation...
authorJulian Uy <uyjulian@gmail.com>
Fri, 6 Dec 2024 15:58:58 +0000 (09:58 -0600)
committerMartin Matuska <martin@matuska.de>
Tue, 11 Mar 2025 09:25:07 +0000 (10:25 +0100)
This is mainly for non-cygwin newlib platforms that don't have tcgetattr
/ tcsetattr implemented

(cherry picked from commit 819c5b01a90e738ced6af237a6ae0d1aff981127)

CMakeLists.txt
build/cmake/config.h.in
configure.ac
contrib/android/config/android.h
contrib/android/config/linux_host.h
contrib/android/config/windows_host.h
libarchive/config_freebsd.h
libarchive_fe/passphrase.c

index bfe68acd507b371590c05bd85b0da2030d9f5707..8ca65967dd1bb4fe70e13db15425f0ef650dfbb3 100644 (file)
@@ -1524,6 +1524,8 @@ CHECK_FUNCTION_EXISTS_GLIBC(strnlen HAVE_STRNLEN)
 CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR)
 CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK)
 CHECK_FUNCTION_EXISTS_GLIBC(sysconf HAVE_SYSCONF)
+CHECK_FUNCTION_EXISTS_GLIBC(tcgetattr HAVE_TCGETATTR)
+CHECK_FUNCTION_EXISTS_GLIBC(tcsetattr HAVE_TCSETATTR)
 CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM)
 CHECK_FUNCTION_EXISTS_GLIBC(tzset HAVE_TZSET)
 CHECK_FUNCTION_EXISTS_GLIBC(unlinkat HAVE_UNLINKAT)
index d6e54879219257871f55157733153ed8d8aba227..9a9ce52e6d31d1405b3f2dd3692306ccbf928c5d 100644 (file)
@@ -1172,6 +1172,12 @@ typedef uint64_t uintmax_t;
 /* Define to 1 if you have the <sys/xattr.h> header file. */
 #cmakedefine HAVE_SYS_XATTR_H 1
 
+/* Define to 1 if you have the `tcgetattr' function. */
+#cmakedefine HAVE_TCGETATTR 1
+
+/* Define to 1 if you have the `tcsetattr' function. */
+#cmakedefine HAVE_TCSETATTR 1
+
 /* Define to 1 if you have the `timegm' function. */
 #cmakedefine HAVE_TIMEGM 1
 
index 8e313186227232d6659f76e81b9b5db7ce25a640..1bb2c76bfc8ba0643c86ad6eef42ead09aa548df 100644 (file)
@@ -833,6 +833,7 @@ AC_CHECK_FUNCS([readpassphrase])
 AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
 AC_CHECK_FUNCS([sysconf])
+AC_CHECK_FUNCS([tcgetattr tcsetattr])
 AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
 AC_CHECK_FUNCS([_fseeki64 _get_timezone])
index 0ccb20c4e8c4506d5725990a7e059f2d9ef87730..00fa4e9fdcfa5cb97d7b4164fdfc67f740761e27 100644 (file)
 #define HAVE_SYS_UTSNAME_H 1
 #define HAVE_SYS_VFS_H 1
 #define HAVE_SYS_WAIT_H 1
+#define HAVE_TCGETATTR 1
+#define HAVE_TCSETATTR 1
 #define HAVE_TIME_H 1
 #define HAVE_TZSET 1
 #define HAVE_UINTMAX_T 1
index 371c6cc480ad05ed251569b146f556bd898ae1f1..f0f7ab39ca178df789ffbbe54a00f08d6404fb18 100644 (file)
 #define HAVE_SYS_VFS_H 1
 #define HAVE_SYS_WAIT_H 1
 #define HAVE_SYS_XATTR_H 1
+#define HAVE_TCGETATTR 1
+#define HAVE_TCSETATTR 1
 #define HAVE_TIMEGM 1
 #define HAVE_TIME_H 1
 #define HAVE_TZSET 1
index 5210a4db5c7fd0081e3acc16e9b01a67ff1fc710..da821cc04a6d1f264e3a3ebe4ab3fc5fb7f098b1 100644 (file)
 /* Define to 1 if you have the <sys/xattr.h> header file. */
 /* #undef HAVE_SYS_XATTR_H */
 
+/* Define to 1 if you have the `tcgetattr' function. */
+/* #undef HAVE_TCGETATTR */
+
+/* Define to 1 if you have the `tcsetattr' function. */
+/* #undef HAVE_TCSETATTR */
+
 /* Define to 1 if you have the `timegm' function. */
 /* #undef HAVE_TIMEGM */
 
index a1bf0dfe9f793da67f301f0a4c7e7cbf0df765e2..5b36e1695de7e3f69b1e597324561e04370898a8 100644 (file)
 #define HAVE_SYS_TYPES_H 1
 #define HAVE_SYS_UTSNAME_H 1
 #define HAVE_SYS_WAIT_H 1
+#define HAVE_TCGETATTR 1
+#define HAVE_TCSETATTR 1
 #define HAVE_TIMEGM 1
 #define HAVE_TIME_H 1
 #define HAVE_TZSET 1
index 90fef32d254c9b43dda12e8e2068b145a2104222..527ad2d63654b70fba45ab53f01ed7f44aa2451a 100644 (file)
@@ -119,7 +119,7 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
        return (buf);
 }
 
-#else /* _WIN32 && !__CYGWIN__ */
+#elif defined(HAVE_TCGETATTR) && defined(HAVE_TCSETATTR)
 
 #include <assert.h>
 #include <ctype.h>
@@ -314,7 +314,13 @@ restart:
                errno = save_errno;
        return(nr == -1 ? NULL : buf);
 }
-#endif /* _WIN32 && !__CYGWIN__ */
+#else
+static char *
+readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
+{
+       return (NULL);
+}
+#endif
 #endif /* HAVE_READPASSPHRASE */
 
 char *