FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:360

Hans-Christoph Steiner hans at guardianproject.info
Wed Feb 15 20:29:56 CET 2012


I applied it and it died with an error.  It seems that not all uses of
ttyname() are protected with HAVE_TTYNAME:

/usr/local/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
--sysroot=/usr/local/android-ndk/platforms/android-9/arch-arm
-I/data/local/include -I/usr/local/include -I/data/local/include
-I/usr/local/include
-I/media/share/code/guardianproject/gnupg-for-android/external/data/local/include
-I/usr/local/include -DANDROID
-I/media/share/code/guardianproject/gnupg-for-android/external/data/local/include
-O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wformat
-Wno-format-y2k -Wformat-security -W -Wno-sign-compare
-Wno-missing-field-initializers -Wdeclaration-after-statement
-Wno-pointer-sign -Wpointer-arith
-L/media/share/code/guardianproject/gnupg-for-android/external/data/local/lib
-Wl,--rpath,/media/share/code/guardianproject/gnupg-for-android/external/data/local/lib
-o t-session-env t-session-env.o libcommon.a ../gl/libgnu.a
-L/data/local/lib -lgcrypt -L/usr/local/lib -lgpg-error
-L/data/local/lib -lassuan -L/usr/local/lib -lgpg-error -L/usr/local/lib
-lgpg-error
libcommon.a(libcommon_a-session-env.o): In function
`session_env_getenv_or_default':
session-env.c:(.text+0x5b8): undefined reference to `broken_native_ttyname'
session-env.c:(.text+0x5c8): undefined reference to `broken_native_ttyname'

config.h had "#define HAVE_TTYNAME 1" in the __ANDROID__ block, so that
is also a potential point of failure. Here's the whole chunk from config.h:

/* Hacks required for Android.  */
#ifdef __ANDROID__
  /* ttyname is a stub in BIONIC, printing a FIXME warning.  */
# define ttyname broken_native_ttyname
# define HAVE_TTYNAME 1
#endif /*__ANDROID__*/


'make clean' and then manually changing "# define HAVE_TTYNAME 1" to "#
undef HAVE_TTYNAME" got me here:

/usr/local/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
--sysroot=/usr/local/android-ndk/platforms/android-9/arch-arm
-DHAVE_CONFIG_H -I. -I..  -I../gl -I../intl
-DLOCALEDIR=\"/data/local/share/locale\"
-DGNUPG_BINDIR="\"/data/local/bin\""
-DGNUPG_LIBEXECDIR="\"/data/local/libexec\""
-DGNUPG_LIBDIR="\"/data/local/lib/gnupg\""
-DGNUPG_DATADIR="\"/data/local/share/gnupg\""
-DGNUPG_SYSCONFDIR="\"/data/local/etc/gnupg\""
-DGNUPG_LOCALSTATEDIR="\"/data/local/var\""        -I/data/local/include
-I/usr/local/include -I/data/local/include -I/usr/local/include
-I/media/share/code/guardianproject/gnupg-for-android/external/data/local/include
-I/usr/local/include -I/data/local/include -I/usr/local/include
-DWITHOUT_GNU_PTH=1 -DANDROID
-I/media/share/code/guardianproject/gnupg-for-android/external/data/local/include
-O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wformat
-Wno-format-y2k -Wformat-security -W -Wno-sign-compare
-Wno-missing-field-initializers -Wdeclaration-after-statement
-Wno-pointer-sign -Wpointer-arith -MT libcommon_a-estream.o -MD -MP -MF
.deps/libcommon_a-estream.Tpo -c -o libcommon_a-estream.o `test -f
'estream.c' || echo './'`estream.c
In file included from estream.c:99:
../common/util.h:292: error: static declaration of
'broken_native_ttyname' follows non-static declaration
/usr/local/android-ndk/platforms/android-9/arch-arm/usr/include/unistd.h:165:
note: previous declaration of 'broken_native_ttyname' was here


.hc


On 02/01/2012 08:18 AM, Werner Koch wrote:
> Hi,
> 
> please try this patch:
> 
> diff --git a/configure.ac b/configure.ac
> index f008d23..47c6d12 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -490,6 +490,13 @@ AH_BOTTOM([
>  # endif
>  #endif
>  
> +/* Hacks required for Android.  */
> +#ifdef __ANDROID__
> +  /* ttyname is a stub in BIONIC, printing a FIXME warning.  */
> +# define ttyname broken_native_ttyname
> +# undef HAVE_TTYNAME
> +#endif /*__ANDROID__*/
> +
>  
>  /* Tell libgcrypt not to use its own libgpg-error implementation. */
>  #define USE_LIBGPG_ERROR 1
> 
> 
> 
> Salam-Shalom,
> 
>    Werner
> 



More information about the Gnupg-devel mailing list