Fix ttyname problem on Android.
* configure.ac: Define macro and conditional HAVE_ANDROID_SYSTEM. * m4/gnupg-ttyname.m4: Force use of replacement on Android. * src/ttyname_r.c: Ditto. -- Android's bionic lib has no working ttyname_r() nor ttyname(). Using them anyway will print FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:466 Thus we force the use of our replacement code which simply return "/dev/tty".
This commit is contained in:
parent
cc59b75b21
commit
12a0c93433
@ -131,6 +131,7 @@ GPGCONF_DEFAULT=no
|
|||||||
G13_DEFAULT=no
|
G13_DEFAULT=no
|
||||||
component_system=None
|
component_system=None
|
||||||
have_dosish_system=no
|
have_dosish_system=no
|
||||||
|
have_android_system=no
|
||||||
have_w32_system=no
|
have_w32_system=no
|
||||||
have_w64_system=no
|
have_w64_system=no
|
||||||
build_w32_glib=no
|
build_w32_glib=no
|
||||||
@ -142,6 +143,9 @@ case "${host}" in
|
|||||||
*-mingw32ce*)
|
*-mingw32ce*)
|
||||||
have_w32ce_system=yes
|
have_w32ce_system=yes
|
||||||
;;
|
;;
|
||||||
|
*-linux-androideabi)
|
||||||
|
have_android_system=yes
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
case "${host}" in
|
case "${host}" in
|
||||||
*-mingw32ce*|*-mingw32*)
|
*-mingw32ce*|*-mingw32*)
|
||||||
@ -210,6 +214,11 @@ if test "$have_w32ce_system" = yes; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
|
AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
|
||||||
|
|
||||||
|
if test "$have_android_system" = yes; then
|
||||||
|
AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
|
||||||
|
|
||||||
AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
|
AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
|
||||||
AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
|
AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
# The macro REPLACE_TTYNAME_R is defined if ttyname_r is a replacement
|
# The macro REPLACE_TTYNAME_R is defined if ttyname_r is a replacement
|
||||||
# function. This macro is useful for the definition of the prototype.
|
# function. This macro is useful for the definition of the prototype.
|
||||||
#
|
#
|
||||||
|
# If the macro "have_android_system" has a value of "yes", ttyname_r
|
||||||
|
# will also be replaced by our own function.
|
||||||
|
#
|
||||||
AC_DEFUN([gnupg_REPLACE_TTYNAME_R],
|
AC_DEFUN([gnupg_REPLACE_TTYNAME_R],
|
||||||
[
|
[
|
||||||
AC_CHECK_HEADERS([unistd.h])
|
AC_CHECK_HEADERS([unistd.h])
|
||||||
@ -60,6 +63,12 @@ AC_DEFUN([gnupg_REPLACE_TTYNAME_R],
|
|||||||
if test $gnupg_cv_func_ttyname_r_posix = no; then
|
if test $gnupg_cv_func_ttyname_r_posix = no; then
|
||||||
AC_LIBOBJ([ttyname_r])
|
AC_LIBOBJ([ttyname_r])
|
||||||
AC_DEFINE([REPLACE_TTYNAME_R],[1])
|
AC_DEFINE([REPLACE_TTYNAME_R],[1])
|
||||||
|
elif test "$have_android_system" = yes; then
|
||||||
|
# Android has ttyname and ttyname_r but they are only stubs and
|
||||||
|
# print an annoying warning message. Thus we need to replace
|
||||||
|
# ttyname_r with our own dummy function.
|
||||||
|
AC_LIBOBJ([ttyname_r])
|
||||||
|
AC_DEFINE([REPLACE_TTYNAME_R],[1])
|
||||||
else
|
else
|
||||||
AC_DEFINE([HAVE_POSIXDECL_TTYNAME_R], [1],
|
AC_DEFINE([HAVE_POSIXDECL_TTYNAME_R], [1],
|
||||||
[Define if the ttyname_r function has a POSIX compliant declaration.])
|
[Define if the ttyname_r function has a POSIX compliant declaration.])
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
# warning ttyname is not thread-safe, and ttyname_r is missing
|
# warning ttyname is not thread-safe, and ttyname_r is missing
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* For Android we force the use of our replacement code. */
|
||||||
|
#if HAVE_ANDROID_SYSTEM
|
||||||
|
# undef HAVE_TTYNAME_R
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_gpgme_ttyname_r (int fd, char *buf, size_t buflen)
|
_gpgme_ttyname_r (int fd, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
@ -110,12 +116,11 @@ _gpgme_ttyname_r (int fd, char *buf, size_t buflen)
|
|||||||
#else /*!HAVE_TTYNAME_R*/
|
#else /*!HAVE_TTYNAME_R*/
|
||||||
char *tty;
|
char *tty;
|
||||||
|
|
||||||
# if HAVE_W32_SYSTEM
|
# if HAVE_W32_SYSTEM || HAVE_ANDROID_SYSTEM
|
||||||
/* We use this default one for now. AFAICS we only need it to be
|
/* We use this default one for now. AFAICS we only need it to be
|
||||||
passed to gpg and in turn to pinentry. Providing a replacement
|
passed to gpg and in turn to pinentry. Providing a replacement
|
||||||
is needed because elsewhere we bail out on error. If we
|
is needed because elsewhere we bail out on error or Android
|
||||||
eventually implement a pinentry for Windows it is inlikely that
|
provided ttyname_r prints an error message if used. */
|
||||||
we need a real tty at all. */
|
|
||||||
tty = "/dev/tty";
|
tty = "/dev/tty";
|
||||||
# else
|
# else
|
||||||
tty = ttyname (fd);
|
tty = ttyname (fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user