[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Tue Nov 30 16:45:01 UTC 2021


The branch, master has been updated
       via  ccfefe28909 s4:samba: split out a samba_service_init() helper function
       via  5d295e41af4 vfs_not_implemented: mark all functions with _PUBLIC_
       via  6745968a154 script/autobuild.py: make sure nss, pam and krb5 plugins don't provide unexpected symbols
       via  4862a8ff2f0 script/autobuild.py: make sure nss and pam plugins don't link any samba libraries
       via  66e90b7391b nsswitch: reduce dependecies to private libraries and link static/builtin if possible
       via  05ca7b9809d lib/replace: use dlsym(RTLD_DEFAULT,) for {nss,nss_host,uid,socket}_wrapper_enabled()
       via  62d05a81087 nsswitch/libwbclient: explicitly mark all wbc* symbols as _PUBLIC_
       via  fa98a44cb4d nsswitch: explicitly mark nss_module_register() _PUBLIC_ on FreeBSD
       via  419ca68de0c nsswitch: explicitly mark NSS_STATUS _nss_winbind_* symbols as _PUBLIC_ on Linux
       via  3f9948bd6dc nsswitch: explicitly mark PAM_EXTERN pam_sm_* symbols as _PUBLIC_
       via  a663c9648f1 nsswitch: explicitly mark magic krb5 plugin symbols as _PUBLIC_
       via  9615395b1fd nsswitch/wbinfo: use wbcRequestResponse() instead of winbindd_request_response()
       via  41108b9ed9f nsswitch: move winbindd_free_response() as inline function to winbind_struct_protocol.h
       via  f3c5980f76f s4:torture/winbind: use wbcRequestResponse() instead of winbindd_request_response()
       via  ac8977d1e76 s3:ntlm_auth: use wbcRequestResponse[Priv]() instead of winbindd_request_response()
       via  35446c27f8e s3:utils: remove notify_msg.c from smbstatus sources
       via  600ebefa5af libwbclient: fix strict-overflow warning in wbcSidToString()
       via  c461b906ca5 heimdal_build: let HEIMDAL_LIBRARY() use SAMBA_LIBRARY()
       via  6c64f3cee83 heimdal_build: avoid using hardcoded vnum values passed to HEIMDAL_LIBRARY()
       via  e35f23195f9 heimdal_build: remove unused cflags argument of HEIMDAL_LIBRARY()
       via  f168f548784 wafsamba: allow SAMBA_LIBRARY() to get and use original 'version-script.map' for private libraries
       via  38d37d4a532 wafsamba: introduce SAMBA[3]_PLUGIN()
       via  70da83a8ca7 wafsamba: introduce require_builtin_deps/provide_builtin_linking/builtin_cflags to SAMBA_{SUBSYSTEM,LIBRARY}
       via  38ef29bc219 wafsamba: let reduce_objects() not remove duplicates of BUILTINS even if there are more than one
       via  295e5270f60 wafsamba: add SAMBA_SUBSYSTEM(force_empty=False)
       via  3aff74e29ed wafsamba: assert for *.sigs source files in abi_build_vscript()
       via  33e6949dda8 wafsamba: the symbol version string of private libraries should be based on the toplevel project
       via  da7c41e2601 wafsamba: use private extentions also for bundled public libraries
       via  43b90da1867 wafsamba: remove unused private_library argument of PRIVATE_NAME()
       via  d6749f590f3 wafsamba: SAMBA_GENERATOR() should not alter the callers dep_vars
       via  932c408c1b4 wafsamba: fix '--private-libraries' option when using 'ALL,!something'
       via  893c24605a5 wafsamba: mark SAMBA_MODULE() with private_library=True
       via  03cd1449f69 script/autobuild.py: fix "nondevel" builds of 'samba-libs'
      from  38c5bad4a85 kdc: Require that PAC_REQUESTER_SID buffer is present for TGTs

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ccfefe289093457587009e1862e1ed8591495aac
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 27 13:06:00 2021 +0200

    s4:samba: split out a samba_service_init() helper function
    
    The loading function should be in the same SAMBA_LIBRARY()
    as the modules.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Tue Nov 30 16:44:57 UTC 2021 on sn-devel-184

commit 5d295e41af4e9316aee1b4cf1c3087663b7c06a4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 27 13:10:41 2021 +0200

    vfs_not_implemented: mark all functions with _PUBLIC_
    
    These functions are used directly by other modules.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 6745968a15497c88646c1213ec6a8b198e624abb
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 23 12:56:15 2021 +0000

    script/autobuild.py: make sure nss, pam and krb5 plugins don't provide unexpected symbols
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 4862a8ff2f02cf7c735d666520846f6a0d63c6b0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 23 12:56:15 2021 +0000

    script/autobuild.py: make sure nss and pam plugins don't link any samba libraries
    
    Note that we exclude libtalloc.so.2 in pam_winbind.so as that simulates
    a system libtalloc.so.2.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 66e90b7391bd404580f3919c4f2b8625c9c89c0e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 12:08:16 2021 +0200

    nsswitch: reduce dependecies to private libraries and link static/builtin if possible
    
    Over the last month I got more and more reports,
    that it's not possible to use a custom Samba version
    on systems with sssd being installed, which depends on some
    specific samba libraries installed in the system.
    
    One major problem is that the custom libnss_winbind.so.2
    depends on the libreplace-samba4.so of the custom build
    and also injects an RPATH into the running process.
    When sssd uses any nss library call it will get this,
    when it then tries to load some of its plugins via dlopen(),
    e.g.
    
    ldd /usr/lib64/sssd/libsss_ad.so| grep samba
    
       libsamba-util.so.0 => /lib64/libsamba-util.so.0
       libreplace-samba4.so => /usr/lib64/samba/libreplace-samba4.so
       libsamba-security-samba4.so => /usr/lib64/samba/libsamba-security-samba4.so
       libsamba-errors.so.1 => /lib64/libsamba-errors.so.1
       libsamba-debug-samba4.so => /usr/lib64/samba/libsamba-debug-samba4.so
       libgenrand-samba4.so => /usr/lib64/samba/libgenrand-samba4.so
       libsocket-blocking-samba4.so => /usr/lib64/samba/libsocket-blocking-samba4.so
       libtime-basic-samba4.so => /usr/lib64/samba/libtime-basic-samba4.so
       libsys-rw-samba4.so => /usr/lib64/samba/libsys-rw-samba4.so
       libiov-buf-samba4.so => /usr/lib64/samba/libiov-buf-samba4.so
    
    When that loads dlopen() will fail as a soname libreplace-samba4.so is
    already loaded, but the symbol version within the other one don't match, as the
    contain the exact version, e.g. replace_dummy@@SAMBA_4.13.3.
    
    This is just an example and similar things can happen in all situations
    where we provide libraries, which are potentially injected into every
    process of the running system. These should only depend on libc.so and
    related basic system libraries in order to avoid the problem.
    
    We have the following libraries, which are in the that category:
    
    - libnss_winbind.so.2
    - libnss_wins.so.2
    - pam_winbind.so
    - winbind_krb5_locator.so
    - async_dns_krb5_locator.so
    
    The rules of library loading are really complex and symbol versioning
    is not enough to solve it, only the combination of unique soname and
    unique symbol version suffix seem to solve the problem, but injecting
    an RPATH is still a problem.
    
    In order to solve the problem I experimented with adding SAMBA_SUBSYSTEM()
    definitions with 'hide_symbols=True' in order to do some static linking
    of selected components, e.g.
    
       bld.SAMBA_SUBSYSTEM('replace-hidden',
                           source=REPLACE_SOURCE,
                           group='base_libraries',
                           hide_symbols=True,
                           deps='dl attr' + extra_libs)
    
    It's relatively simple to get to the point where the following are
    completely static:
    
    - libnss_winbind.so.2
    - libnss_wins.so.2
    - pam_winbind.so
    - winbind_krb5_locator.so
    
    But 'async_dns_krb5_locator.so' links in almost everything!
    It seems we install the krb5 plugins into our own $MODULESDIR/krb5/,
    so it may not be so critical, as long it's the admin who created
    the desired symlinks into the location the kerberos libraries search
    for plugins. Note the at least the locator plugins are always loaded
    without any configuration, every .so in a special path are loaded with dlopen().
    This is done by every application using kerberos, so we load a lot of samba libraries
    into them.
    
    Packagers should not put async_dns_krb5_locator.so (nor a symlink) into
    the path that's reachable by libkrb5.so.
    
    As a longterm solution we may want to change async_dns_krb5_locator.so
    to use a helper process with posix_spawn() instead of doing everything
    within the process.
    
    Note I added hiden_symbols=True to the nss modules for Linux and
    FreeBSD only, because these are the only platforms I'm able to test
    on. We most likely should do the same on other platforms, but some
    with access to the platform should provide a tested patch.
    
    In order to avoid manual definitions of SAMBA_SUBSYSTEMS() with
    '-hidden', I added the 'provide_builtin_linking=True' option,
    as the logic is very similar to what we already have with the
    '--builtin-libraries=BUILTIN_LIBRARIES' configure option.
    
    SAMBA_PLUGIN() is used in order to use SAMBA_LIBRARY() in order
    to make it more strict that these plugins can't be used as
    normal depedency by other subsystems and libraries.
    
    While being there it was easy enough to make libwbclient.so
    also standalone without dependecies to other samba libraries.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 05ca7b9809d7329aea93fc8f1b8b2e54703f1dbd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 5 18:03:14 2021 +0200

    lib/replace: use dlsym(RTLD_DEFAULT,) for {nss,nss_host,uid,socket}_wrapper_enabled()
    
    We should not provide the symbols ourself instead we should just check
    if they are already available when we want to check the result.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 62d05a81087029d93ba0cf81c11e5b244d788aef
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Oct 12 14:30:09 2021 +0200

    nsswitch/libwbclient: explicitly mark all wbc* symbols as _PUBLIC_
    
    Some private functions from wbclient_internal.h already
    leaked into the ABI. With hide_symbols=True we make sure
    this doesn't happen again.
    
    Having wbcRequestResponse[Priv]() as part of the ABI helps us
    in order to hide winbindd_[priv_]request_response() soon.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit fa98a44cb4d94c6a290deb931b260e411364314d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 12:08:16 2021 +0200

    nsswitch: explicitly mark nss_module_register() _PUBLIC_ on FreeBSD
    
    This is the only symbol which is used via dlopen()/dlsym() and
    needs to be exported, in future we'll do hide all other symbols.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 419ca68de0c9ed02612e64717963d133833061e7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 12:08:16 2021 +0200

    nsswitch: explicitly mark NSS_STATUS _nss_winbind_* symbols as _PUBLIC_ on Linux
    
    The symbols which are used via dlopen()/dlsym() need to be exported,
    in future we'll do hide all other symbols.
    
    On other platforms, which are implemented as wrappers above the
    Linux implementation, we mark the symbols as _PRIVATE_
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 3f9948bd6dc16e7cf488277fab6837f545e94432
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 12:08:16 2021 +0200

    nsswitch: explicitly mark PAM_EXTERN pam_sm_* symbols as _PUBLIC_
    
    The symbols which are used via dlopen()/dlsym() need to be exported,
    in future we'll do hide all other symbols.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit a663c9648f14294d7e02f30ee1a9a53b1a404279
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 12:08:16 2021 +0200

    nsswitch: explicitly mark magic krb5 plugin symbols as _PUBLIC_
    
    The symbols which are used via dlopen()/dlsym() need to be exported,
    in future we'll do hide all other symbols.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 9615395b1fdaa4509a9739bada93c3bb72903b2c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 22 17:59:48 2021 +0100

    nsswitch/wbinfo: use wbcRequestResponse() instead of winbindd_request_response()
    
    We should try to route everything through libwbclient.so, because we'll
    soon don't have a single library providing winbindd_request_response().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 41108b9ed9f32ca9ad1b3d4a48a91a6f22c65db6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 22 18:11:27 2021 +0100

    nsswitch: move winbindd_free_response() as inline function to winbind_struct_protocol.h
    
    nsswitch/wb_common.c will be made completely internal soon.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit f3c5980f76f30c65378623e4f5b25e73d4ace25b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 22 17:59:48 2021 +0100

    s4:torture/winbind: use wbcRequestResponse() instead of winbindd_request_response()
    
    We should try to route everything through libwbclient.so, because we'll
    soon don't have a single library providing winbindd_request_response().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit ac8977d1e760824d9f170455899e53aa555f807e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 22 17:59:48 2021 +0100

    s3:ntlm_auth: use wbcRequestResponse[Priv]() instead of winbindd_request_response()
    
    We should try to route everything through libwbclient.so, because we'll
    soon don't have a single library providing winbindd_request_response().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 35446c27f8ef3532d2440d4e86774e13065e86c4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Nov 26 01:39:40 2021 +0100

    s3:utils: remove notify_msg.c from smbstatus sources
    
    This is not needed for smbstatus and the symbols are also available
    via 'smbd_base', which already contains notify_msg.c.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 600ebefa5af806f376abda722fb492895f0603ac
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 4 18:03:13 2021 +0200

    libwbclient: fix strict-overflow warning in wbcSidToString()
    
    ../../nsswitch/libwbclient/wbc_sid.c:83:5: error: assuming signed overflow does not occur when simplifying conditional [-Werror=strict-overflow]
      if (len+1 > sizeof(buf)) {
         ^
    
    Even this would fail:
    ../../nsswitch/libwbclient/wbc_sid.c:83:5: error: assuming signed overflow does not occur when simplifying conditional [-Werror=strict-overflow]
      if (len >= sizeof(buf)) {
         ^
    
    Note that this only seems to happen with gcc 7 and when -O3 and
    -fvisibility=hidden are used together. E.g. in the opensuse151-samba-o3
    builds.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c461b906ca5940bcf69901f973b5698e3ef75063
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 18 17:55:25 2021 +0200

    heimdal_build: let HEIMDAL_LIBRARY() use SAMBA_LIBRARY()
    
    This simplifies a lot and makes sure we always use the
    same rules for private libraries.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 6c64f3cee832c9f48b3cc058d3de31561524997a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 18 15:47:33 2021 +0200

    heimdal_build: avoid using hardcoded vnum values passed to HEIMDAL_LIBRARY()
    
    For private libraries we don't want versioned sonames,
    it's also pointless to use the upstream heimdal vnum values
    for our private libraries as the soname is different anyway.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit e35f23195f921f48b78dfe9cc1d0f85194697ece
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 18 15:47:33 2021 +0200

    heimdal_build: remove unused cflags argument of HEIMDAL_LIBRARY()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit f168f548784e643335cf0351a5f506dbc087f65f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 18 17:34:09 2021 +0200

    wafsamba: allow SAMBA_LIBRARY() to get and use original 'version-script.map' for private libraries
    
    We'll soon use this for the internal Heimdal build and take the raw
    version-script.map files in order to create our own .vscript file
    with our private version suffix.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 38d37d4a53285f08ce805f28b0659456c197f023
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 20 23:05:57 2021 +0200

    wafsamba: introduce SAMBA[3]_PLUGIN()
    
    This will be used to define plugins we provide to be used
    via dbopen/dlsym to external consumers.
    
    SAMBA_PLUGIN() is used instead of SAMBA_LIBRARY() in order
    to make it more strict that these plugins can't be used as
    normal depedency by other subsystems and libraries.
    
    With require_builtin_deps=True we make sure that only
    symbols explicitly marked with _PUBLIC_ are exported
    and we only link to system libraries and include all
    internal depedencies as builtin subsystems.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 70da83a8ca7fdb2d1bcd8601a1a0111d39469000
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 19 17:31:24 2021 +0200

    wafsamba: introduce require_builtin_deps/provide_builtin_linking/builtin_cflags to SAMBA_{SUBSYSTEM,LIBRARY}
    
    The 'provide_builtin_linking=True' option that allows wscript files
    to specify that a SAMBA_{SUBSYSTEM,LIBRARY} will also create a
    builtin version of them in addition.
    
    The logic behind this is very similar to what we already have with the
    '--builtin-libraries=BUILTIN_LIBRARIES' configure option.
    
    This avoids the need for manual definitions of SAMBA_SUBSYSTEMS() with
    like this:
    
       bld.SAMBA_SUBSYSTEM('replace-hidden',
                           source=REPLACE_SOURCE,
                           group='base_libraries',
                           hide_symbols=True,
                           deps='dl attr' + extra_libs)
    
    The builtin version will also make sure that it will include all
    dependecies (of internal code) also in the builtin variant.
    Note that this is also possible if the dependency also
    provided 'provide_builtin_linking=True' in order to limit
    the scope.
    
    We now imply '-D_PUBLIC_=_PRIVATE_' and 'hide_symbols=True' for
    builtin libraries and subsystems in order to avoid exporting
    the symbols of them.
    
    With 'require_builtin_deps=True' a library can specify that it
    is only able to use libraries/subsystems marked with
    provide_builtin_linking=True. As a result it won't
    link against any other SAMBA_LIBRARY() dependency,
    but link in everything internal. Only system libraries
    still get linked dynamically.
    
    Use 'git show -w' to see a reduced diff.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 38ef29bc219afcd608a1c87f8aae99cebe79b665
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 20 16:25:02 2021 +0200

    wafsamba: let reduce_objects() not remove duplicates of BUILTINS even if there are more than one
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 295e5270f60296feb4e9bbb57ae3b3f58f2d3258
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 20 12:27:17 2021 +0000

    wafsamba: add SAMBA_SUBSYSTEM(force_empty=False)
    
    We will need to define empty subsystems without any dependency.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 3aff74e29ed3bb99fd7b9a510001e7046b86c8fa
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 18 17:20:12 2021 +0200

    wafsamba: assert for *.sigs source files in abi_build_vscript()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 33e6949dda83996550d126d7de09a13691ff35cc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 15:29:46 2021 +0200

    wafsamba: the symbol version string of private libraries should be based on the toplevel project
    
    If we build a private library all symbols should be made private based
    on a unique suffix.
    
    When we use a unique soname and a unique symbol version suffix it's very unlikely
    to hit conflicts due to inherited libraries.
    
    For the abi checking we still use the original vnum as abi_vnum.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit da7c41e26016845f0dfd78601987c075ef8711a6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 13 15:16:59 2021 +0200

    wafsamba: use private extentions also for bundled public libraries
    
    Playing tricks with redefining libraries, which may also be installed in
    the system with the same version, isn't really a good thing.
    It may work in some cases, but there are so many things which may go
    wrong. So if we build a library as private/bundled library we should
    change the soname of the library.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 43b90da1867135ddb5f740c9d664af4c2d96a18f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 13 15:14:01 2021 +0200

    wafsamba: remove unused private_library argument of PRIVATE_NAME()
    
    The only caller asserts that private_library is True.
    
    Use: git show -U5
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit d6749f590f338cff42634c7406dda96dc1d8e2fd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 18 17:54:31 2021 +0200

    wafsamba: SAMBA_GENERATOR() should not alter the callers dep_vars
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 932c408c1b4f53098c8857941bcaf67c978195ec
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 1 12:08:11 2021 +0200

    wafsamba: fix '--private-libraries' option when using 'ALL,!something'
    
    We already had the desired logic in LIB_MUST_BE_BUNDLED(), so we can
    just reuse it in LIB_MUST_BE_PRIVATE().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 893c24605a5874b4b093ea1967ebbcb1e4837ffa
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 27 12:39:01 2021 +0200

    wafsamba: mark SAMBA_MODULE() with private_library=True
    
    Symbols from modules should have a symbol versioning tag of the
    current version.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 03cd1449f697dc7a9950fd4d333273ea72bcb174
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 20 09:21:13 2021 +0000

    script/autobuild.py: fix "nondevel" builds of 'samba-libs'
    
    Commit 3e6af7109eb9d49328b426095580e4bfb2338ceb removed environment
    variables like PKG_CONFIG_PATH from the configure run, so we no longer
    tested a build against the shared libraries we build before.
    
    We also assert that we no longer build private libraries
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba3.py                      |   5 +
 buildtools/wafsamba/samba_abi.py                   |  88 +++++-
 buildtools/wafsamba/samba_bundled.py               |  28 +-
 buildtools/wafsamba/samba_deps.py                  | 115 +++++++-
 buildtools/wafsamba/samba_utils.py                 |   2 +-
 buildtools/wafsamba/stale_files.py                 |   2 +-
 buildtools/wafsamba/symbols.py                     |  12 +-
 buildtools/wafsamba/wafsamba.py                    | 309 ++++++++++++++++++---
 buildtools/wafsamba/wscript                        |   4 +-
 lib/replace/cwrap.c                                |  46 ---
 lib/replace/replace.h                              |  57 +++-
 lib/replace/wscript                                |   2 +-
 lib/talloc/wscript                                 |   1 +
 lib/util/wscript_build                             |   4 +-
 nsswitch/krb5_plugin/async_dns_krb5_locator.c      |   2 +-
 nsswitch/krb5_plugin/winbind_krb5_localauth.c      |   4 +-
 nsswitch/krb5_plugin/winbind_krb5_locator.c        |   2 +-
 nsswitch/libwbclient/wbc_guid.c                    |   2 +
 nsswitch/libwbclient/wbc_idmap.c                   |  26 ++
 nsswitch/libwbclient/wbc_pam.c                     |  26 ++
 nsswitch/libwbclient/wbc_pwd.c                     |  26 ++
 nsswitch/libwbclient/wbc_sid.c                     |  24 +-
 nsswitch/libwbclient/wbc_util.c                    |  20 ++
 nsswitch/libwbclient/wbclient.c                    |  11 +
 nsswitch/libwbclient/wscript                       |  14 +-
 nsswitch/pam_winbind.c                             |  12 +-
 nsswitch/wb_common.c                               |  10 -
 nsswitch/wbinfo.c                                  |  21 +-
 nsswitch/winbind_client.h                          |   1 -
 nsswitch/winbind_nss_freebsd.c                     |   6 +-
 nsswitch/winbind_nss_linux.c                       |  12 +
 nsswitch/winbind_nss_linux.h                       |   9 +
 nsswitch/winbind_struct_protocol.h                 |  10 +
 nsswitch/wins.c                                    |   3 +
 nsswitch/wins_freebsd.c                            |   6 +-
 nsswitch/wscript_build                             | 151 ++++++----
 python/samba/tests/test_pam_winbind.sh             |   2 +-
 python/samba/tests/test_pam_winbind_chauthtok.sh   |   2 +-
 .../tests/test_pam_winbind_warn_pwd_expire.sh      |   2 +-
 script/autobuild.py                                |  73 ++++-
 selftest/target/Samba.pm                           |   2 +-
 source3/modules/vfs_not_implemented.c              | 101 +++++++
 source3/utils/ntlm_auth.c                          |  27 +-
 source3/utils/wscript_build                        |   3 +-
 source4/heimdal_build/wscript_build                |  75 +----
 source4/samba/server.c                             |  12 +-
 source4/samba/service.c                            |  24 ++
 source4/samba/service.h                            |   2 +
 source4/selftest/tests.py                          |   2 +-
 source4/torture/winbind/struct_based.c             |  37 ++-
 source4/torture/winbind/wscript_build              |   2 +-
 51 files changed, 1100 insertions(+), 339 deletions(-)
 delete mode 100644 lib/replace/cwrap.c


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba3.py b/buildtools/wafsamba/samba3.py
index 7b42075d1ab..ebc7fbb707f 100644
--- a/buildtools/wafsamba/samba3.py
+++ b/buildtools/wafsamba/samba3.py
@@ -85,6 +85,11 @@ def SAMBA3_LIBRARY(bld, name, *args, **kwargs):
     return bld.SAMBA_LIBRARY(name, *args, **kwargs)
 Build.BuildContext.SAMBA3_LIBRARY = SAMBA3_LIBRARY
 
+def SAMBA3_PLUGIN(bld, name, *args, **kwargs):
+    s3_fix_kwargs(bld, kwargs)
+    return bld.SAMBA_PLUGIN(name, *args, **kwargs)
+Build.BuildContext.SAMBA3_PLUGIN = SAMBA3_PLUGIN
+
 def SAMBA3_MODULE(bld, name, *args, **kwargs):
     s3_fix_kwargs(bld, kwargs)
     return bld.SAMBA_MODULE(name, *args, **kwargs)
diff --git a/buildtools/wafsamba/samba_abi.py b/buildtools/wafsamba/samba_abi.py
index bf82fc5fe1f..80643aa28d7 100644
--- a/buildtools/wafsamba/samba_abi.py
+++ b/buildtools/wafsamba/samba_abi.py
@@ -142,7 +142,7 @@ def abi_check(self):
     abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh')
 
     abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.version_libname,
-                                  self.vnum)
+                                  self.abi_vnum)
 
     tsk = self.create_task('abi_check', self.link_task.outputs[0])
     tsk.ABI_FILE = abi_file
@@ -157,6 +157,46 @@ def abi_process_file(fname, version, symmap):
         if not symname in symmap:
             symmap[symname] = version
 
+def version_script_map_process_file(fname, version, abi_match):
+    '''process one standard version_script file, adding the symbols to the
+    abi_match'''
+    in_section = False
+    in_global = False
+    in_local = False
+    for _line in Utils.readf(fname).splitlines():
+        line = _line.strip()
+        if line == "":
+            continue
+        if line.startswith("#"):
+            continue
+        if line.endswith(" {"):
+            in_section = True
+            continue
+        if line == "};":
+            assert in_section
+            in_section = False
+            in_global = False
+            in_local = False
+            continue
+        if not in_section:
+            continue
+        if line == "global:":
+            in_global = True
+            in_local = False
+            continue
+        if line == "local:":
+            in_global = False
+            in_local = True
+            continue
+
+        symname = line.split(";")[0]
+        assert symname != ""
+        if in_local:
+            if symname == "*":
+                continue
+            symname = "!%s" % symname
+        if not symname in abi_match:
+            abi_match.append(symname)
 
 def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match):
     """Write a vscript file for a library in --version-script format.
@@ -214,21 +254,51 @@ def abi_build_vscript(task):
 
     symmap = {}
     versions = []
+    abi_match = list(task.env.ABI_MATCH)
     for f in task.inputs:
         fname = f.abspath(task.env)
         basename = os.path.basename(fname)
-        version = basename[len(task.env.LIBNAME)+1:-len(".sigs")]
-        versions.append(version)
-        abi_process_file(fname, version, symmap)
+        if basename.endswith(".sigs"):
+            version = basename[len(task.env.LIBNAME)+1:-len(".sigs")]
+            versions.append(version)
+            abi_process_file(fname, version, symmap)
+            continue
+        if basename == "version-script.map":
+            version_script_map_process_file(fname, task.env.VERSION, abi_match)
+            continue
+        raise Errors.WafError('Unsupported input "%s"' % fname)
+    if task.env.PRIVATE_LIBRARY:
+        # For private libraries we need to inject
+        # each public symbol explicitly into the
+        # abi match array and remove all explicit
+        # versioning so that each exported symbol
+        # is tagged with the private library tag.
+        for s in symmap:
+            abi_match.append(s)
+        symmap = {}
+        versions = []
     f = open(tgt, mode='w')
     try:
         abi_write_vscript(f, task.env.LIBNAME, task.env.VERSION, versions,
-            symmap, task.env.ABI_MATCH)
+            symmap, abi_match)
     finally:
         f.close()
 
+def VSCRIPT_MAP_PRIVATE(bld, libname, orig_vscript, version, private_vscript):
+    version = version.replace("-", "_").replace("+","_").upper()
+    t = bld.SAMBA_GENERATOR(private_vscript,
+                            rule=abi_build_vscript,
+                            source=orig_vscript,
+                            group='vscripts',
+                            target=private_vscript)
+    t.env.ABI_MATCH = []
+    t.env.VERSION = version
+    t.env.LIBNAME = libname
+    t.env.PRIVATE_LIBRARY = True
+    t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH', 'PRIVATE_LIBRARY']
+Build.BuildContext.VSCRIPT_MAP_PRIVATE = VSCRIPT_MAP_PRIVATE
 
-def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
+def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None, private_library=False):
     '''generate a vscript file for our public libraries'''
     if abi_directory:
         source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname), flat=True)
@@ -238,6 +308,9 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
     else:
         source = ''
 
+    if private_library is None:
+        private_library = False
+
     libname = os.path.basename(libname)
     version = os.path.basename(version)
     libname = libname.replace("-", "_").replace("+","_").upper()
@@ -255,5 +328,6 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
     t.env.ABI_MATCH = abi_match
     t.env.VERSION = version
     t.env.LIBNAME = libname
-    t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH']
+    t.env.PRIVATE_LIBRARY = private_library
+    t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH', 'PRIVATE_LIBRARY']
 Build.BuildContext.ABI_VSCRIPT = ABI_VSCRIPT
diff --git a/buildtools/wafsamba/samba_bundled.py b/buildtools/wafsamba/samba_bundled.py
index 5f080dd8a7a..7d2d855cd9c 100644
--- a/buildtools/wafsamba/samba_bundled.py
+++ b/buildtools/wafsamba/samba_bundled.py
@@ -5,19 +5,9 @@ from waflib import Build, Options, Logs
 from waflib.Configure import conf
 from wafsamba import samba_utils
 
-def PRIVATE_NAME(bld, name, private_extension, private_library):
+def PRIVATE_NAME(bld, name):
     '''possibly rename a library to include a bundled extension'''
 
-    if not private_library:
-        return name
-
-    # we now use the same private name for libraries as the public name.
-    # see http://git.samba.org/?p=tridge/junkcode.git;a=tree;f=shlib for a
-    # demonstration that this is the right thing to do
-    # also see http://lists.samba.org/archive/samba-technical/2011-January/075816.html
-    if private_extension:
-        return name
-
     extension = bld.env.PRIVATE_EXTENSION
 
     if extension and name.startswith('%s' % extension):
@@ -95,20 +85,22 @@ def LIB_MAY_BE_BUNDLED(conf, libname):
         return False
     return True
 
- at conf
-def LIB_MUST_BE_BUNDLED(conf, libname):
-    if libname in conf.env.BUNDLED_LIBS:
+def __LIB_MUST_BE(liblist, libname):
+    if libname in liblist:
         return True
-    if '!%s' % libname in conf.env.BUNDLED_LIBS:
+    if '!%s' % libname in liblist:
         return False
-    if 'ALL' in conf.env.BUNDLED_LIBS:
+    if 'ALL' in liblist:
         return True
     return False
 
+ at conf
+def LIB_MUST_BE_BUNDLED(conf, libname):
+    return __LIB_MUST_BE(conf.env.BUNDLED_LIBS, libname)
+
 @conf
 def LIB_MUST_BE_PRIVATE(conf, libname):
-    return ('ALL' in conf.env.PRIVATE_LIBS or
-            libname in conf.env.PRIVATE_LIBS)
+    return __LIB_MUST_BE(conf.env.PRIVATE_LIBS, libname)
 
 @conf
 def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py
index cb8acfae34e..81979e291a7 100644
--- a/buildtools/wafsamba/samba_deps.py
+++ b/buildtools/wafsamba/samba_deps.py
@@ -7,7 +7,6 @@ from waflib.Logs import debug
 from waflib.Configure import conf
 from waflib import ConfigSet
 
-from samba_bundled import BUILTIN_LIBRARY
 from samba_utils import LOCAL_CACHE, TO_LIST, get_tgt_list, unique_list
 from samba_autoconf import library_flags
 
@@ -78,7 +77,7 @@ def build_dependencies(self):
     the full dependency list for a target until we have all of the targets declared.
     '''
 
-    if self.samba_type in ['LIBRARY', 'BINARY', 'PYTHON']:
+    if self.samba_type in ['LIBRARY', 'PLUGIN', 'BINARY', 'PYTHON']:
         self.uselib        = list(self.final_syslibs)
         self.uselib_local  = list(self.final_libs)
         self.add_objects   = list(self.final_objects)
@@ -102,7 +101,7 @@ def build_dependencies(self):
         debug('deps: computed dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
               self.sname, self.uselib, self.uselib_local, self.add_objects)
 
-    if self.samba_type in ['SUBSYSTEM']:
+    if self.samba_type in ['SUBSYSTEM', 'BUILTIN']:
         # this is needed for the cflags of libs that come from pkg_config
         self.uselib = list(self.final_syslibs)
         self.uselib.extend(list(self.direct_syslibs))
@@ -284,7 +283,7 @@ def check_duplicate_sources(bld, tgt_list):
 
     # build a list of targets that each source file is part of
     for t in tgt_list:
-        if not targets[t.sname] in [ 'LIBRARY', 'BINARY', 'PYTHON' ]:
+        if not targets[t.sname] in [ 'LIBRARY', 'PLUGIN', 'BINARY', 'PYTHON' ]:
             continue
         for obj in t.add_objects:
             t2 = t.bld.get_tgen_by_name(obj)
@@ -354,7 +353,7 @@ def show_final_deps(bld, tgt_list):
     targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
 
     for t in tgt_list:
-        if not targets[t.sname] in ['LIBRARY', 'BINARY', 'PYTHON', 'SUBSYSTEM']:
+        if not targets[t.sname] in ['LIBRARY', 'PLUGIN', 'BINARY', 'PYTHON', 'SUBSYSTEM', 'BUILTIN']:
             continue
         debug('deps: final dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
               t.sname, t.uselib, getattr(t, 'uselib_local', []), getattr(t, 'add_objects', []))
@@ -376,6 +375,58 @@ def add_samba_attributes(bld, tgt_list):
         t.samba_includes_extended = TO_LIST(t.samba_includes)[:]
         t.cflags = getattr(t, 'samba_cflags', '')
 
+def replace_builtin_subsystem_deps(bld, tgt_list):
+    '''replace dependencies based on builtin subsystems/libraries
+
+    '''
+
+    targets  = LOCAL_CACHE(bld, 'TARGET_TYPE')
+
+    # If either the target or the dependency require builtin linking
+    # we should replace the dependency
+    for t in tgt_list:
+        t_require_builtin_deps = getattr(t, 'samba_require_builtin_deps', False)
+        if t_require_builtin_deps:
+            debug("deps: target %s: requires builtin dependencies..." % (t.sname))
+        else:
+            debug("deps: target %s: does not require builtin dependencies..." % (t.sname))
+
+        replacing = {}
+
+        for dep in t.samba_deps_extended:
+            bld.ASSERT(dep in targets, "target %s: dependency target %s not declared" % (t.sname, dep))
+            dtype = targets[dep]
+            bld.ASSERT(dtype != 'BUILTIN', "target %s: dependency target %s is BUILTIN" % (t.sname, dep))
+            bld.ASSERT(dtype != 'PLUGIN', "target %s: dependency target %s is PLUGIN" % (t.sname, dep))
+            if dtype not in ['SUBSYSTEM', 'LIBRARY']:
+                debug("deps: target %s: keep %s dependency %s" % (t.sname, dtype, dep))
+                continue
+            dt = bld.get_tgen_by_name(dep)
+            bld.ASSERT(dt is not None, "target %s: dependency target %s not found by name" % (t.sname, dep))
+            dt_require_builtin_deps = getattr(dt, 'samba_require_builtin_deps', False)
+            if not dt_require_builtin_deps and not t_require_builtin_deps:
+                # both target and dependency don't require builtin linking
+                continue
+            sdt = getattr(dt, 'samba_builtin_subsystem', None)
+            if not t_require_builtin_deps:
+                if sdt is None:
+                    debug("deps: target %s: dependency %s requires builtin deps only" % (t.sname, dep))
+                    continue
+                debug("deps: target %s: dependency %s requires builtin linking" % (t.sname, dep))
+            bld.ASSERT(sdt is not None, "target %s: dependency target %s is missing samba_builtin_subsystem" % (t.sname, dep))
+            sdep = sdt.sname
+            bld.ASSERT(sdep in targets, "target %s: builtin dependency target %s (from %s) not declared" % (t.sname, sdep, dep))
+            sdt = targets[sdep]
+            bld.ASSERT(sdt == 'BUILTIN', "target %s: builtin dependency target %s (from %s) is not BUILTIN" % (t.sname, sdep, dep))
+            replacing[dep] = sdep
+
+        for i in range(len(t.samba_deps_extended)):
+            dep = t.samba_deps_extended[i]
+            if dep in replacing:
+                sdep = replacing[dep]
+                debug("deps: target %s: replacing dependency %s with builtin subsystem %s" % (t.sname, dep, sdep))
+                t.samba_deps_extended[i] = sdep
+
 def replace_grouping_libraries(bld, tgt_list):
     '''replace dependencies based on grouping libraries
 
@@ -446,7 +497,12 @@ def build_direct_deps(bld, tgt_list):
                 t.direct_syslibs.add(d)
                 if d in syslib_deps:
                     for implied in TO_LIST(syslib_deps[d]):
-                        if BUILTIN_LIBRARY(bld, implied):
+                        if targets[implied] == 'SUBSYSTEM':
+                            it = bld.get_tgen_by_name(implied)
+                            sit = getattr(it, 'samba_builtin_subsystem', None)
+                            if sit:
+                                implied = sit.sname
+                        if targets[implied] == 'BUILTIN':
                             t.direct_objects.add(implied)
                         elif targets[implied] == 'SYSLIB':
                             t.direct_syslibs.add(implied)
@@ -463,8 +519,13 @@ def build_direct_deps(bld, tgt_list):
                 sys.exit(1)
             if t2.samba_type in [ 'LIBRARY', 'MODULE' ]:
                 t.direct_libs.add(d)
-            elif t2.samba_type in [ 'SUBSYSTEM', 'ASN1', 'PYTHON' ]:
+            elif t2.samba_type in [ 'SUBSYSTEM', 'BUILTIN', 'ASN1', 'PYTHON' ]:
                 t.direct_objects.add(d)
+            elif t2.samba_type in [ 'PLUGIN' ]:
+                Logs.error('Implicit dependency %s in %s is of type %s' % (
+                           d, t.sname, t2.samba_type))
+                sys.exit(1)
+
     debug('deps: built direct dependencies')
 
 
@@ -654,10 +715,10 @@ def break_dependency_loops(bld, tgt_list):
     # expand indirect subsystem and library loops
     for loop in loops.copy():
         t = bld.get_tgen_by_name(loop)
-        if t.samba_type in ['SUBSYSTEM']:
+        if t.samba_type in ['SUBSYSTEM', 'BUILTIN']:
             loops[loop] = loops[loop].union(t.indirect_objects)
             loops[loop] = loops[loop].union(t.direct_objects)
-        if t.samba_type in ['LIBRARY','PYTHON']:
+        if t.samba_type in ['LIBRARY', 'PLUGIN', 'PYTHON']:
             loops[loop] = loops[loop].union(t.indirect_libs)
             loops[loop] = loops[loop].union(t.direct_libs)
         if loop in loops[loop]:
@@ -698,6 +759,8 @@ def break_dependency_loops(bld, tgt_list):
 
 def reduce_objects(bld, tgt_list):
     '''reduce objects by looking for indirect object dependencies'''
+    targets  = LOCAL_CACHE(bld, 'TARGET_TYPE')
+
     rely_on = {}
 
     for t in tgt_list:
@@ -705,7 +768,7 @@ def reduce_objects(bld, tgt_list):
 
     changed = False
 
-    for type in ['BINARY', 'PYTHON', 'LIBRARY']:
+    for type in ['BINARY', 'PYTHON', 'LIBRARY', 'PLUGIN']:
         for t in tgt_list:
             if t.samba_type != type: continue
             # if we will indirectly link to a target then we don't need it
@@ -718,8 +781,13 @@ def reduce_objects(bld, tgt_list):
                     dup = dup.difference(rely_on[t.sname])
                 if dup:
                     # Do not remove duplicates of BUILTINS
-                    d = next(iter(dup))
-                    if BUILTIN_LIBRARY(bld, d):
+                    for d in iter(dup.copy()):
+                        dtype = targets[d]
+                        if dtype == 'BUILTIN':
+                            debug('deps: BUILTIN SKIP: removing dups from %s of type %s: %s also in %s %s',
+                                  t.sname, t.samba_type, d, t2.samba_type, l)
+                            dup.remove(d)
+                    if len(dup) == 0:
                         continue
 
                     debug('deps: removing dups from %s of type %s: %s also in %s %s',
@@ -729,6 +797,19 @@ def reduce_objects(bld, tgt_list):
                     if not l in rely_on:
                         rely_on[l] = set()
                     rely_on[l] = rely_on[l].union(dup)
+            for n in iter(new.copy()):
+                # if we got the builtin version as well
+                # as the native one, we keep using the
+                # builtin one and remove the rest.
+                # Otherwise our check_duplicate_sources()
+                # checks would trigger!
+                if n.endswith('.builtin.objlist'):
+                    unused = n.replace('.builtin.objlist', '.objlist')
+                    if unused in new:
+                        new.remove(unused)
+                    unused = n.replace('.builtin.objlist', '')
+                    if unused in new:
+                        new.remove(unused)
             t.final_objects = new
 
     if not changed:
@@ -834,7 +915,7 @@ def calculate_final_deps(bld, tgt_list, loops):
     # we now need to make corrections for any library loops we broke up
     # any target that depended on the target of the loop and doesn't
     # depend on the source of the loop needs to get the loop source added
-    for type in ['BINARY','PYTHON','LIBRARY','BINARY']:
+    for type in ['BINARY','PYTHON','LIBRARY','PLUGIN','BINARY']:
         for t in tgt_list:
             if t.samba_type != type: continue
             for loop in loops:
@@ -867,7 +948,7 @@ def calculate_final_deps(bld, tgt_list, loops):
 
     # add in any syslib dependencies
     for t in tgt_list:
-        if not t.samba_type in ['BINARY','PYTHON','LIBRARY','SUBSYSTEM']:
+        if not t.samba_type in ['BINARY','PYTHON','LIBRARY','PLUGIN','SUBSYSTEM','BUILTIN']:
             continue
         syslibs = set()
         for d in t.final_objects:
@@ -884,7 +965,7 @@ def calculate_final_deps(bld, tgt_list, loops):
     # find any unresolved library loops
     lib_loop_error = False
     for t in tgt_list:
-        if t.samba_type in ['LIBRARY', 'PYTHON']:
+        if t.samba_type in ['LIBRARY', 'PLUGIN', 'PYTHON']:
             for l in t.final_libs.copy():
                 t2 = bld.get_tgen_by_name(l)
                 if t.sname in t2.final_libs:
@@ -1110,6 +1191,10 @@ def check_project_rules(bld):
 
     debug('deps: project rules checking started')
 
+    replace_builtin_subsystem_deps(bld, tgt_list)
+
+    debug("deps: replace_builtin_subsystem_deps: %s" % str(timer))
+
     expand_subsystem_deps(bld)
 
     debug("deps: expand_subsystem_deps: %s" % str(timer))
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index e08b55cf71d..863e9d5ba22 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -658,7 +658,7 @@ def get_tgt_list(bld):
     tgt_list = []
     for tgt in targets:
         type = targets[tgt]
-        if not type in ['SUBSYSTEM', 'MODULE', 'BINARY', 'LIBRARY', 'ASN1', 'PYTHON']:
+        if not type in ['SUBSYSTEM', 'BUILTIN', 'MODULE', 'BINARY', 'LIBRARY', 'PLUGIN', 'ASN1', 'PYTHON']:
             continue
         t = bld.get_tgen_by_name(tgt)
         if t is None:
diff --git a/buildtools/wafsamba/stale_files.py b/buildtools/wafsamba/stale_files.py
index 175f573296e..78efea424fd 100644
--- a/buildtools/wafsamba/stale_files.py
+++ b/buildtools/wafsamba/stale_files.py
@@ -69,7 +69,7 @@ def replace_refill_task_list(self):
                                 objpath = os.path.normpath(output.abspath(bld.env))
                                 expected.append(objpath)
                     for t in tlist:
-                        if ttype in ['LIBRARY','MODULE']:
+                        if ttype in ['LIBRARY', 'PLUGIN', 'MODULE']:
                             t = samba_utils.apply_pattern(t, bld.env.shlib_PATTERN)
                         if ttype == 'PYTHON':
                             t = samba_utils.apply_pattern(t, bld.env.pyext_PATTERN)
diff --git a/buildtools/wafsamba/symbols.py b/buildtools/wafsamba/symbols.py
index d3bf9ac1c6b..a6af1ac1485 100644
--- a/buildtools/wafsamba/symbols.py
+++ b/buildtools/wafsamba/symbols.py
@@ -252,7 +252,7 @@ def build_symbol_sets(bld, tgt_list):
             bld.env.public_symbols[name] = bld.env.public_symbols[name].union(t.public_symbols)
         else:
             bld.env.public_symbols[name] = t.public_symbols
-        if t.samba_type == 'LIBRARY':
+        if t.samba_type in ['LIBRARY', 'PLUGIN']:
             for dep in t.add_objects:
                 t2 = bld.get_tgen_by_name(dep)
                 bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep))
@@ -265,7 +265,7 @@ def build_symbol_sets(bld, tgt_list):
             bld.env.used_symbols[name] = bld.env.used_symbols[name].union(t.used_symbols)
         else:
             bld.env.used_symbols[name] = t.used_symbols
-        if t.samba_type == 'LIBRARY':
+        if t.samba_type in ['LIBRARY', 'PLUGIN']:
             for dep in t.add_objects:
                 t2 = bld.get_tgen_by_name(dep)
                 bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep))
@@ -281,7 +281,7 @@ def build_library_dict(bld, tgt_list):
     bld.env.library_dict = {}
 
     for t in tgt_list:
-        if t.samba_type in [ 'LIBRARY', 'PYTHON' ]:


-- 
Samba Shared Repository



More information about the samba-cvs mailing list