metze/samba/wip.git
9 months agoTODO rtld_next_vsyscall master-krb5-ccache
Stefan Metzmacher [Tue, 8 Nov 2022 18:51:15 +0000 (19:51 +0100)]
TODO rtld_next_vsyscall

9 months agoRevert "libnetapi.idl account/password"
Stefan Metzmacher [Thu, 11 Aug 2022 09:49:05 +0000 (11:49 +0200)]
Revert "libnetapi.idl account/password"

This reverts commit bee4932a1b2ed7e0716061492c79db89c6dab6e5.

9 months agolibnetapi.idl account/password
Stefan Metzmacher [Thu, 11 Aug 2022 09:48:40 +0000 (11:48 +0200)]
libnetapi.idl account/password

9 months agoRevert "NOT NEEDED??? s3:winbindd: ldap_reconnect_need_retry() source3/winbindd/winbi...
Stefan Metzmacher [Mon, 20 Jun 2022 13:01:11 +0000 (15:01 +0200)]
Revert "NOT NEEDED??? s3:winbindd: ldap_reconnect_need_retry() source3/winbindd/winbindd_reconnect_ads.c"

This reverts commit 5b7d69b233aba793269f54e3ff54d22e840cbc9e.

9 months agoNOT NEEDED??? s3:winbindd: ldap_reconnect_need_retry() source3/winbindd/winbindd_reco...
Stefan Metzmacher [Mon, 20 Jun 2022 13:00:37 +0000 (15:00 +0200)]
NOT NEEDED??? s3:winbindd: ldap_reconnect_need_retry() source3/winbindd/winbindd_reconnect_ads.c

9 months agosource3/winbindd/winbindd_cm.c dcip_check_name_ads => ads_connect_anon
Stefan Metzmacher [Thu, 9 Jun 2022 22:03:04 +0000 (00:03 +0200)]
source3/winbindd/winbindd_cm.c dcip_check_name_ads => ads_connect_anon

9 months agos3:winbindd: we don't need ads_kdestroy(WINBIND_CCACHE_NAME); anymore
Stefan Metzmacher [Thu, 9 Jun 2022 16:28:38 +0000 (18:28 +0200)]
s3:winbindd: we don't need ads_kdestroy(WINBIND_CCACHE_NAME); anymore

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: make use of pdb_get_trust_credentials() in ads_cached_ldap_connection...
Stefan Metzmacher [Thu, 9 Jun 2022 12:03:25 +0000 (14:03 +0200)]
s3:winbindd: make use of pdb_get_trust_credentials() in ads_cached_ldap_connection/ads_cached_connection_connect

This way we avoid ads_connect() and use ads_connect_creds() instead.
It also means we no longer use KRB5CCNAME/WINBIND_CCACHE_NAME.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: let ads_cached_connection() use ads_cached_ldap_connection()
Stefan Metzmacher [Thu, 9 Jun 2022 12:02:56 +0000 (14:02 +0200)]
s3:winbindd: let ads_cached_connection() use ads_cached_ldap_connection()

The only thing we loose here is WINBINDD_PAM_AUTH_KRB5_RENEW_TIME,
but that's not really useful for machine passwords, which are always
available from local storage.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: split out ads_cached_ldap_connection()
Stefan Metzmacher [Thu, 9 Jun 2022 16:18:59 +0000 (18:18 +0200)]
s3:winbindd: split out ads_cached_ldap_connection()

This will be reused in ads_cached_connection() soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: let ads_idmap_cached_connection() pass wb_dom->name to ads_cached_connec...
Stefan Metzmacher [Thu, 9 Jun 2022 16:15:07 +0000 (18:15 +0200)]
s3:winbindd: let ads_idmap_cached_connection() pass wb_dom->name to ads_cached_connection_connect()

The value is the same, but it simplifies further changes.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: let ads_idmap_cached_connection() use the correct password the use auth_...
Stefan Metzmacher [Thu, 9 Jun 2022 16:13:38 +0000 (18:13 +0200)]
s3:winbindd: let ads_idmap_cached_connection() use the correct password the use auth_realm

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: introduce a creds_dom variable in ads_cached_connection_connect()
Stefan Metzmacher [Thu, 9 Jun 2022 16:11:38 +0000 (18:11 +0200)]
s3:winbindd: introduce a creds_dom variable in ads_cached_connection_connect()

This way we can simplify the code a lot.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: let ads_cached_connection_connect() use realm = our_domain->alt_name
Stefan Metzmacher [Thu, 9 Jun 2022 16:06:07 +0000 (18:06 +0200)]
s3:winbindd: let ads_cached_connection_connect() use realm = our_domain->alt_name

If lp_realm() has a useful value it means our primary domain has alt_name set,
so we can simplify the code.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: we don't need to copy realm in ads_idmap_cached_connection()
Stefan Metzmacher [Thu, 9 Jun 2022 16:03:57 +0000 (18:03 +0200)]
s3:winbindd: we don't need to copy realm in ads_idmap_cached_connection()

ads_cached_connection_connect() also handles auth_realm == NULL
and returns an error, so no need for an assert.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:winbindd: try realm based SAF cache in ads_idmap_cached_connection()
Stefan Metzmacher [Thu, 9 Jun 2022 15:56:04 +0000 (17:56 +0200)]
s3:winbindd: try realm based SAF cache in ads_idmap_cached_connection()

9 months agos3:winbindd: move find_domain_from_name() further up in ads_idmap_cached_connection()
Stefan Metzmacher [Thu, 9 Jun 2022 15:50:47 +0000 (17:50 +0200)]
s3:winbindd: move find_domain_from_name() further up in ads_idmap_cached_connection()

9 months agos3:winbindd: avoid allocating ads_struct on a stackframe
Stefan Metzmacher [Thu, 11 Aug 2022 12:17:36 +0000 (14:17 +0200)]
s3:winbindd: avoid allocating ads_struct on a stackframe

Allocating it first on the stackframe and them moving it
to a longterm context, leaks the stackframe.

So we first allocate it on the final memory context
and reparent it to the stackframe in order to
have it cleaned up correctly on error.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agolibgpo/pygpo: make use of ads_connect_creds() and ads_connect_machine()
Stefan Metzmacher [Wed, 8 Jun 2022 12:20:57 +0000 (14:20 +0200)]
libgpo/pygpo: make use of ads_connect_creds() and ads_connect_machine()

9 months agosource3/libsmb/namequery_dc.c use ads_connect_anon
Stefan Metzmacher [Thu, 28 Apr 2022 17:08:27 +0000 (19:08 +0200)]
source3/libsmb/namequery_dc.c use ads_connect_anon

9 months agosource3/printing/nt_printing_ads.c ads_connect_machine => ads_kdestroy("MEMORY:prtpub...
Stefan Metzmacher [Thu, 28 Apr 2022 16:58:27 +0000 (18:58 +0200)]
source3/printing/nt_printing_ads.c ads_connect_machine => ads_kdestroy("MEMORY:prtpub_cache");

cli_credentials_set_ccache() free_dccache => free_mccache (optional)

9 months agoadd ads_connect_machine()
Stefan Metzmacher [Thu, 28 Apr 2022 16:53:03 +0000 (18:53 +0200)]
add ads_connect_machine()

9 months agosource3/libads/ldap.c make use of ads_connect_anon() where possible
Stefan Metzmacher [Thu, 28 Apr 2022 16:43:00 +0000 (18:43 +0200)]
source3/libads/ldap.c make use of ads_connect_anon() where possible

9 months agosq add ads_connect_anon()
Stefan Metzmacher [Thu, 28 Apr 2022 16:41:08 +0000 (18:41 +0200)]
sq add ads_connect_anon()

9 months agosq source3/utils/net_ads.c use ads_connect_anon()
Stefan Metzmacher [Thu, 28 Apr 2022 16:39:23 +0000 (18:39 +0200)]
sq source3/utils/net_ads.c use ads_connect_anon()

9 months agoadd ads_connect_anon()
Stefan Metzmacher [Thu, 28 Apr 2022 16:38:17 +0000 (18:38 +0200)]
add ads_connect_anon()

9 months agoSPLIT source3/utils/net_ads.c use ads_connect_creds()
Stefan Metzmacher [Thu, 28 Apr 2022 16:28:59 +0000 (18:28 +0200)]
SPLIT source3/utils/net_ads.c use ads_connect_creds()

9 months agolibnet_connect_ads() make use of ads_connect_creds()
Stefan Metzmacher [Thu, 28 Apr 2022 16:00:29 +0000 (18:00 +0200)]
libnet_connect_ads() make use of ads_connect_creds()

9 months agopass creds to libnet_connect_ads()
Stefan Metzmacher [Thu, 28 Apr 2022 15:59:00 +0000 (17:59 +0200)]
pass creds to libnet_connect_ads()

9 months agoadd ads_simple_creds
Stefan Metzmacher [Thu, 28 Apr 2022 15:51:57 +0000 (17:51 +0200)]
add ads_simple_creds

9 months agoHACK debug net ads join libads machine libnet_join_connect_ads_machine() failing
Stefan Metzmacher [Thu, 28 Apr 2022 14:35:45 +0000 (16:35 +0200)]
HACK debug net ads join libads machine libnet_join_connect_ads_machine() failing

9 months agosq ads_prepare_krb5
Stefan Metzmacher [Thu, 28 Apr 2022 14:34:36 +0000 (16:34 +0200)]
sq ads_prepare_krb5

9 months agoads_legacy_creds ads->auth.ccache_name
Stefan Metzmacher [Thu, 28 Apr 2022 14:33:57 +0000 (16:33 +0200)]
ads_legacy_creds ads->auth.ccache_name

9 months agoads_legacy_creds move cli_credentials_set_ccache last???
Stefan Metzmacher [Thu, 28 Apr 2022 10:15:15 +0000 (12:15 +0200)]
ads_legacy_creds move cli_credentials_set_ccache last???

9 months agoFIX ads_legacy_creds cli_credentials_set_ccache...
Stefan Metzmacher [Thu, 28 Apr 2022 10:13:18 +0000 (12:13 +0200)]
FIX ads_legacy_creds cli_credentials_set_ccache...

9 months agoHACK/DEBUG/FIX ads_prepare_krb5
Stefan Metzmacher [Thu, 28 Apr 2022 10:12:08 +0000 (12:12 +0200)]
HACK/DEBUG/FIX ads_prepare_krb5

9 months agosq ads_prepare_krb5...
Stefan Metzmacher [Thu, 28 Apr 2022 07:32:20 +0000 (09:32 +0200)]
sq ads_prepare_krb5...

9 months agoRevert "TODO source3/librpc/idl/libnet_join.idl only admin_credentials"
Stefan Metzmacher [Thu, 28 Apr 2022 07:28:38 +0000 (09:28 +0200)]
Revert "TODO source3/librpc/idl/libnet_join.idl only admin_credentials"

This reverts commit 6a62df55785aa3742ce48363105f74e737788a18.

9 months agoads_prepare_krb5...
Stefan Metzmacher [Thu, 28 Apr 2022 07:24:22 +0000 (09:24 +0200)]
ads_prepare_krb5...

9 months agoNEEDED? ads_legacy_creds cli_credentials_set_ccache
Stefan Metzmacher [Mon, 25 Apr 2022 16:21:58 +0000 (18:21 +0200)]
NEEDED? ads_legacy_creds cli_credentials_set_ccache

9 months agoads_prepare_krb5...
Stefan Metzmacher [Thu, 28 Apr 2022 07:19:18 +0000 (09:19 +0200)]
ads_prepare_krb5...

9 months agokdc_db_ctx->disable_db_enumeration
Stefan Metzmacher [Thu, 28 Apr 2022 06:29:54 +0000 (08:29 +0200)]
kdc_db_ctx->disable_db_enumeration

9 months agonet_ads_leave only creds
Stefan Metzmacher [Tue, 26 Apr 2022 14:50:41 +0000 (16:50 +0200)]
net_ads_leave only creds

9 months agosource3/utils/py_net.c creds
Stefan Metzmacher [Tue, 26 Apr 2022 14:10:20 +0000 (16:10 +0200)]
source3/utils/py_net.c creds

9 months agoTODO source3/librpc/idl/libnet_join.idl only admin_credentials
Stefan Metzmacher [Mon, 25 Apr 2022 16:49:12 +0000 (18:49 +0200)]
TODO source3/librpc/idl/libnet_join.idl only admin_credentials

9 months agosource3/utils/net_ pass r->in.admin_credentials = c->creds
Stefan Metzmacher [Mon, 25 Apr 2022 16:44:17 +0000 (18:44 +0200)]
source3/utils/net_ pass r->in.admin_credentials = c->creds

9 months agosource3/librpc/idl/libnet_join.idl admin_credentials
Stefan Metzmacher [Mon, 25 Apr 2022 16:41:00 +0000 (18:41 +0200)]
source3/librpc/idl/libnet_join.idl admin_credentials

9 months agos3:libads: split out ads_connect_creds() and call it with ads_legacy_creds()
Stefan Metzmacher [Wed, 27 Apr 2022 11:11:26 +0000 (13:11 +0200)]
s3:libads: split out ads_connect_creds() and call it with ads_legacy_creds()

9 months agos3:libads: let ads_sasl_spnego_bind() use cli_credentials_get_unparsed_name()
Stefan Metzmacher [Wed, 27 Apr 2022 10:45:04 +0000 (12:45 +0200)]
s3:libads: let ads_sasl_spnego_bind() use cli_credentials_get_unparsed_name()

We should only operate on the creds structure and
avoid using ads->auth.{user_name,realm}.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libads: let ads_sasl_spnego_bind() reset krb5_state at the end
Stefan Metzmacher [Wed, 27 Apr 2022 11:39:11 +0000 (13:39 +0200)]
s3:libads: let ads_sasl_spnego_bind() reset krb5_state at the end

In future we'll pass in creds from the caller, so we better
restore the original krb5_state at the end of ads_sasl_spnego_bind().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libads: let ads_sasl_spnego_bind() use cli_credentials_get_kerberos_state()
Stefan Metzmacher [Wed, 27 Apr 2022 10:32:30 +0000 (12:32 +0200)]
s3:libads: let ads_sasl_spnego_bind() use cli_credentials_get_kerberos_state()

We should only operate on the creds structure and avoid ads->auth.flags

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agoRevert "NEEDED? ads_legacy_creds cli_credentials_set_ccache"
Stefan Metzmacher [Wed, 27 Apr 2022 11:27:51 +0000 (13:27 +0200)]
Revert "NEEDED? ads_legacy_creds cli_credentials_set_ccache"

This reverts commit 626ab9e5711c9e125cf4dbbf0f8f8702e3180348.

9 months agoNEEDED? ads_legacy_creds cli_credentials_set_ccache
Stefan Metzmacher [Mon, 25 Apr 2022 16:21:58 +0000 (18:21 +0200)]
NEEDED? ads_legacy_creds cli_credentials_set_ccache

9 months agos3:libads: split out ads_legacy_creds()
Stefan Metzmacher [Mon, 25 Apr 2022 16:08:33 +0000 (18:08 +0200)]
s3:libads: split out ads_legacy_creds()

This is just a temporary change until the highlevel caller
will pass in a cli_credentials structure and we'll get rid of
ads->auth.{user_name,realm,password}.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agolib/cmdline/cmdline.c legacy_s3_kerberos
Stefan Metzmacher [Tue, 26 Apr 2022 15:47:26 +0000 (17:47 +0200)]
lib/cmdline/cmdline.c legacy_s3_kerberos

9 months agos3:libads: remove unused server_blob argument to ads_sasl_spnego_gensec_bind()
Stefan Metzmacher [Mon, 25 Apr 2022 15:36:48 +0000 (17:36 +0200)]
s3:libads: remove unused server_blob argument to ads_sasl_spnego_gensec_bind()

With libads we always have a valid target_service and target_hostname.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agoTODO: docs-xml/smbdotconf/security/clientusedefaultkrb5ccache.xml
Stefan Metzmacher [Thu, 14 Apr 2022 10:48:54 +0000 (12:48 +0200)]
TODO: docs-xml/smbdotconf/security/clientusedefaultkrb5ccache.xml

9 months agofix python/samba/getopt.py
Stefan Metzmacher [Wed, 16 Mar 2022 13:08:11 +0000 (14:08 +0100)]
fix python/samba/getopt.py

9 months agosource3/script/tests/test_smbclient_krb5.sh STEP3
Stefan Metzmacher [Wed, 16 Mar 2022 11:30:39 +0000 (12:30 +0100)]
source3/script/tests/test_smbclient_krb5.sh STEP3

9 months agoTODO-SPLIT add --use-default-krb5-ccache to select the default ccache
Stefan Metzmacher [Wed, 16 Mar 2022 10:39:56 +0000 (11:39 +0100)]
TODO-SPLIT add --use-default-krb5-ccache to select the default ccache

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15018

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agosource3/script/tests/test_smbclient_krb5.sh STEP2
Stefan Metzmacher [Wed, 16 Mar 2022 11:30:28 +0000 (12:30 +0100)]
source3/script/tests/test_smbclient_krb5.sh STEP2

9 months agolib/cmdline/cmdline.c --use-krb5-ccache= needs to export KRB5CCNAME
Stefan Metzmacher [Wed, 16 Mar 2022 11:42:56 +0000 (12:42 +0100)]
lib/cmdline/cmdline.c --use-krb5-ccache= needs to export KRB5CCNAME

9 months agosource3/script/tests/test_smbclient_krb5.sh STEP 1
Stefan Metzmacher [Wed, 16 Mar 2022 11:29:58 +0000 (12:29 +0100)]
source3/script/tests/test_smbclient_krb5.sh STEP 1

9 months agolib/cmdline: skip the password prompt if we have a valid krb5 ccache
Stefan Metzmacher [Thu, 14 Apr 2022 11:34:37 +0000 (13:34 +0200)]
lib/cmdline: skip the password prompt if we have a valid krb5 ccache

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agolib/cmdline: only call cli_credentials_get_password_and_obtained if needed
Stefan Metzmacher [Thu, 14 Apr 2022 11:31:20 +0000 (13:31 +0200)]
lib/cmdline: only call cli_credentials_get_password_and_obtained if needed

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agolib/cmdline: move cli_credentials_set_cmdline_callbacks to the end of POPT_CALLBACK_R...
Stefan Metzmacher [Thu, 14 Apr 2022 11:30:56 +0000 (13:30 +0200)]
lib/cmdline: move cli_credentials_set_cmdline_callbacks to the end of POPT_CALLBACK_REASON_POST

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libsmb: avoid exporting KRB5CCNAME in cli_session_creds_prepare_krb5()
Stefan Metzmacher [Thu, 14 Apr 2022 15:00:34 +0000 (17:00 +0200)]
s3:libsmb: avoid exporting KRB5CCNAME in cli_session_creds_prepare_krb5()

It's no longer needed for the gse module.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:gse: get an explicit ccache_name from creds and require a valid cache
Stefan Metzmacher [Thu, 14 Apr 2022 13:23:13 +0000 (15:23 +0200)]
s3:gse: get an explicit ccache_name from creds and require a valid cache

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:gse: avoid prompting for a password that we don't use in the end
Stefan Metzmacher [Thu, 14 Apr 2022 12:23:23 +0000 (14:23 +0200)]
s3:gse: avoid prompting for a password that we don't use in the end

Currently we rely on a valid default credential cache being available
and don't make use of the password.

In future we'll do a kinit on demand, but that's for another day.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libsmb: let cli_session_creds_prepare_krb5() kinit into a ccache on creds
Stefan Metzmacher [Thu, 14 Apr 2022 14:51:44 +0000 (16:51 +0200)]
s3:libsmb: let cli_session_creds_prepare_krb5() kinit into a ccache on creds

This will allow the gse module to get an explicit ccache_name from creds
and we'll avoid using the KRB5CCNAME environment variable in the next
commits.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libsmb: avoid prompting for a password if we have a valid krb5 ccache
Stefan Metzmacher [Thu, 14 Apr 2022 13:19:57 +0000 (15:19 +0200)]
s3:libsmb: avoid prompting for a password if we have a valid krb5 ccache

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:client: avoid cli_credentials_get_password() to check for a specified password
Stefan Metzmacher [Thu, 14 Apr 2022 11:49:39 +0000 (13:49 +0200)]
s3:client: avoid cli_credentials_get_password() to check for a specified password

Using cli_credentials_get_password_obtained() is more lightweight as
it avoids a possible password prompt.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libsmb: let cli_tree_connect_creds() only call cli_credentials_get_password()...
Stefan Metzmacher [Thu, 14 Apr 2022 13:36:51 +0000 (15:36 +0200)]
s3:libsmb: let cli_tree_connect_creds() only call cli_credentials_get_password() if needed

Only legacy protocols need a password for share level authentication,
so avoid triggering the password prompt for the common case.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agoauth/credentials: add cli_credentials_get_ccache_name_obtained()
Stefan Metzmacher [Thu, 14 Apr 2022 11:29:47 +0000 (13:29 +0200)]
auth/credentials: add cli_credentials_get_ccache_name_obtained()

It's often good to know if a credential structure already has
a valid kerberos credential cache attached, without the side
effect of doing a kinit and prompt for a password.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agoauth/credentials: add cli_credentials_get_password_obtained()
Stefan Metzmacher [Thu, 14 Apr 2022 11:46:18 +0000 (13:46 +0200)]
auth/credentials: add cli_credentials_get_password_obtained()

It's often useful to know if a password was already explicitly
specified without triggering the password callback function.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libsmb: remove unused spnego_parse_negTokenInit() function
Stefan Metzmacher [Mon, 18 Oct 2021 10:57:01 +0000 (12:57 +0200)]
s3:libsmb: remove unused spnego_parse_negTokenInit() function

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libsmb: libcli/auth/spnego.h is not needed in cliconnect.c
Stefan Metzmacher [Mon, 18 Oct 2021 10:52:22 +0000 (12:52 +0200)]
s3:libsmb: libcli/auth/spnego.h is not needed in cliconnect.c

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libads: remove unused ADS_AUTH_SIMPLE_BIND code
Stefan Metzmacher [Mon, 25 Apr 2022 12:49:33 +0000 (14:49 +0200)]
s3:libads: remove unused ADS_AUTH_SIMPLE_BIND code

We have other code to test simple binds.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libads: avoid changing ADS->server.workgroup
Stefan Metzmacher [Fri, 15 Oct 2021 01:34:11 +0000 (03:34 +0200)]
s3:libads: avoid changing ADS->server.workgroup

ads_find_dc() uses c_domain = ads->server.workgroup and
don't expect it to get out of scope deep in resolve_and_ping_dns().

The result are corrupted domain values in the debug output.

Valgrind shows this:

 Invalid read of size 1
    at 0x483EF46: strlen (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x608BE94: __vfprintf_internal (vfprintf-internal.c:1688)
    by 0x609ED49: __vasprintf_internal (vasprintf.c:57)
    by 0x5D2EC0F: __dbgtext_va (debug.c:1860)
    by 0x5D2ED3F: dbgtext (debug.c:1881)
    by 0x4BFFB50: ads_find_dc (ldap.c:570)
    by 0x4C001F4: ads_connect (ldap.c:704)
    by 0x4C1DC12: ads_dc_name (namequery_dc.c:84)
  Address 0xb69f6f0 is 0 bytes inside a block of size 11 free'd
    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4BFF0AF: ads_try_connect (ldap.c:299)
    by 0x4BFF40E: cldap_ping_list (ldap.c:367)
    by 0x4BFF75F: resolve_and_ping_dns (ldap.c:468)
    by 0x4BFFA91: ads_find_dc (ldap.c:556)
    by 0x4C001F4: ads_connect (ldap.c:704)
    by 0x4C1DC12: ads_dc_name (namequery_dc.c:84)
  Block was alloc'd at
    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x60B250E: strdup (strdup.c:42)
    by 0x4FF1492: smb_xstrdup (util.c:743)
    by 0x4C10E62: ads_init (ads_struct.c:148)
    by 0x4C1DB68: ads_dc_name (namequery_dc.c:73)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14981

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libads: directly use kerberos without asking the server
Stefan Metzmacher [Mon, 18 Oct 2021 10:21:57 +0000 (12:21 +0200)]
s3:libads: directly use kerberos without asking the server

Every AD DC supports kerberos so we can just use it without
asking the server (in an untrusted way) if kerberos is supported.
So remove another useless roundtrip.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agos3:libads: use GSS-SPNEGO directly without asking for supportedSASLMechanisms
Stefan Metzmacher [Mon, 18 Oct 2021 10:20:15 +0000 (12:20 +0200)]
s3:libads: use GSS-SPNEGO directly without asking for supportedSASLMechanisms

Every AD DC supports 'GSS-SPNEGO' and that's the only one we use anyway,
so remove an unused roundtrip.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
9 months agolibrpc/nbt: Avoid reading invalid member of union
Joseph Sutton [Wed, 5 Jul 2023 22:57:59 +0000 (10:57 +1200)]
librpc/nbt: Avoid reading invalid member of union

WACK packets use the ‘data’ member of the ‘nbt_rdata’ union, but they
claim to be a different type — NBT_QTYPE_NETBIOS — than would normally
be used with that union member. This means that if rr_type is equal to
NBT_QTYPE_NETBIOS, ndr_push_nbt_res_rec() has to guess which type the
structure really is by examining the data member. However, if the
structure is actually of a different type, that union member will not be
valid and accessing it will invoke undefined behaviour.

To fix this, eliminate all the guesswork and introduce a new type,
NBT_QTYPE_WACK, which can never appear on the wire, and which indicates
that although the ‘data’ union member should be used, the wire type is
actually NBT_QTYPE_NETBIOS.

This means that as far as NDR is concerned, the ‘netbios’ member of the
‘nbt_rdata’ union will consistently be used for all NBT_QTYPE_NETBIOS
structures; we shall no longer access the wrong member of the union.

Credit to OSS-Fuzz.

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38480

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15019

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri Jul  7 01:14:06 UTC 2023 on atb-devel-224

9 months agolibrpc:ndr: Fix overflow in ndr_push_expand
Joseph Sutton [Wed, 5 Jul 2023 22:50:05 +0000 (10:50 +1200)]
librpc:ndr: Fix overflow in ndr_push_expand

If ‘size’ was equal to UINT32_MAX, the expression ‘size+1’ could
overflow to zero.

This could result in inadequate memory being allocated, which could
cause ndr_pull_compression_xpress_huff_raw_chunk() to overflow memory
with zero bytes.

Credit to OSS-Fuzz.

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=57728

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15415

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agos3:rpc_server: Fix double blackslash issue in dfs path
Pavel Filipenský [Tue, 20 Jun 2023 14:24:55 +0000 (16:24 +0200)]
s3:rpc_server: Fix double blackslash issue in dfs path

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15400

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jul  5 20:24:35 UTC 2023 on atb-devel-224

9 months agos3:rpc_server: Initialize consumedcnt to 0 in _dfs_GetInfo()
Pavel Filipenský [Fri, 23 Jun 2023 08:08:39 +0000 (10:08 +0200)]
s3:rpc_server: Initialize consumedcnt to 0 in _dfs_GetInfo()

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agos3:tests: Add rpcclient 'dfsgetinfo' test
Pavel Filipenský [Fri, 23 Jun 2023 10:03:30 +0000 (12:03 +0200)]
s3:tests: Add rpcclient 'dfsgetinfo' test

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15400

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbd: call exit_server_cleanly() to avoid panicking
Ralph Boehme [Wed, 5 Jul 2023 09:33:58 +0000 (11:33 +0200)]
smbd: call exit_server_cleanly() to avoid panicking

The parent smdb forwards SIGTERM to its process group in order to kill all
children like the scavenger. This happens from a function registered via
atexit() which means the signal forwarding is happening very briefly before the
main smbd process exits. When exiting the pipe between smbd and scavenger is
closed which triggers a file event in the scavenger.

However, due to kernel sheduling it is possible that the file descriptor event
is received before the signal, where we call exit_server() which call
smb_panic() at the end.

Change the exit to exit_server_cleanly() and just log this event at level 2
which we already do.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15275

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jul  5 13:14:08 UTC 2023 on atb-devel-224

9 months agos3:winbindd: let winbind_samlogon_retry_loop() fallback to NT_STATUS_NO_LOGON_SERVERS
Stefan Metzmacher [Tue, 4 Jul 2023 12:12:03 +0000 (14:12 +0200)]
s3:winbindd: let winbind_samlogon_retry_loop() fallback to NT_STATUS_NO_LOGON_SERVERS

When we were not able to get a valid response from any DC we should
report NT_STATUS_NO_LOGON_SERVERS with authoritative = 1.

This matches what windows does. In a chain of transitive
trusts the ACCESS_DENIED/authoritative=0 is not propagated,
instead NT_STATUS_NO_LOGON_SERVERS/authoritative=1 is
passed along the chain if there's no other DC is available.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15413

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3:winbindd: make use of reset_cm_connection_on_error() in winbind_samlogon_retry_loop()
Stefan Metzmacher [Tue, 4 Jul 2023 11:01:24 +0000 (13:01 +0200)]
s3:winbindd: make use of reset_cm_connection_on_error() in winbind_samlogon_retry_loop()

Note this is more than a simple invalidate_cm_connection() as it may set
domain->conn.netlogon_force_reauth = true, which is important in order
to recover from NT_STATUS_RPC_SEC_PKG_ERROR errors.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15413

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3:winbindd: let winbind_samlogon_retry_loop() always start with authoritative = 1
Stefan Metzmacher [Wed, 16 Feb 2022 13:19:16 +0000 (14:19 +0100)]
s3:winbindd: let winbind_samlogon_retry_loop() always start with authoritative = 1

Otherwise we could treat a local problem as non-authoritative.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15413

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3:winbindd: make use of reset_cm_connection_on_error() for winbindd_lookup_{names...
Stefan Metzmacher [Tue, 4 Jul 2023 10:32:34 +0000 (12:32 +0200)]
s3:winbindd: make use of reset_cm_connection_on_error() for winbindd_lookup_{names,sids}()

Note this is more than a simple invalidate_cm_connection() as it may set
domain->conn.netlogon_force_reauth = true.

This is not strictly needed as the callers call
reset_cm_connection_on_error() via reconnect_need_retry().
But it might avoid one roundtrip.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15413

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3:winbindd: call reset_cm_connection_on_error() in wb_cache_query_user_list()
Stefan Metzmacher [Tue, 4 Jul 2023 10:32:34 +0000 (12:32 +0200)]
s3:winbindd: call reset_cm_connection_on_error() in wb_cache_query_user_list()

This is mostly for consistency, every remote call should call
reset_cm_connection_on_error(). Note this is more than
a simple invalidate_cm_connection() as it may set
domain->conn.netlogon_force_reauth = true.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15413

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agoctdb-tests: Run ShellCheck on event-script unit test support scripts
Martin Schwenke [Mon, 3 Jul 2023 02:02:36 +0000 (12:02 +1000)]
ctdb-tests: Run ShellCheck on event-script unit test support scripts

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Jul  5 12:16:57 UTC 2023 on atb-devel-224

9 months agoctdb-tests: Avoid ShellCheck warnings
Martin Schwenke [Sun, 2 Jul 2023 23:32:26 +0000 (09:32 +1000)]
ctdb-tests: Avoid ShellCheck warnings

These are all trivial, so handle them in bulk.

* Change code to avoid (approximately sorted by frequency):

  SC2004 $/${} is unnecessary on arithmetic variables.
  SC2086 Double quote to prevent globbing and word splitting.
  SC2162 read without -r will mangle backslashes.
  SC2254 Quote expansions in case patterns to match literally rather than as a glob.
  SC2154 (warning): <variable> is referenced but not assigned.
  SC3037 (warning): In POSIX sh, echo flags are undefined.
  SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
  SC2069 (warning): To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).
  SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
  SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
  SC2223 (info): This default assignment may cause DoS due to globbing. Quote it.

* Locally disable checks:

  SC2034 (warning): <variable> appears unused. Verify use (or export if used externally).
  SC2086 (info): Double quote to prevent globbing and word splitting. [once]
  SC2120 (warning): <function> references arguments, but none are ever passed.
  SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

While touching reads for SC2162, switch unused variables to "_"
instead of "_x", which seems to be preferred by ShellCheck.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
9 months agoctdb-tests: Avoid ShellCheck warning SC2059
Martin Schwenke [Tue, 4 Jul 2023 00:30:05 +0000 (10:30 +1000)]
ctdb-tests: Avoid ShellCheck warning SC2059

  SC2059 (info): Don't use variables in the printf format string. Use printf '..%s..' "$foo".

Move the format string to the function and just parameterise the share
type.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
9 months agoctdb-tests: Avoid ShellCheck warnings SC2046, SC2005
Martin Schwenke [Mon, 3 Jul 2023 01:54:15 +0000 (11:54 +1000)]
ctdb-tests: Avoid ShellCheck warnings SC2046, SC2005

In ./tests/UNIT/eventscripts/scripts/local.sh line 328:
echo $(ctdb ifaces -X | awk -F'|' 'FNR > 1 {print $2}')
             ^-- SC2046 (warning): Quote this to prevent word splitting.
             ^-- SC2005 (style): Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.

Use xargs to get output on 1 line.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
9 months agoctdb-tests: Drop unreachable code
Martin Schwenke [Mon, 3 Jul 2023 01:42:56 +0000 (11:42 +1000)]
ctdb-tests: Drop unreachable code

This generates ShellCheck warnings:

In ./tests/UNIT/eventscripts/scripts/60.nfs.sh line 412:
if [ -n "$service_check_cmd" ]; then
                                 ^----------------^ SC2031 (info): service_check_cmd was modified in a subshell. That change might be lost.

In ./tests/UNIT/eventscripts/scripts/60.nfs.sh line 413:
if eval "$service_check_cmd"; then
                                         ^----------------^ SC2031 (info): service_check_cmd was modified in a subshell. That change might be lost.

service_check_cmd will never be set here because it is only set in a
sub-shell in rpc_set_service_failure_response().

This reverts some of commit 713ec217507d2f0d5f516efc45c8cd8773fccc14.

If testcases requiring use of service_check_cmd are later added then
this will need to be redone properly.  This would probably start by
renaming this function nfs_iterate_rpc_test().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
9 months agoctdb-tests: Reformat with "shfmt -w -p -i 0 -fn"
Martin Schwenke [Sun, 2 Jul 2023 23:26:34 +0000 (09:26 +1000)]
ctdb-tests: Reformat with "shfmt -w -p -i 0 -fn"

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
9 months agoctdb-tests: Drop unused test code for tunables
Martin Schwenke [Fri, 16 Jun 2023 03:28:40 +0000 (13:28 +1000)]
ctdb-tests: Drop unused test code for tunables

This is unused since loading tunables was moved to ctdbd.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
9 months agoctdb-tests: Avoid ShellCheck warning SC2086
Martin Schwenke [Mon, 3 Jul 2023 02:10:28 +0000 (12:10 +1000)]
ctdb-tests: Avoid ShellCheck warning SC2086

  SC2086 Double quote to prevent globbing and word splitting.

Apparently ShellCheck is more picky about some of these than it used
to be.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>