1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

libads: Move check_cldap_reply_required_flags() to netlogon_ping.c

netlogon_ping.c depends on it but itself has fewer dependencies than
cldap.c, so we can use it in more places

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Volker Lendecke 2024-10-28 15:01:57 +01:00
parent fc7c55c938
commit eb8767a076
4 changed files with 55 additions and 56 deletions

View File

@ -28,59 +28,6 @@
#include "libads/cldap.h"
#include "libads/netlogon_ping.h"
/****************************************************************
****************************************************************/
#define RETURN_ON_FALSE(x) if (!(x)) return false;
bool check_cldap_reply_required_flags(uint32_t ret_flags,
uint32_t req_flags)
{
if (req_flags == 0) {
return true;
}
if (req_flags & DS_PDC_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_PDC);
if (req_flags & DS_GC_SERVER_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_GC);
if (req_flags & DS_ONLY_LDAP_NEEDED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_LDAP);
if ((req_flags & DS_DIRECTORY_SERVICE_REQUIRED) ||
(req_flags & DS_DIRECTORY_SERVICE_PREFERRED))
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS);
if (req_flags & DS_KDC_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_KDC);
if (req_flags & DS_TIMESERV_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_TIMESERV);
if (req_flags & DS_WEB_SERVICE_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_ADS_WEB_SERVICE);
if (req_flags & DS_WRITABLE_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_WRITABLE);
if (req_flags & DS_DIRECTORY_SERVICE_6_REQUIRED)
RETURN_ON_FALSE(ret_flags & (NBT_SERVER_SELECT_SECRET_DOMAIN_6
|NBT_SERVER_FULL_SECRET_DOMAIN_6));
if (req_flags & DS_DIRECTORY_SERVICE_8_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS_8);
if (req_flags & DS_DIRECTORY_SERVICE_9_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS_9);
if (req_flags & DS_DIRECTORY_SERVICE_10_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS_10);
return true;
}
/*******************************************************************
do a cldap netlogon query. Always 389/udp
*******************************************************************/

View File

@ -27,9 +27,6 @@
/* The following definitions come from libads/cldap.c */
bool check_cldap_reply_required_flags(uint32_t ret_flags,
uint32_t req_flags);
bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
struct sockaddr_storage *ss,
const char *realm,

View File

@ -29,6 +29,59 @@
#include "lib/util/tevent_ntstatus.h"
#include "source4/lib/tls/tls.h"
#include "source3/libads/cldap.h"
#include "librpc/gen_ndr/netlogon.h"
#define RETURN_ON_FALSE(x) \
if (!(x)) \
return false;
bool check_cldap_reply_required_flags(uint32_t ret_flags, uint32_t req_flags)
{
if (req_flags == 0) {
return true;
}
if (req_flags & DS_PDC_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_PDC);
if (req_flags & DS_GC_SERVER_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_GC);
if (req_flags & DS_ONLY_LDAP_NEEDED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_LDAP);
if ((req_flags & DS_DIRECTORY_SERVICE_REQUIRED) ||
(req_flags & DS_DIRECTORY_SERVICE_PREFERRED))
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS);
if (req_flags & DS_KDC_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_KDC);
if (req_flags & DS_TIMESERV_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_TIMESERV);
if (req_flags & DS_WEB_SERVICE_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_ADS_WEB_SERVICE);
if (req_flags & DS_WRITABLE_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_WRITABLE);
if (req_flags & DS_DIRECTORY_SERVICE_6_REQUIRED)
RETURN_ON_FALSE(ret_flags &
(NBT_SERVER_SELECT_SECRET_DOMAIN_6 |
NBT_SERVER_FULL_SECRET_DOMAIN_6));
if (req_flags & DS_DIRECTORY_SERVICE_8_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS_8);
if (req_flags & DS_DIRECTORY_SERVICE_9_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS_9);
if (req_flags & DS_DIRECTORY_SERVICE_10_REQUIRED)
RETURN_ON_FALSE(ret_flags & NBT_SERVER_DS_10);
return true;
}
struct ldap_netlogon_state {
struct tevent_context *ev;

View File

@ -24,6 +24,8 @@
#include "libcli/util/ntstatus.h"
#include "lib/param/loadparm.h"
bool check_cldap_reply_required_flags(uint32_t ret_flags, uint32_t req_flags);
struct netlogon_samlogon_response;
struct netlogon_ping_filter {