ttyname in gpgme when running Android

Hans-Christoph Steiner hans at guardianproject.info
Wed Oct 24 01:19:39 CEST 2012


So with gnupg we went thru this also, and looks like the same issue in gpgme.
I built the gpgme tests and ran them by hand on the emulator:

$ ./run-keylist
FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:466
run-keylist: file run-keylist.c line 154: <GPGME> Unknown system error

Android's bionic lib has neither ttyname_r() nor ttyname().  I tried to make
sense of m4/gnupg-ttyname.m4 but my m4 skills are very weak, and didn't have
any tangible results.  So to get things working, I resorted to a quick macro
test which gives me a working ./run-keylist test :-D

diff --git a/src/ttyname_r.c b/src/ttyname_r.c
index 105e0af..fa49a6b 100644
--- a/src/ttyname_r.c
+++ b/src/ttyname_r.c
@@ -35,7 +35,7 @@
 int
 _gpgme_ttyname_r (int fd, char *buf, size_t buflen)
 {
-#if HAVE_TTYNAME_R
+#if HAVE_TTYNAME_R && !defined __ANDROID__
 # if HAVE_BROKEN_TTYNAME_R
    /* Solaris fails if BUFLEN is less than 128. OSF/1 5.1 completely
       ignores BUFLEN.  We use a large buffer to woraround this.  */
@@ -110,7 +110,7 @@ _gpgme_ttyname_r (int fd, char *buf, size_t buflen)
 #else /*!HAVE_TTYNAME_R*/
   char *tty;

-# if HAVE_W32_SYSTEM
+# if HAVE_W32_SYSTEM || defined __ANDROID__
   /* 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
      is needed because elsewhere we bail out on error.  If we


.hc



More information about the Gnupg-devel mailing list