gpgme-1.3.0 porting issues on no-GNU platforms

Uldis.Ansmits at tieto.com Uldis.Ansmits at tieto.com
Tue Feb 23 16:01:36 CET 2010


gpgme-1.3.0 has been compiled and tested on following non-GNU systems:
  hppa2.0w-hp-hpux11.00
  ia64-hp-hpux11.31
  sparc-sun-solaris2.7
  sparc-sun-solaris2.10
  powerpc-ibm-aix5.2.0.0

Compiler:
  gcc-4.2

Other libraries:
  libgpg-error-1.7
  libassuan-2.0.0

There were few porting issues. I would like to clarify if they are valid.

Runtime issues --------------------------------------------

Patches for gpgme-1.3.0

Critical on AIX. getrlimit return INFINITY for rlim_max. Probably it
would better to write "fds = min(rl.rlim_max,rl.rlim_cur)" because
it is waste of resources to close more handles than user limit.
Without this patch time to spawning new process on AIX takes forever.
Similar problem affects gpg-agent form gnupg2.
--- src/posix-io.c.ORIG 2009-11-11 13:38:20.000000000 +0200
+++ src/posix-io.c      2009-11-11 14:13:10.000000000 +0200
@@ -225,7 +225,7 @@
     if (rc == 0)
       {
        source = "RLIMIT_NOFILE";
-       fds = rl.rlim_max;
+       fds = rl.rlim_cur;
       }
   }
 #endif
@@ -237,7 +237,7 @@
       if (rc == 0)
        {
          source = "RLIMIT_OFILE";
-         fds = rl.rlim_max;
+         fds = rl.rlim_cur;
        }
     }
 #endif

Critical on Solaris. "rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));" will fail
with ERANGE if size of dft_ttyname is 64 bytes. src/engine-assuan.c, src/engine-gpg.c and
src/engine-gpgsm.c must be modified for bigger array.
--- src/engine-assuan.c.ORIG    2009-11-11 17:38:50.000000000 +0200
+++ src/engine-assuan.c 2009-11-11 17:38:50.000000000 +0200
@@ -28,6 +28,7 @@
 #include <config.h>
 #endif

+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
@@ -245,7 +246,11 @@
   if (llass->opt.gpg_agent && isatty (1))
     {
       int rc;
+#ifdef _POSIX_PATH_MAX
+      char dft_ttyname[_POSIX_PATH_MAX];
+#else
       char dft_ttyname[64];
+#endif
       char *dft_ttytype = NULL;

       rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));


This is non-critical because is not typical real-world case. When using several contexts
simultaneously, callback functions are called with invalid parameter arguments and data
get lost. This can be reproduced with callback based data buffers and when gpgme_wait(,,0)
is called for different contexts. Perhaps this is topic for different thread. After this
modification "simultenious" callback operations works fine. There are more wait operations though.
--- src/wait-global.c.ORIG      2010-01-12 12:55:22.000000000 +0200
+++ src/wait-global.c   2010-01-12 12:55:44.000000000 +0200
@@ -304,6 +304,15 @@
              ictx = item->ctx;
              assert (ictx);

+             /* Run on specified context only */
+             if(ctx)
+               {
+                 if(ictx != ctx)
+                  {
+                    continue;
+                  }
+               }
+
              LOCK (ctx->lock);
              if (ctx->canceled)
                err = gpg_error (GPG_ERR_CANCELED);

This is also non-critical. _gpgme_debug_buffer from src/debug.c is very CPU expensive compared
to the rest of gpgme operations. Makes sense to disable debugging for the weak sparch processors.
Would be nice to have a configure option.
--- src/debug.h.ORIG    2010-01-14 13:19:42.000000000 +0200
+++ src/debug.h 2010-01-14 13:19:54.000000000 +0200
@@ -75,7 +75,7 @@
 /* Trace support.  */

 /* FIXME: For now.  */
-#define _gpgme_debug_trace() 1
+#define _gpgme_debug_trace() 0

 #define _TRACE(lvl, name, tag)                                 \
   int _gpgme_trace_level = lvl;                                        \

Building issues --------------------------------------------

Patch for libgpg-error-1.7

Build time programs require system specific linking options. For example on AIX
link option "-Wl,-brtl" will enable runtime linking or on Solaris set of
system libraries is required.
--- src/Makefile.in.ORIG        2009-12-10 16:34:56.000000000 +0200
+++ src/Makefile.in     2009-12-10 16:38:21.000000000 +0200
@@ -846,7 +846,7 @@
 # It is correct to use $(CC_FOR_BUILD) here.  We want to run the
 # program at build time.
 mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile
-       $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c
+       $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c $(CFLAGS) $(LDFLAGS)

 code-from-errno.h: mkerrcodes Makefile
        ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@

Patches for gpgme-1.3.0
Compile time program gpgme_tool needs libassuan
--- src/Makefile.in.ORIG        2010-02-23 13:07:06.000000000 +0200
+++ src/Makefile.in     2010-02-23 13:07:06.000000000 +0200
@@ -709,7 +709,7 @@
        rm -f $$list
 gpgme-tool$(EXEEXT): $(gpgme_tool_OBJECTS) $(gpgme_tool_DEPENDENCIES)
        @rm -f gpgme-tool$(EXEEXT)
-       $(LINK) $(gpgme_tool_OBJECTS) $(gpgme_tool_LDADD) $(LIBS)
+       $(LINK) $(gpgme_tool_OBJECTS) $(gpgme_tool_LDADD) $(LIBS) $(LIBASSUAN_LIBS)
 gpgme-w32spawn$(EXEEXT): $(gpgme_w32spawn_OBJECTS) $(gpgme_w32spawn_DEPENDENCIES)
        @rm -f gpgme-w32spawn$(EXEEXT)
        $(LINK) $(gpgme_w32spawn_OBJECTS) $(gpgme_w32spawn_LDADD) $(LIBS)


getopt.h is missing on non-GNU system.
--- src/gpgme-tool.c.ORIG       2010-02-23 13:51:06.000000000 +0200
+++ src/gpgme-tool.c    2010-02-23 13:51:06.000000000 +0200
@@ -25,7 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <getopt.h>
+/* Avoid using getopt.h. Missing on non-GNU platform */
+/* #include <getopt.h> */
 #include <ctype.h>
 #include <stdarg.h>
 #include <locale.h>

Regards,
Uldis


More information about the Gnupg-devel mailing list