Skip to content

Commit 819c5b0

Browse files
authored
Check for tcgetattr / tcsetattr before using it for readpassphrase implementation (#2424)
This is mainly for non-cygwin newlib platforms that don't have tcgetattr / tcsetattr implemented
1 parent b5d9532 commit 819c5b0

File tree

8 files changed

+29
-2
lines changed

8 files changed

+29
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,8 @@ CHECK_FUNCTION_EXISTS_GLIBC(strnlen HAVE_STRNLEN)
15251525
CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR)
15261526
CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK)
15271527
CHECK_FUNCTION_EXISTS_GLIBC(sysconf HAVE_SYSCONF)
1528+
CHECK_FUNCTION_EXISTS_GLIBC(tcgetattr HAVE_TCGETATTR)
1529+
CHECK_FUNCTION_EXISTS_GLIBC(tcsetattr HAVE_TCSETATTR)
15281530
CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM)
15291531
CHECK_FUNCTION_EXISTS_GLIBC(tzset HAVE_TZSET)
15301532
CHECK_FUNCTION_EXISTS_GLIBC(unlinkat HAVE_UNLINKAT)

build/cmake/config.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,12 @@ typedef uint64_t uintmax_t;
11751175
/* Define to 1 if you have the <sys/xattr.h> header file. */
11761176
#cmakedefine HAVE_SYS_XATTR_H 1
11771177

1178+
/* Define to 1 if you have the `tcgetattr' function. */
1179+
#cmakedefine HAVE_TCGETATTR 1
1180+
1181+
/* Define to 1 if you have the `tcsetattr' function. */
1182+
#cmakedefine HAVE_TCSETATTR 1
1183+
11781184
/* Define to 1 if you have the `timegm' function. */
11791185
#cmakedefine HAVE_TIMEGM 1
11801186

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ AC_CHECK_FUNCS([readpassphrase])
835835
AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
836836
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
837837
AC_CHECK_FUNCS([sysconf])
838+
AC_CHECK_FUNCS([tcgetattr tcsetattr])
838839
AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
839840
AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
840841
AC_CHECK_FUNCS([_fseeki64 _get_timezone])

contrib/android/config/android.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@
151151
#define HAVE_SYS_UTSNAME_H 1
152152
#define HAVE_SYS_VFS_H 1
153153
#define HAVE_SYS_WAIT_H 1
154+
#define HAVE_TCGETATTR 1
155+
#define HAVE_TCSETATTR 1
154156
#define HAVE_TIME_H 1
155157
#define HAVE_TZSET 1
156158
#define HAVE_UINTMAX_T 1

contrib/android/config/linux_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
#define HAVE_SYS_VFS_H 1
154154
#define HAVE_SYS_WAIT_H 1
155155
#define HAVE_SYS_XATTR_H 1
156+
#define HAVE_TCGETATTR 1
157+
#define HAVE_TCSETATTR 1
156158
#define HAVE_TIMEGM 1
157159
#define HAVE_TIME_H 1
158160
#define HAVE_TZSET 1

contrib/android/config/windows_host.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,12 @@
827827
/* Define to 1 if you have the <sys/xattr.h> header file. */
828828
/* #undef HAVE_SYS_XATTR_H */
829829

830+
/* Define to 1 if you have the `tcgetattr' function. */
831+
/* #undef HAVE_TCGETATTR */
832+
833+
/* Define to 1 if you have the `tcsetattr' function. */
834+
/* #undef HAVE_TCSETATTR */
835+
830836
/* Define to 1 if you have the `timegm' function. */
831837
/* #undef HAVE_TIMEGM */
832838

libarchive/config_freebsd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@
210210
#define HAVE_SYS_TYPES_H 1
211211
#define HAVE_SYS_UTSNAME_H 1
212212
#define HAVE_SYS_WAIT_H 1
213+
#define HAVE_TCGETATTR 1
214+
#define HAVE_TCSETATTR 1
213215
#define HAVE_TIMEGM 1
214216
#define HAVE_TIME_H 1
215217
#define HAVE_TZSET 1

libarchive_fe/passphrase.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
119119
return (buf);
120120
}
121121

122-
#else /* _WIN32 && !__CYGWIN__ */
122+
#elif defined(HAVE_TCGETATTR) && defined(HAVE_TCSETATTR)
123123

124124
#include <assert.h>
125125
#include <ctype.h>
@@ -314,7 +314,13 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
314314
errno = save_errno;
315315
return(nr == -1 ? NULL : buf);
316316
}
317-
#endif /* _WIN32 && !__CYGWIN__ */
317+
#else
318+
static char *
319+
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
320+
{
321+
return (NULL);
322+
}
323+
#endif
318324
#endif /* HAVE_READPASSPHRASE */
319325

320326
char *

0 commit comments

Comments
 (0)