1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00
samba-mirror/python/samba/tests
Stefan Metzmacher 66e90b7391 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@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2021-11-30 15:53:34 +00:00
..
bin gp: Test Firewalld Group Policy Apply 2021-11-01 20:29:36 +00:00
blackbox CVE-2020-25721 ndrdump: Add tests for PAC with UPN_DNS_INFO 2021-11-09 19:45:32 +00:00
dcerpc CVE-2021-23192: python/tests/dcerpc: add tests to check how security contexts relate to fragmented requests 2021-11-09 19:45:34 +00:00
dns_forwarder_helpers libcli/dns.c: dns forwarder port test changes 2021-09-28 09:44:35 +00:00
emulate python compat: remove StringIO 2020-08-11 16:37:35 +00:00
kcc pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
krb5 tests/krb5: Add a test for S4U2Self with no authorization data required 2021-11-30 02:42:31 +00:00
samba_tool CVE-2020-25722 pytests: Give computer accounts unique (and valid) sAMAccountNames and SPNs 2021-11-09 19:45:34 +00:00
__init__.py CVE-2020-25722 pytest: Raise an error when adding a dynamic test that would overwrite an existing test 2021-11-09 19:45:33 +00:00
audit_log_base.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
audit_log_dsdb.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
audit_log_pass_change.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
auth_log_base.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
auth_log_ncalrpc.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
auth_log_netlogon_bad_creds.py python2 reduction: Merge remaining compat code into common 2020-10-02 14:49:36 +00:00
auth_log_netlogon.py python compat: remove text_type 2020-08-11 16:37:35 +00:00
auth_log_pass_change.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
auth_log_samlogon.py python compat: remove text_type 2020-08-11 16:37:35 +00:00
auth_log_winbind.py python2 reduction: Merge remaining compat code into common 2020-10-02 14:49:36 +00:00
auth_log.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
auth.py PEP8: fix E302: expected 2 blank lines, found 1 2018-08-24 07:49:29 +02:00
common.py python: Move dsdb_Dn to samdb 2020-10-02 13:29:35 +00:00
complex_expressions.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
core.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
cred_opt.py Test password removal via python proctitle 2020-11-26 06:52:41 +00:00
credentials.py Revert "cli_credentials_parse_string: fix parsing of principals" 2020-11-05 06:30:31 +00:00
dckeytab.py python: wrap 'import dckeytab' in an explanatory function 2020-07-17 07:17:40 +00:00
dns_aging.py pytest/dns_aging: remove duplicate tests 2021-11-22 10:28:34 +00:00
dns_base.py pytest:dns_base: make_txt_update can set arbitrary TTL 2021-06-11 08:38:34 +00:00
dns_forwarder.py libcli/dns.c: dns forwarder port test changes 2021-09-28 09:44:35 +00:00
dns_invalid.py python/tests/dns*: remove unused imports 2018-10-25 21:45:54 +02:00
dns_packet.py CVE-2020-14303 Ensure an empty packet will not DoS the NBT server 2020-07-02 09:01:41 +00:00
dns_tkey.py python: Fix usage strings 2021-09-04 00:10:37 +00:00
dns_wildcard.py pytests/dns: use dnsserver.record_from_string 2021-04-08 21:54:35 +00:00
dns.py samba-tool dns: move dns_record_match to dnsserver.py 2021-06-02 03:56:36 +00:00
docs.py pytest/docs: better spelling of set_smbconf_arbitrary 2021-11-22 11:18:09 +00:00
domain_backup_offline.py python/samba/tests: Remove DCs joined to test samba-tool behaviour 2021-06-21 00:58:31 +00:00
domain_backup.py tests: Rework backup test inheritance to make LP constraints clearer 2018-11-27 06:57:03 +01:00
dsdb_api.py pydsdb: Add API to return strings of known UF_ flags 2021-09-02 05:03:31 +00:00
dsdb_dns.py pydns: expose dns timestamp utils to python, and test 2021-03-29 23:20:37 +00:00
dsdb_lock.py PEP8: fix E303: too many blank lines (2) 2018-08-24 07:49:30 +02:00
dsdb_schema_attributes.py selftest: Add prefix to new schema attributes to avoid flapping dsdb_schema_attributes 2021-09-06 02:32:51 +00:00
dsdb.py ridalloc: Don't skip the first RID of a pool 2021-06-11 07:41:38 +00:00
encrypted_secrets.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
gensec.py python/tests/gensec: add spnego downgrade python tests 2019-10-12 14:33:33 +00:00
get_opt.py python: Streamline option parser of python tools 2021-06-20 23:26:32 +00:00
getdcname.py selftest: Improve an error message 2019-01-11 06:01:01 +01:00
glue.py pyglue: add float2nttime() and nttime2float() 2021-03-01 03:50:35 +00:00
gpo_member.py gpo: Enable user policy application 2021-08-13 19:14:30 +00:00
gpo.py gp: Test Firewalld Group Policy Apply 2021-11-01 20:29:36 +00:00
graph.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
group_audit.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
hostconfig.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
imports.py python: Test samdb import 2021-03-10 21:43:34 +00:00
join.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
krb5_credentials.py python tests: fix format() strings for Python 2.6 2018-09-21 20:04:23 +02:00
ldap_raw.py s4 cldap server tests: request size limit tests 2020-05-10 21:45:38 +00:00
ldap_referrals.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
ldap_spn.py CVE-2020-25722 pytest: test setting servicePrincipalName over ldap 2021-11-09 19:45:33 +00:00
ldap_upn_sam_account.py CVE-2020-25722 pytest: test sAMAccountName/userPrincipalName over ldap 2021-11-09 19:45:33 +00:00
libsmb.py tests: SMB2 rename fails to check del-on-close on dst dir 2020-11-19 22:56:41 +00:00
loadparm.py PEP8: fix E302: expected 2 blank lines, found 1 2018-08-24 07:49:29 +02:00
lsa_string.py python/tests/lsa_string: remove duplicate method 2018-10-25 21:45:59 +02:00
messaging.py python compat: remove integer_types 2020-08-11 16:37:35 +00:00
ndr.py selftest: Add test of NDR marshalling from python, starting with wbint 2021-06-02 03:56:36 +00:00
net_join_no_spnego.py PEP8: fix E302: expected 2 blank lines, found 1 2018-08-24 07:49:29 +02:00
net_join.py PEP8: fix E302: expected 2 blank lines, found 1 2018-08-24 07:49:29 +02:00
netbios.py python/tests/netbios: remove unused imports 2018-10-25 21:45:54 +02:00
netcmd.py samba-tool:testparm: Test error handling for unknown sections and parameters 2021-05-17 21:39:38 +00:00
netlogonsvc.py PEP8: fix E302: expected 2 blank lines, found 1 2018-08-24 07:49:29 +02:00
ntacls_backup.py netcmd: Fix opening SamDB database for offline backup 2021-03-24 02:08:54 +00:00
ntacls.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
ntlm_auth_base.py selftest: Add a new base class for ntlm_auth tests 2018-12-19 12:42:09 +01:00
ntlm_auth_krb5.py tests/ntlm_auth: Port ntlm_auth_krb5 tests to python 2018-12-19 12:42:14 +01:00
ntlm_auth.py python2 reduction: Merge remaining compat code into common 2020-10-02 14:49:36 +00:00
ntlmdisabled.py python/tests/*: remove unused imports 2018-10-25 21:45:54 +02:00
pam_winbind_chauthtok.py tests/pam_winbind.py: allow upn names to be used in USERNAME with an empty DOMAIN value 2019-09-24 18:30:37 +00:00
pam_winbind_warn_pwd_expire.py tests/pam_winbind.py: allow upn names to be used in USERNAME with an empty DOMAIN value 2019-09-24 18:30:37 +00:00
pam_winbind.py tests/pam_winbind.py: allow upn names to be used in USERNAME with an empty DOMAIN value 2019-09-24 18:30:37 +00:00
param.py selftest: use 10.53.57.0/8 instead of 127.0.0.1/8 2020-03-27 09:02:38 +00:00
password_hash_fl2003.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
password_hash_fl2008.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
password_hash_gpgme.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
password_hash_ldap.py python compat: remove text_type 2020-08-11 16:37:35 +00:00
password_hash.py python compat: remove text_type 2020-08-11 16:37:35 +00:00
password_quality.py python/tests: remove unused imports 2018-10-25 21:45:54 +02:00
password_test.py python/tests/*: remove unused imports 2018-10-25 21:45:54 +02:00
policy.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
posixacl.py tests/pysmbd: fill session unix info in ntacl tests 2020-06-05 10:32:31 +00:00
prefork_restart.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
process_limits.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
provision.py provision: Remove final code for the LDAP backend 2020-04-23 06:12:20 +00:00
pso.py python tests: fix format() strings for Python 2.6 2018-09-21 20:04:23 +02:00
py_credentials.py python2 reduction: Merge remaining compat code into common 2020-10-02 14:49:36 +00:00
registry.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
s3_net_join.py pytest: s3_net_join: avoid name clash 2021-10-20 12:02:33 +00:00
s3idmapdb.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
s3param.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
s3passdb.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
s3registry.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
s3windb.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
samba3sam.py python: remove all 'from __future__ import print_function' 2021-04-28 03:43:34 +00:00
samba_upgradedns_lmdb.py test upgradedns: ensure lmdb lock files linked 2019-12-20 07:35:41 +00:00
samdb_api.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
samdb.py samdb: Add samdb.domain_netbios_name() 2020-11-11 01:15:39 +00:00
sddl.py libcli: Fix parsing access flags from multiple tables 2021-04-21 00:04:36 +00:00
security.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
segfault.py pytest:segfault: Add test for deleting an ldb.Control critical flag 2021-09-28 09:44:35 +00:00
smb-notify.py python/tests: add tests for smb notify and the dependency to the TRAVERSE privilege 2020-12-17 13:59:38 +00:00
smb.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
smbd_base.py CVE-2019-3870 pysmbd: Include tests to show the outside umask has no impact 2019-04-08 10:27:34 +00:00
smbd_fuzztest.py python: tests. Add test for fuzzing smbd crash bug. 2019-12-04 20:02:40 +00:00
source_chars.py pytest/source_chars: forget thirdparty/pep8 test file 2021-11-19 12:35:39 +00:00
source.py python/tests/krb5: modify rfc4120.asn1 in order to generate pyasn1 code 2020-03-27 18:17:35 +00:00
strings.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
subunitrun.py pytests/subunitrun: not usefully executable 2019-07-02 04:21:36 +00:00
tdb_util.py python: tests: Add test for tdb_copy function from tdb_util module. 2017-07-05 02:00:25 +02:00
test_pam_winbind_chauthtok.sh nsswitch: reduce dependecies to private libraries and link static/builtin if possible 2021-11-30 15:53:34 +00:00
test_pam_winbind_warn_pwd_expire.sh nsswitch: reduce dependecies to private libraries and link static/builtin if possible 2021-11-30 15:53:34 +00:00
test_pam_winbind.sh nsswitch: reduce dependecies to private libraries and link static/builtin if possible 2021-11-30 15:53:34 +00:00
upgrade.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
upgradeprovision.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
upgradeprovisionneeddc.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00
usage.py CVE-2020-25717: tests/krb5: Add a test for idmap_nss mapping users to SIDs 2021-11-15 18:10:28 +00:00
xattr.py pytests: heed assertEquals deprecation warning en-masse 2020-02-07 10:37:37 +00:00