[PATCHES] Fix build with system provided Heimdal library

Christof Schmitt cs at samba.org
Tue Jun 26 22:07:18 UTC 2018

This was triggered by the fact that Ubuntu 18.04 provides libldap that
depends on the Heimdal kerberos library. Building a simple Samba file
server with the requirement that only one Kerberos is used, then
requires building against the system provided Heimdal library (as
libldap already has the dependency).

The configure command which allowed this to work was:

./configure \
 --without-ad-dc --disable-cups

Note that on this system --disable-cups was required as well, as libcups
in Ubuntu 18.04 depends on MIT kerberos.

The two attached patches are required for this build to succeed.

-------------- next part --------------
From 3fd8f40d05bdb5bb75e0652949d2312dfdf31a1b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 26 Jun 2018 13:30:06 -0700
Subject: [PATCH 1/2] winbindd: Remove ads.h include from nss_info

nss_info does not use libads. Removing this include
fixes a compile error when trying to compile with a
system provided heimdal library:

[2188/3043] Compiling source3/winbindd/nss_info.c
In file included from ../source3/libads/kerberos_proto.h:33:0,
                 from ../source3/include/ads.h:154,
                 from ../source3/winbindd/nss_info.c:24:
../lib/replace/system/kerberos.h:33:10: fatal error: krb5.h: No such file or directory
 #include <krb5.h>

Signed-off-by: Christof Schmitt <cs at samba.org>
 source3/winbindd/nss_info.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/winbindd/nss_info.c b/source3/winbindd/nss_info.c
index 9ef7e20..473b1a3 100644
--- a/source3/winbindd/nss_info.c
+++ b/source3/winbindd/nss_info.c
@@ -20,7 +20,6 @@
 #include "includes.h"
-#include "ads.h"
 #include "nss_info.h"
 static struct nss_function_entry *backends = NULL;

From a631916477c47500431143faab24015559ba84ad Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 26 Jun 2018 13:32:28 -0700
Subject: [PATCH 2/2] heimdal: Fix build with system provided heimdal library
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Trying to compile with a system provided heimdal library
results in this compile error:

[ 876/3043] Compiling source4/auth/kerberos/srv_keytab.c
In file included from /usr/include/heimdal/krb5.h:949:0,
                 from ../lib/replace/system/kerberos.h:33,
                 from ../source4/auth/kerberos/srv_keytab.c:31:
/usr/include/heimdal/krb5-protos.h:3894:1: error: unknown type name ‘HEIMDAL_WARN_UNUSED_RESULT_ATTRIBUTE’; did you mean ‘_WARN_UNUSED_RESULT_’?
/usr/include/heimdal/krb5-protos.h:3895:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘krb5_generate_random’
 krb5_generate_random (

The problem is that Samba provides a minimal krb5-types.h file
for the internal build that gets used during the build with
the system provided heimdal library. As the minimal file
does not provide all definitions, the build fails.

Fix this by having the krb-types.h file simply include the
include file from the system library, if the build is done
using the system provided heimdal library.

Signed-off-by: Christof Schmitt <cs at samba.org>
 source4/heimdal_build/krb5-types.h      | 10 +++++++---
 source4/heimdal_build/wscript_configure |  5 ++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/source4/heimdal_build/krb5-types.h b/source4/heimdal_build/krb5-types.h
index 4f55a80..b88194c 100644
--- a/source4/heimdal_build/krb5-types.h
+++ b/source4/heimdal_build/krb5-types.h
@@ -1,14 +1,18 @@
 /* krb5-types.h -- this file was generated for i686-pc-linux-gnu by
                    $Id: bits.c,v 1.23 2005/01/05 15:22:02 lha Exp $ */
-#ifndef __krb5_types_h__
-#define __krb5_types_h__
+#ifndef __samba_krb5_types_h__
+#define __samba_krb5_types_h__
 #include "replace.h"
 #include "system/network.h"
 typedef socklen_t krb5_socklen_t;
 typedef int krb5_socket_t;
 typedef ssize_t krb5_ssize_t;
-#endif /* __krb5_types_h__ */
+#endif /* __samb_krb5_types_h__ */
diff --git a/source4/heimdal_build/wscript_configure b/source4/heimdal_build/wscript_configure
index 7bd499f..19f0bf2 100644
--- a/source4/heimdal_build/wscript_configure
+++ b/source4/heimdal_build/wscript_configure
@@ -176,7 +176,10 @@ if krb5_config:
             if l.startswith("libdir="):
             elif l.startswith("includedir="):
-                heimdal_includedirs.append(l.strip()[len("includedir="):])
+                include_path = l.strip()[len("includedir="):]
+                heimdal_includedirs.append(include_path)
+                conf.define('HEIMDAL_KRB5_TYPES_PATH',
+                            include_path + "/krb5-types.h")

More information about the samba-technical mailing list