1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

1390 Commits

Author SHA1 Message Date
Stefan Metzmacher
8132edf119 s3:libads: let cldap_ping_list() use cldap_multi_netlogon()
We have a list of ip addresses, so we can request them
all together under a single timeout, instead of asking
each ip with it's own timeout.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Sep  8 08:12:46 UTC 2022 on sn-devel-184
2022-09-08 08:12:46 +00:00
Stefan Metzmacher
ab6b9465ed s3:libads: split out ads_fill_cldap_reply() out of ads_try_connect()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2022-09-08 07:16:36 +00:00
Pavel Filipenský
4df98ed05d s3:libads: Zero memory in ads_change_trust_account_password()
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2022-08-26 07:59:32 +00:00
Pavel Filipenský
f641abfcb5 s3:libads: Fix trailing whitespaces in util.c
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2022-08-26 07:59:32 +00:00
Jeremy Allison
96a649efd8 s3: libads: Fix coverity false positive.
dn is always returned as NULL on error in ads_build_path(),
but coverity can't see that. Easy change to quieten it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Jul  4 16:42:28 UTC 2022 on sn-devel-184
2022-07-04 16:42:28 +00:00
Jeremy Allison
5903657bd9 s3: libads: Fix return from malloc check.
We shouldn't be checking *realm != '\0' here, just
the return from malloc.

Coverity CID: 1506719.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun 30 16:28:30 UTC 2022 on sn-devel-184
2022-06-30 16:28:30 +00:00
Andreas Schneider
fbf134c8d9 s3:libads: Check if we have a valid sockaddr
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Jun 27 20:39:31 UTC 2022 on sn-devel-184
2022-06-27 20:39:31 +00:00
Andreas Schneider
d96a6cafe5 s4:libads: Fix trailing whitespaces in ldap.c
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 19:47:28 +00:00
Samuel Cabrero
3d6ec74fd2 s3:libads: RIP ads_destroy()
All ADS_STRUCT members are allocated under its talloc context.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
8ea0dd1a38 s3:libads: Allocate ads->config.config_path under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
6ca5eaccfa s3:libads: Allocate ads->config.schema_path under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
9fe2cf1b20 s3:libads: Allocate ads->config.client_site_name under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
40cd92040b s3:libads: Allocate ads->config.server_site_name under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
dcf6578dff s3:libads: Allocate ads->config.ldap_server_name under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
dd9e0f1191 s3:libads: Allocate ads->config.bind_path under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
b2381e1038 s3:libads: Return ADS_STATUS from ads_build_dn()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
9530ca8537 s3:libads: Return ADS_STATUS from ads_build_path()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
b8a0446a4d s3:libads: Allocate ads->config.realm under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
ed784ed07e s3:libads: Allocate ads->auth.ccache_name under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
89c3f22407 s3:libads: Print ads->auth.ccache_name in ndr_print_ads_struct()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
ca7ac79fae s3:libads: Allocate ads->auth.kdc_server under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
633ccc55c0 s3:libads: Allocate ads->auth.user_name under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
d64335eaef s3:libads: Allocate ads->auth.password under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
c1ab39163b s3:libads: Allocate ads->auth.realm under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
cc8465f1b7 s3:libads: Allocate ads->server.ldap_server under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
5ec9b8ef31 s3:libads: Allocate ads->server.workgroup under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
cdef601150 s3:libads: Alloc ads->server.realm under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
e60d2bc8c8 s3:libads: Remove no longer used is_mine flag from ADS_STRUCT
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
d0dc0171ad s3:libads: Allocate ADS_STRUCT under a talloc context
The ads_destroy() function is now static and only called from the
ADS_STRUCT destructor.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
d005418005 s3:libads: Move the ads_destroy() function up in the file
Will be static soon

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
e6cd1be1e9 s3:libads: Remove unused define
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:30 +00:00
Samuel Cabrero
9163033560 s3:libads: Allocate temporary memory context for ads_domain_func_level()
Prepare to allocate ADS_STRUCT under talloc context.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:29 +00:00
Samuel Cabrero
2093639117 s3:libads: Rename talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:29 +00:00
Samuel Cabrero
6223dea34e s3:libads: Pass the correct ADS_STRUCT pointer to ads_msgfree
The search is performed using the ads_s pointer.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:29 +00:00
Samuel Cabrero
ed89ef46af s3:libads: Clear previous CLDAP ping flags when reusing the ADS_STRUCT
Fixes the problem described in commit a26f535ded
but for ads_domain_func_level() function.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-06-27 15:50:29 +00:00
Samuel Cabrero
a26f535ded s3:libads: Clear previous CLDAP ping flags when reusing the ADS_STRUCT
Before commit 1d066f37b9, when the LDAP
connection wasn't established yet (ads->ldap.ld == NULL), the
ads_current_time() function always allocated and initialized a new
ADS_STRUCT even when ads->ldap.ss had a good address after having called
ads_find_dc().

After that commit, when the ADS_STRUCT is reused and passed to the
ads_connect() call, ads_try_connect() may fail depending on the
contacted DC because ads->config.flags field can contain the flags
returned by the previous CLDAP call. For example, when having 5 DCs:

* 192.168.101.31 has PDC FSMO role
* 192.168.101.32
* 192.168.101.33
* 192.168.101.34
* 192.168.101.35

$> net ads info -S 192.168.101.35

net_ads_info()
  ads_startup_nobind()
    ads_startup_int()
      ads_init()
      ads_connect()
        ads_try_connect(192.168.101.35)
          check_cldap_reply_required_flags(returned=0xF1FC, required=0x0)
  ads_current_time()
    ads_connect()
      ads_try_connect(192.168.101.35)
        check_cldap_reply_required_flags(returned=0xF1FC, required=0xF1FC)

The check_cldap_reply_required_flags() call fails because
ads->config.flags contain the flags returned by the previous CLDAP call,
even when the returned and required values match because they have
different semantics:

  if (req_flags & DS_PDC_REQUIRED)
        RETURN_ON_FALSE(ret_flags & NBT_SERVER_PDC);

  translates to:

  if (0xF1FC & 0x80)
        RETURN_ON_FALSE(0xF1FC & 0x01);

  which returns false because 192.168.101.35 has no PDC FSMO role.

The easiest fix for now is to reset ads->config.flags in
ads_current_time() when reusing an ADS_STRUCT before calling
ads_connect(), but we should consider storing the required and returned
flags in different fields or at least use the same bitmap for them
because check_cldap_reply_required_flags() is checking a
netr_DsRGetDCName_flags value using the nbt_server_type bitmap.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon May 23 19:18:38 UTC 2022 on sn-devel-184
2022-05-23 19:18:38 +00:00
Samuel Cabrero
11e0eb6f93 s3:libads: Print 'gc' and 'no_fallback' fields in ndr_print_ads_struct()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-05-23 18:25:28 +00:00
Andreas Schneider
68d181ee67 s3:libads: Fix creating local krb5.conf
We create an KDC ip string entry directly at the beginning, use it if we
don't have any additional DCs.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>

Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Mar 16 14:26:36 UTC 2022 on sn-devel-184
2022-03-16 14:26:36 +00:00
Andreas Schneider
12c843ad0a s3:libads: Check print_canonical_sockaddr_with_port() for NULL in get_kdc_ip_string()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15016

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Andreas Schneider
cca189d093 s3:libads: Remove obsolete free's of kdc_str
This is allocated on the stackframe now!

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Andreas Schneider
652c8ce167 s3:libads: Allocate all memory on the talloc stackframe
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15016

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Andreas Schneider
812032833a s3:libads: Use talloc_asprintf_append() in get_kdc_ip_string()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15016

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Andreas Schneider
7f721dc2ee s3:libads: Improve debug messages for get_kdc_ip_string()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15016

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Andreas Schneider
313f03c784 s3:libads: Leave early on error in get_kdc_ip_string()
This avoids useless allocations.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Andreas Schneider
567b199679 s3:libads: Remove trailing spaces in kerberos.c
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15016

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2022-03-16 13:28:30 +00:00
Samuel Cabrero
00b1f44a7e s3:libads: Return canonical principal and realm from kerberos_return_pac()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14979

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2022-02-23 15:20:32 +00:00
Samuel Cabrero
3dbcd20de9 s3:libads: Fix memory leak in kerberos_return_pac() error path
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2022-02-23 15:20:32 +00:00
Ralph Boehme
3ee690455e s3/libads: ensure a sockaddr variable is correctly zero initialized
is_zero_addr() doesn't work with addresses that have been zero-initialized.

This fixes the logic added in c863cc2ba3.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14674
MR: https://gitlab.com/samba-team/samba/-/merge_requests/2354

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Feb  8 20:24:12 UTC 2022 on sn-devel-184
2022-02-08 20:24:12 +00:00
Ralph Boehme
c266ed40ae s3/libads: simplify storing existing ads->ldap.ss
We just need temporal storage for ads->ldap.ss, no need to store it as a struct
samba_sockaddr.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14674
MR: https://gitlab.com/samba-team/samba/-/merge_requests/2354

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-08 19:27:29 +00:00
Pavel Filipenský
17ea2ccdab s3:libads: Disable NTLMSSP if not allowed (for builds without kerberos)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14955

Pair-Programmed-With: Andreas Schneider <asn@samba.org>

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2022-01-21 23:33:36 +00:00