[gnutls-help] Compiling gnutls on solaris

dev dev at cor0.com
Sat Sep 27 12:56:31 CEST 2014



On September 27, 2014 at 3:01 AM Nikos Mavrogiannopoulos
<nmav at gnutls.org> wrote:
> On Fri, 2014-09-26 at 15:29 -0400, dev wrote:
>
> > Just did a clone and the new lib/x509/verify-high2.c is *wildly*
> > different
> > from the source file in the release tarball to the extent that the
> > function
> > load_dir_certs() is gone entirely.
> >
> > Let me check here :
> >
> > node000$ /usr/local/bin/git clone
> > git://git.savannah.gnu.org/gnutls.git
>
> Gnutls' repository was moved to gitorious some time ago.
> It is: git://gitorious.org/gnutls/gnutls.git
>
> regards,
> Nikos
>
>

OKay, thank you for the redirection of my brain and once again I think
we have progress .. so let's see what we have here :

node000$ git clone git://gitorious.org/gnutls/gnutls.git
Cloning into 'gnutls'...
remote: Counting objects: 150790, done.
remote: Compressing objects: 100% (28109/28109), done.
remote: Total 150790 (delta 127792), reused 145271 (delta 122296)
Receiving objects: 100% (150790/150790), 60.87 MiB | 302.00 KiB/s, done.
Resolving deltas: 100% (127792/127792), done.
Checking connectivity... done.
Checking out files: 100% (1977/1977), done.


nice .. I will take the once file that I am looking for now :

node000$ cp -p ./gnutls/lib/x509/verify-high2.c \
> /usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/x509/verify-high2.c

head back to my build area for various things like GNU TLS :

node000$ cd /usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/


... and do a quick look :

node000$ ls -lapb lib/x509/verify-high2.*
-rw-r--r--   1 dclarke  devl       10543 Sep 27 09:59
lib/x509/verify-high2.c
-rw-r--r--   1 dclarke  devl       10408 Sep 12 16:31
lib/x509/verify-high2.c_


The one with the trailing underscore is my backup of the original file
from the release tarball.


node000$ diff -cut lib/x509/verify-high2.c_ lib/x509/verify-high2.c
--- lib/x509/verify-high2.c_    Fri Sep 12 16:31:50 2014
+++ lib/x509/verify-high2.c     Sat Sep 27 09:59:18 2014
@@ -36,6 +36,12 @@

 #include <dirent.h>

+#ifndef _DIRENT_HAVE_D_TYPE
+# ifdef DT_UNKNOWN
+#  define _DIRENT_HAVE_D_TYPE
+# endif
+#endif
+
 /* Convenience functions for verify-high functionality
  */

@@ -309,8 +315,12 @@
 #else
                         struct dirent e;
                         ret = readdir_r(dirp, &e, &d);
-                        if (ret == 0 && d != NULL && (d->d_type ==
DT_REG || d->d_type == DT_LNK || d->d_type == DT_UNKNOWN)) {
+                        if (ret == 0 && d != NULL
+#ifdef _DIRENT_HAVE_D_TYPE
+                                && (d->d_type == DT_REG || d->d_type ==
DT_LNK || d->d_type == DT_UNKNOWN)
 #endif
+                        ) {
+#endif
                                 snprintf(path, sizeof(path), "%s/%s",
                                          dirname, d->d_name);



OKay .. so let me see if I can re-format that a bit to get things into
72 chars wide neatly by swapping the tabs for four-spaces and then a
little re-jigger of things from line 297 onwards into func
load_dir_certs() :


static
int load_dir_certs(const char *dirname,
                   gnutls_x509_trust_list_t list,
                   unsigned int tl_flags, unsigned int tl_vflags,
                   unsigned type, unsigned crl)
{
    DIR *dirp;
    struct dirent *d;
    int ret;
    int r = 0;
    char path[GNUTLS_PATH_MAX];

    dirp = opendir(dirname);
    if (dirp != NULL) {
        do {
#ifdef _WIN32
            d = readdir(dirp);
            if (d != NULL) {
#else
            struct dirent e;
            ret = readdir_r(dirp, &e, &d);
            if (ret == 0 && d != NULL
#ifdef _DIRENT_HAVE_D_TYPE
                && (   ( d->d_type == DT_REG )
                    || ( d->d_type == DT_LNK )
                    || ( d->d_type == DT_UNKNOWN )
                   )
#endif
            ) {
#endif
                snprintf(path, sizeof(path), "%s/%s",
                     dirname, d->d_name);

                if (crl != 0) {
                    ret =
                        gnutls_x509_trust_list_add_trust_file
                        (list, NULL, path, type, tl_flags,
                         tl_vflags);
                } else {
                    ret =
                        gnutls_x509_trust_list_add_trust_file
                        (list, path, NULL, type, tl_flags,
                         tl_vflags);
                }
                if (ret >= 0)
                    r += ret;
            }
        }
        while (d != NULL);
        closedir(dirp);
    }

    return r;
}

Yeah I know. I'm a bit pedantic but that looks more readable.  Sorry.

Okay .. so we have a new ifdef in there as opposed to going fully
portable.  However if those condition checks for a DT_REG or DT_LNK or
the default DT_UNKNOWN are a throwaway then why have them at all? It
looks like the result here is ( if you don't have that d_type stuff in
dirent.h ) then ( ignore this anyways ) is the end result here.  I know
this has been beaten to death over the years in a million places but I
do wish that DT_UNKNOWN was returned on all systems where we don't have
d_type in the struct dirent.

OKay for the moment and let me just look at that ifdef chunk at the top
there from line 36 :


#include <dirent.h>

#ifndef _DIRENT_HAVE_D_TYPE
# ifdef DT_UNKNOWN
#  define _DIRENT_HAVE_D_TYPE
# endif
#endif


huh ... okay.  I guess.


Really what is on my mind here is why the need for the d_type bits at
all inside that function.

dunno really .. but let's try a new fresh rebuild with this change and
only this change from where things stopped last time :



node000$
node000$ gmake
/usr/local/bin/gmake  all-recursive
gmake[1]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001'
Making all in gl
gmake[2]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl'
/usr/local/bin/gmake  all-recursive
gmake[3]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl'
Making all in tests
gmake[4]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl/tests'
/usr/local/bin/gmake  all-recursive
gmake[5]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl/tests'
Making all in .
gmake[6]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl/tests'
gmake[6]: Nothing to be done for `all-am'.
gmake[6]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl/tests'
gmake[5]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl/tests'
gmake[4]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl/tests'
gmake[4]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl'
gmake[4]: Nothing to be done for `all-am'.
gmake[4]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl'
gmake[3]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl'
gmake[2]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/gl'
Making all in lib
gmake[2]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib'
/usr/local/bin/gmake  all-recursive
gmake[3]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib'
Making all in includes
gmake[4]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/includes'
gmake[4]: Nothing to be done for `all'.
gmake[4]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/includes'
Making all in x509
gmake[4]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/x509'
  CC       verify-high2.lo
  CC       x509_ext.lo
  CC       ocsp.lo
  CC       ocsp_output.lo
  CCLD     libgnutls_x509.la
gmake[4]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/x509'
Making all in auth
.
.
.


Excellent !  We are past the x509 directory with that change.

Things move along nicely until I see :


gmake[4]: Entering directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/opencdk'
  CC       armor.lo
  CC       kbnode.lo
  CC       sig-check.lo
  CC       keydb.lo
"keydb.c", line 1955: warning: statement not reached
"keydb.c", line 2276: warning: statement not reached
  CC       pubkey.lo
"pubkey.c", line 645: warning: statement not reached
  CC       stream.lo


Note .. I am going to insert some blank lines here just for clarity.


"stream.c", line 668: warning: return value type mismatch
"stream.c", line 670: warning: return value type mismatch
"stream.c", line 672: warning: return value type mismatch
"stream.c", line 1119: warning:
                             argument #2 is incompatible with prototype:

123456789+123456789+123456789+123456789+123456789+123456789+123456789+12

        prototype: pointer to
           function(pointer to void, int,
                    pointer to struct __FILE {array[16] of long __pad},
                    pointer to struct __FILE {array[16] of long __pad})
                    returning enum  {CDK_Network_Error(28),
                                     CDK_No_Passphrase(27),
                                     CDK_No_Data(26),
                                     CDK_Unusable_Key(25),
                                     CDK_Too_Short(24),
                                     CDK_Inv_Packet_Ver(23),
                                     CDK_Wrong_Format(22),
                                     CDK_Error_No_Keyring(21),
                                     CDK_Inv_Mode(20),
                                     CDK_Bad_MDC(19),
                                     CDK_Wrong_Seckey(18),
                                     CDK_Out_Of_Core(17),
                                     CDK_Weak_Key(16),
                                     CDK_Zlib_Error(15),
                                     CDK_Time_Conflict(14),
                                     CDK_Chksum_Error(13),
                                     CDK_Error_No_Key(12),
                                     CDK_Inv_Value(11),
                                     CDK_MPI_Error(10),
                                     CDK_Armor_CRC_Error(9),
                                     CDK_Armor_Error(8),
                                     CDK_Not_Implemented(6),
                                     CDK_Inv_Algo(5),
                                     CDK_Inv_Packet(4),
                                     CDK_Bad_Sig(3),
                                     CDK_File_Error(2),
                                     CDK_General_Error(1),
                                     CDK_Success(0),
                                     CDK_EOF(-1)} : "stream.c",

line 632

        argument : pointer to
           function(pointer to void, int,
                    pointer to struct __FILE {array[16] of long __pad},
                    pointer to struct __FILE {array[16] of long __pad})
           returning int

"stream.c", line 1158: warning: argument #2 is incompatible with
prototype:

etc etc etc and other noisey output from the Oracle Studio 12.3 compiler
kit, which is fine because I asked for it ;-)

  CC       write-packet.lo
  CC       misc.lo
  CC       seskey.lo
  CC       literal.lo
"literal.c", line 160: warning: statement not reached
  CC       new-packet.lo
  CC       read-packet.lo
  CCLD     libminiopencdk.la
gmake[4]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib/opencdk'
Making all in openpgp
.
.
.

OKay .. so as you can see I have really verbose options enabled and so I
will climb into lib/opencdk/stream.c and see if I can sort out the
noisey type mismatch warnings.


Those are just warnings however ... build does continue up until here :


  CCLD     libgnutls.la
Undefined                       first referenced
 symbol                             in file
inet_aton
                          x509/.libs/libgnutls_x509.a(rfc2818_hostname.o)
 (symbol belongs to implicit dependency /lib/64/libnsl.so.1)
ld: fatal: symbol referencing errors. No output written to
.libs/libgnutls.so.28.41.0
gmake[4]: *** [libgnutls.la] Error 2
gmake[4]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib'
gmake[3]: *** [all-recursive] Error 1
gmake[3]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001/lib'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory
`/usr/local/build/gnutls-3.3.8_SunOS5.10_sparcv9_001'
gmake: *** [all] Error 2
node000$

OKay, this looks familiar and I remember running into this last time I
tried a build of gnutls and I think I recall the solution was we need
-lsocket -lnsl on Solaris because the socket funcs inet_ntop, inet_ntoa
etc etc are buried somewhere in some lib.  We definately need this :

     #include <sys/types.h>
     #include <sys/socket.h>
     #include <netinet/in.h>
     #include <arpa/inet.h>

In any case we have progress and let me hack at it and I will certainly
let you know.

Just aside, I see two flavours of inet_pton.c here at ./lib/inet_pton.c
and also ./src/gl/inet_pton.c which is different.

One is a version from ISC and the other from the FSF.  Okay .. I'll look
into this also to see if there is a reason for why these are separate,
different or why they even exist or whatever .. don't know.  This means
coffee needed.


Dennis



More information about the Gnutls-help mailing list