components/samba/patches/ldap-libs.patch
branchs11u3-sru
changeset 7067 776b367d2e46
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/samba/patches/ldap-libs.patch	Thu Apr 07 18:24:13 2016 -0700
@@ -0,0 +1,233 @@
+in-house
+promoted into the community:
+https://bugzilla.samba.org/show_bug.cgi?id=12124
+
+################################################################################
+From 06092e4728f53c90c7ead56f289d004c80c85f5d Mon Sep 17 00:00:00 2001
+From: Jiri Sasek <[email protected]>
+Date: Mon, 8 Aug 2016 14:32:02 +0200
+Subject: [PATCH] Bug 12124
+
+This is a small configuration change to allow to choose which LDAP C-SDK will be used
+by defining the alternate paths in ldap.pc and lber.pc (pkg-config) files.
+note: in case of the API do not reside in standard paths the appropriate "SYSLIB target"
+should be added into the deps= of the target to ensure the appropriate "-I<alt.path>" or
+"-L<alt.path>" flags will be available when compile/link.
+
+In case of no pkg-config info is found libldap.so and liblber.so libs are searched in
+standard library path.
+
+Motivation:
+On Solaris 11 there are 2 LDAP APIs:
+
+ - "legacy" DS 5 C-SDK represented by:
+   /usr/include/ldap.h
+   /usr/include/lber.h
+   /usr/lib/libldap.so -> libldap.so.5
+    ...mozldap has no lber lib. distiguished from ldap lib.
+
+ - new OpenLDAP C-SDK represented by:
+   /usr/include/openldap/ldap.h
+   /usr/include/openldap/lber.h
+   /usr/lib/libldap_r.so -> libldap_r.so.${cur.ver.}
+   /usr/lib/liblber.so -> liblber.so.${cur.ver.}
+
+...so the default one found by waf is the "wrong one".
+
+---
+ buildtools/wafsamba/samba_autoconf.py |  3 ++-
+ lib/ldb/wscript                       |  2 +-
+ source3/auth/wscript_build            |  2 +-
+ source3/librpc/wscript_build          |  2 +-
+ source3/winbindd/wscript_build        | 10 +++++-----
+ source3/wscript                       | 24 ++++++++++++++++--------
+ source3/wscript_build                 |  5 +++--
+ 7 files changed, 29 insertions(+), 19 deletions(-)
+
+diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
+index 5f35d77..ed3af9d 100644
+--- a/buildtools/wafsamba/samba_autoconf.py
++++ b/buildtools/wafsamba/samba_autoconf.py
+@@ -454,7 +454,7 @@ def CHECK_CODE(conf, code, define,
+ 
+ @conf
+ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
+-                           always=False, define=None, headers=None):
++                           always=False, define=None, headers=None, lib=None):
+     '''check for a structure member'''
+     if define is None:
+         define = 'HAVE_%s' % member.upper()
+@@ -466,6 +466,7 @@ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
+                       always=always,
+                       headers=headers,
+                       local_include=False,
++                      lib=lib,
+                       msg="Checking for member %s in %s" % (member, structname))
+ 
+ 
+diff --git a/lib/ldb/wscript b/lib/ldb/wscript
+index 13f1d93..ce1eae0 100755
+--- a/lib/ldb/wscript
++++ b/lib/ldb/wscript
+@@ -68,7 +68,7 @@ def configure(conf):
+         conf.CHECK_XSLTPROC_MANPAGES()
+ 
+         # we need this for the ldap backend
+-        if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
++        if conf.CHECK_FUNCS('ber_flush ldap_open ldap_initialize', lib='ldap', headers='lber.h ldap.h'):
+             conf.env.ENABLE_LDAP_BACKEND = True
+ 
+         # we don't want any libraries or modules to rely on runtime
+diff --git a/source3/auth/wscript_build b/source3/auth/wscript_build
+index e7a6051..ff170e9 100644
+--- a/source3/auth/wscript_build
++++ b/source3/auth/wscript_build
+@@ -57,7 +57,7 @@ bld.SAMBA3_MODULE('auth_wbc',
+ bld.SAMBA3_MODULE('auth_domain',
+                  subsystem='auth',
+                  source='auth_domain.c',
+-                 deps='RPC_CLIENT_SCHANNEL trusts_util',
++                 deps='RPC_CLIENT_SCHANNEL trusts_util ldap',
+                  init_function='',
+                  internal_module=True)
+ 
+diff --git a/source3/librpc/wscript_build b/source3/librpc/wscript_build
+index 2445859..9ed3407 100644
+--- a/source3/librpc/wscript_build
++++ b/source3/librpc/wscript_build
+@@ -7,7 +7,7 @@ bld.SAMBA3_SUBSYSTEM('NDR_LIBNETAPI',
+ 
+ bld.SAMBA3_SUBSYSTEM('NDR_LIBNET_JOIN',
+ 	source='gen_ndr/ndr_libnet_join.c',
+-	public_deps='ndr krb5samba'
++	public_deps='ndr ldap krb5samba'
+ 	)
+ 
+ bld.SAMBA3_SUBSYSTEM('NDR_OPEN_FILES',
+diff --git a/source3/winbindd/wscript_build b/source3/winbindd/wscript_build
+index 1a2c497..1f6de4c 100644
+--- a/source3/winbindd/wscript_build
++++ b/source3/winbindd/wscript_build
+@@ -8,7 +8,7 @@ bld.SAMBA3_LIBRARY('idmap',
+ 
+ bld.SAMBA3_SUBSYSTEM('IDMAP_RW',
+                      source='idmap_rw.c',
+-                     deps='samba-util')
++                     deps='samba-util ldap')
+ 
+ bld.SAMBA3_SUBSYSTEM('IDMAP_TDB_COMMON',
+                      source='idmap_tdb_common.c',
+@@ -16,7 +16,7 @@ bld.SAMBA3_SUBSYSTEM('IDMAP_TDB_COMMON',
+ 
+ bld.SAMBA3_SUBSYSTEM('IDMAP_HASH',
+                     source='idmap_hash/idmap_hash.c idmap_hash/mapfile.c',
+-                    deps='samba-util krb5samba',
++                    deps='samba-util krb5samba ldap',
+                     enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_hash'))
+ 
+ bld.SAMBA3_SUBSYSTEM('IDMAP_AD',
+@@ -70,7 +70,7 @@ bld.SAMBA3_MODULE('idmap_ldap',
+ bld.SAMBA3_MODULE('idmap_nss',
+                  subsystem='idmap',
+                  source='idmap_nss.c',
+-                 deps='samba-util',
++                 deps='samba-util ldap',
+                  init_function='',
+                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_nss'),
+                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_nss'))
+@@ -78,7 +78,7 @@ bld.SAMBA3_MODULE('idmap_nss',
+ bld.SAMBA3_MODULE('idmap_tdb',
+                  subsystem='idmap',
+                  source='idmap_tdb.c',
+-                 deps='samba-util tdb IDMAP_TDB_COMMON',
++                 deps='samba-util tdb IDMAP_TDB_COMMON ldap',
+                  init_function='',
+                  allow_undefined_symbols=True,
+                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_tdb'),
+@@ -122,7 +122,7 @@ bld.SAMBA3_LIBRARY('nss_info',
+ bld.SAMBA3_MODULE('nss_info_template',
+                  subsystem='nss_info',
+                  source='nss_info_template.c',
+-                 deps='samba-util krb5samba',
++                 deps='samba-util krb5samba ldap',
+                  init_function='',
+                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('nss_info_template'),
+                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('nss_info_template'))
+diff --git a/source3/wscript b/source3/wscript
+index 497b673..88169be 100644
+--- a/source3/wscript
++++ b/source3/wscript
+@@ -666,24 +666,32 @@ msg.msg_accrightslen = sizeof(fd);
+ 
+     # Check for LDAP
+     if Options.options.with_ldap:
+-        conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
+-        conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
+-        conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
+-        conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
++        if conf.CHECK_CFG(package='ldap', args="--cflags --libs", msg='Check for ldap', uselib_store="LDAP") :
++            conf.SET_TARGET_TYPE('ldap', 'SYSLIB')
++        else :
++            conf.CHECK_LIB('ldap', shlib=True)
++        if conf.CHECK_CFG(package='lber', args="--cflags --libs", msg='Check for lber', uselib_store="LBER") :
++            conf.SET_TARGET_TYPE('lber', 'SYSLIB')
++        else :
++            conf.CHECK_LIB('lber', shlib=True)
++        conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h', lib='ldap')
++        conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h', lib='ldap lber')
++        conf.CHECK_FUNCS('ber_scanf ber_sockbuf_add_io', lib='ldap lber')
++        conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h', lib='ldap')
+ 
+         # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
+         # for the samba logs
+         conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
+-                            define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
++                            define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h', lib='ldap lber')
+ 
+-        conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
+-        conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
++        conf.CHECK_FUNCS('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', lib='ldap')
++        conf.CHECK_FUNCS('ldap_add_result_entry', lib='ldap')
+ 
+         # Check if ldap_set_rebind_proc() takes three arguments
+         if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
+                            'LDAP_SET_REBIND_PROC_ARGS',
+                            msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
+-                           headers='ldap.h lber.h', link=False):
++                           headers='ldap.h lber.h', link=False, lib='ldap'):
+             conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
+         else:
+             conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
+diff --git a/source3/wscript_build b/source3/wscript_build
+index edf921c..6011f72 100755
+--- a/source3/wscript_build
++++ b/source3/wscript_build
+@@ -405,6 +405,7 @@ bld.SAMBA3_LIBRARY('libsmb',
+                    deps='''
+                    auth_generic
+                    CLDAP
++                   ldap
+                    LIBNMB
+                    SPNEGO_PARSE
+                    LIBTSOCKET
+@@ -464,7 +465,7 @@ bld.SAMBA3_SUBSYSTEM('LIBADS_SERVER',
+ 
+ bld.SAMBA3_SUBSYSTEM('LIBADS_PRINTER',
+                     source='libads/ldap_printer.c',
+-                    deps='samba-util krb5samba')
++                    deps='samba-util krb5samba ldap')
+ 
+ bld.SAMBA3_LIBRARY('smbconf',
+                    source='''lib/smbconf/smbconf_init.c
+@@ -835,7 +836,7 @@ bld.SAMBA3_SUBSYSTEM('LIBCLI_WINREG_INTERNAL',
+ 
+ bld.SAMBA3_SUBSYSTEM('RPC_CLIENT_SCHANNEL',
+                     source='rpc_client/cli_pipe_schannel.c',
+-                    deps='samba-util krb5samba')
++                    deps='samba-util krb5samba ldap')
+ 
+ bld.SAMBA3_SUBSYSTEM('INIT_LSA',
+                     source='rpc_client/init_lsa.c',
+-- 
+2.6.1
+