ttyname in gpgme when running Android

Hans-Christoph Steiner hans at guardianproject.info
Wed Oct 24 02:43:38 CEST 2012


On 10/23/2012 07:19 PM, Hans-Christoph Steiner wrote:
> 
> 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

I think I figured out m4 enough to get something working, and it might even be
an acceptable patch. I attached it in "git format-patch" style.

.hc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Android-does-not-have-ttyname-or-ttyname_r-use-repla.patch
Type: text/x-patch
Size: 2009 bytes
Desc: not available
URL: </pipermail/attachments/20121023/78b9477f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 937 bytes
Desc: OpenPGP digital signature
URL: </pipermail/attachments/20121023/78b9477f/attachment.pgp>


More information about the Gnupg-devel mailing list