mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
s3: Replace sid_binstring and sid_guidstring with PIDL-based alternatives
This reduces the manual marshalling of these structures by removing the duplication here. Andrew Bartlett Signed-off-by: Günther Deschner <gd@samba.org>
This commit is contained in:
parent
d44e86b473
commit
d7bc452a89
@ -557,14 +557,14 @@ LIBSAMBA_OBJ = $(LIBSMB_OBJ0) \
|
||||
$(LIBSMB_ERR_OBJ)
|
||||
|
||||
LIBCLI_LDAP_MESSAGE_OBJ = ../libcli/ldap/ldap_message.o
|
||||
LIBCLI_LDAP_NDR_OBJ = ../libcli/ldap/ldap_ndr.o
|
||||
LIBCLI_LDAP_NDR_OBJ = ../libcli/ldap/ldap_ndr.o lib/ldb_compat.o
|
||||
|
||||
LIBTSOCKET_OBJ = ../lib/tsocket/tsocket.o \
|
||||
../lib/tsocket/tsocket_helpers.o \
|
||||
../lib/tsocket/tsocket_bsd.o
|
||||
|
||||
CLDAP_OBJ = libads/cldap.o \
|
||||
../libcli/cldap/cldap.o lib/ldb_compat.o \
|
||||
../libcli/cldap/cldap.o \
|
||||
../lib/util/idtree.o \
|
||||
$(LIBCLI_LDAP_MESSAGE_OBJ) $(LIBCLI_LDAP_NDR_OBJ) $(LIBTSOCKET_OBJ)
|
||||
|
||||
@ -998,6 +998,7 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \
|
||||
PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) \
|
||||
$(LIBSAMBA_OBJ) $(LIBTSOCKET_OBJ) \
|
||||
$(LIB_NONSMBD_OBJ) $(GROUPDB_OBJ) \
|
||||
$(LIBCLI_LDAP_NDR_OBJ) \
|
||||
$(POPT_LIB_OBJ) $(SMBLDAP_OBJ) ../lib/util/asn1.o
|
||||
|
||||
SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ1)
|
||||
@ -1443,6 +1444,7 @@ NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \
|
||||
$(PASSDB_OBJ) $(LIBTSOCKET_OBJ) $(GROUPDB_OBJ) \
|
||||
$(SMBLDAP_OBJ) $(LIBNMB_OBJ) \
|
||||
$(WBCOMMON_OBJ) \
|
||||
$(LIBCLI_LDAP_NDR_OBJ) \
|
||||
$(LIBNDR_GEN_OBJ0) $(LIBNDR_NETLOGON_OBJ) @BUILD_INIPARSER@
|
||||
|
||||
|
||||
@ -3013,9 +3015,9 @@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \
|
||||
$(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
|
||||
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS) @INIPARSERLIBS@
|
||||
|
||||
bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) $(LIBTALLOC) $(LIBWBCLIENT) $(LIBTDB)
|
||||
bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) $(LIBCLI_LDAP_NDR_OBJ) $(LIBTALLOC) $(LIBWBCLIENT) $(LIBTDB)
|
||||
@echo "Linking shared library $@"
|
||||
@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) \
|
||||
@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) $(LIBCLI_LDAP_NDR_OBJ) -lpam $(DYNEXP) \
|
||||
$(LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
|
||||
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS)
|
||||
|
||||
|
@ -1295,7 +1295,6 @@ void sid_copy(struct dom_sid *dst, const struct dom_sid *src);
|
||||
bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
|
||||
bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid);
|
||||
bool non_mappable_sid(struct dom_sid *sid);
|
||||
char *sid_binstring(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
|
||||
char *sid_binstring_hex(const struct dom_sid *sid);
|
||||
NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
|
||||
struct dom_sid **sids, uint32_t *num);
|
||||
@ -1587,7 +1586,6 @@ int islower_ascii(int c);
|
||||
|
||||
void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr);
|
||||
void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu);
|
||||
char *guid_binstring(TALLOC_CTX *mem_ctx, const struct GUID *guid);
|
||||
|
||||
/* The following definitions come from lib/version.c */
|
||||
|
||||
|
@ -333,26 +333,6 @@ bool non_mappable_sid(struct dom_sid *sid)
|
||||
Caller must free.
|
||||
*****************************************************************/
|
||||
|
||||
char *sid_binstring(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
|
||||
{
|
||||
uint8_t *buf;
|
||||
char *s;
|
||||
int len = ndr_size_dom_sid(sid, 0);
|
||||
buf = talloc_array(mem_ctx, uint8_t, len);
|
||||
if (!buf) {
|
||||
return NULL;
|
||||
}
|
||||
sid_linearize((char *)buf, len, sid);
|
||||
s = binary_string_rfc2254(mem_ctx, buf, len);
|
||||
TALLOC_FREE(buf);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Return the binary string representation of a struct dom_sid.
|
||||
Caller must free.
|
||||
*****************************************************************/
|
||||
|
||||
char *sid_binstring_hex(const struct dom_sid *sid)
|
||||
{
|
||||
char *buf, *s;
|
||||
|
@ -38,16 +38,3 @@ void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu)
|
||||
memcpy(uu->node, in.info+10, 6);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Return the binary string representation of a GUID.
|
||||
Caller must free.
|
||||
*****************************************************************/
|
||||
|
||||
char *guid_binstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
|
||||
{
|
||||
UUID_FLAT guid_flat;
|
||||
|
||||
smb_uuid_pack(*guid, &guid_flat);
|
||||
|
||||
return binary_string_rfc2254(mem_ctx, guid_flat.info, UUID_FLAT_SIZE);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "includes.h"
|
||||
#include "ads.h"
|
||||
#include "libads/ldap_schema.h"
|
||||
#include "../libcli/ldap/ldap_ndr.h"
|
||||
|
||||
#ifdef HAVE_LDAP
|
||||
|
||||
@ -124,7 +125,7 @@ const char *ads_get_attrname_by_guid(ADS_STRUCT *ads,
|
||||
goto done;
|
||||
}
|
||||
|
||||
guid_bin = guid_binstring(mem_ctx, schema_guid);
|
||||
guid_bin = ldap_encode_ndr_GUID(mem_ctx, schema_guid);
|
||||
if (!guid_bin) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../libds/common/flags.h"
|
||||
#include "secrets.h"
|
||||
#include "../librpc/gen_ndr/samr.h"
|
||||
#include "../libcli/ldap/ldap_ndr.h"
|
||||
|
||||
struct pdb_ads_state {
|
||||
struct sockaddr_un socket_address;
|
||||
@ -155,7 +156,7 @@ static struct pdb_ads_samu_private *pdb_ads_get_samu_private(
|
||||
result, struct pdb_ads_samu_private);
|
||||
}
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), pdb_get_user_sid(sam));
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), pdb_get_user_sid(sam));
|
||||
if (sidstr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -437,7 +438,7 @@ static NTSTATUS pdb_ads_getsampwsid(struct pdb_methods *m,
|
||||
m->private_data, struct pdb_ads_state);
|
||||
char *sidstr, *filter;
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), sid);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
filter = talloc_asprintf(
|
||||
@ -829,7 +830,7 @@ static NTSTATUS pdb_ads_delete_dom_group(struct pdb_methods *m,
|
||||
|
||||
sid_compose(&sid, &state->domainsid, rid);
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), &sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), &sid);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
rc = pdb_ads_search_fmt(state, state->domaindn, TLDAP_SCOPE_SUB,
|
||||
@ -917,7 +918,7 @@ static NTSTATUS pdb_ads_enum_group_members(struct pdb_methods *m,
|
||||
DATA_BLOB *blobs;
|
||||
uint32_t *members;
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), group);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), group);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
rc = pdb_ads_search_fmt(state, state->domaindn, TLDAP_SCOPE_SUB,
|
||||
@ -1201,7 +1202,7 @@ static NTSTATUS pdb_ads_delete_alias(struct pdb_methods *m,
|
||||
return NT_STATUS_LDAP(TLDAP_SERVER_DOWN);
|
||||
}
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), sid);
|
||||
if (sidstr == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
@ -1260,7 +1261,7 @@ static NTSTATUS pdb_ads_set_aliasinfo(struct pdb_methods *m,
|
||||
return NT_STATUS_LDAP(TLDAP_SERVER_DOWN);
|
||||
}
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), sid);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
rc = pdb_ads_search_fmt(state, state->domaindn, TLDAP_SCOPE_SUB,
|
||||
@ -1327,7 +1328,7 @@ static NTSTATUS pdb_ads_sid2dn(struct pdb_ads_state *state,
|
||||
char *sidstr, *dn;
|
||||
int rc;
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), sid);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
rc = pdb_ads_search_fmt(state, state->domaindn, TLDAP_SCOPE_SUB,
|
||||
@ -1482,7 +1483,7 @@ static NTSTATUS pdb_ads_enum_aliasmem(struct pdb_methods *m,
|
||||
DATA_BLOB *blobs;
|
||||
struct dom_sid *members;
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), alias);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), alias);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
rc = pdb_ads_search_fmt(state, state->domaindn, TLDAP_SCOPE_SUB,
|
||||
@ -1651,7 +1652,7 @@ static NTSTATUS pdb_ads_lookup_rids(struct pdb_methods *m,
|
||||
|
||||
sid_compose(&sid, domain_sid, rids[i]);
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), &sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), &sid);
|
||||
NT_STATUS_HAVE_NO_MEMORY(sidstr);
|
||||
|
||||
rc = pdb_ads_search_fmt(state, state->domaindn,
|
||||
@ -1954,7 +1955,7 @@ static bool pdb_ads_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
|
||||
|
||||
sid_peek_rid(sid, &rid);
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), sid);
|
||||
if (sidstr == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "secrets.h"
|
||||
#include "idmap.h"
|
||||
#include "../libcli/security/dom_sid.h"
|
||||
#include "../libcli/ldap/ldap_ndr.h"
|
||||
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_IDMAP
|
||||
@ -563,7 +564,7 @@ again:
|
||||
|
||||
ids[idx]->status = ID_UNKNOWN;
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), ids[idx]->sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), ids[idx]->sid);
|
||||
filter = talloc_asprintf_append_buffer(filter, "(objectSid=%s)", sidstr);
|
||||
|
||||
TALLOC_FREE(sidstr);
|
||||
@ -885,7 +886,7 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e,
|
||||
attrs[2] = ctx->ad_schema->posix_gecos_attr;
|
||||
attrs[3] = ctx->ad_schema->posix_gidnumber_attr;
|
||||
|
||||
sidstr = sid_binstring(mem_ctx, sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(mem_ctx, sid);
|
||||
filter = talloc_asprintf(mem_ctx, "(objectSid=%s)", sidstr);
|
||||
TALLOC_FREE(sidstr);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "idmap.h"
|
||||
#include "idmap_adex.h"
|
||||
#include "libads/cldap.h"
|
||||
#include "../libcli/ldap/ldap_ndr.h"
|
||||
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_IDMAP
|
||||
@ -719,7 +720,7 @@ done:
|
||||
|
||||
*name = NULL;
|
||||
|
||||
sid_string = sid_binstring(frame, sid);
|
||||
sid_string = ldap_encode_ndr_dom_sid(frame, sid);
|
||||
BAIL_ON_PTR_ERROR(sid_string, nt_status);
|
||||
|
||||
filter = talloc_asprintf(frame, "(objectSid=%s)", sid_string);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ads.h"
|
||||
#include "idmap.h"
|
||||
#include "idmap_adex.h"
|
||||
#include "../libcli/ldap/ldap_ndr.h"
|
||||
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_IDMAP
|
||||
@ -485,7 +486,7 @@ static NTSTATUS search_forest(struct likewise_cell *forest_cell,
|
||||
|
||||
switch (fdata->ftype) {
|
||||
case SidFilter:
|
||||
sid_binstr = sid_binstring(frame, &fdata->filter.sid);
|
||||
sid_binstr = ldap_encode_ndr_dom_sid(frame, &fdata->filter.sid);
|
||||
BAIL_ON_PTR_ERROR(sid_binstr, nt_status);
|
||||
|
||||
filter = talloc_asprintf(frame, "(objectSid=%s)", sid_binstr);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../libds/common/flags.h"
|
||||
#include "ads.h"
|
||||
#include "secrets.h"
|
||||
#include "../libcli/ldap/ldap_ndr.h"
|
||||
|
||||
#ifdef HAVE_ADS
|
||||
|
||||
@ -542,7 +543,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
|
||||
return NT_STATUS_SERVER_DISABLED;
|
||||
}
|
||||
|
||||
sidstr = sid_binstring(talloc_tos(), sid);
|
||||
sidstr = ldap_encode_ndr_dom_sid(talloc_tos(), sid);
|
||||
|
||||
ret = asprintf(&ldap_exp, "(objectSid=%s)", sidstr);
|
||||
TALLOC_FREE(sidstr);
|
||||
@ -1044,7 +1045,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((sidbinstr = sid_binstring(talloc_tos(), group_sid)) == NULL) {
|
||||
if ((sidbinstr = ldap_encode_ndr_dom_sid(talloc_tos(), group_sid)) == NULL) {
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
@ -321,10 +321,10 @@ LIBSMB_SRC0 = '''
|
||||
LIBSAMBA_SRC = '${LIBSMB_SRC0}'
|
||||
|
||||
LIBCLI_LDAP_MESSAGE_SRC = '''../libcli/ldap/ldap_message.c'''
|
||||
LIBCLI_LDAP_NDR_SRC = '''../libcli/ldap/ldap_ndr.c'''
|
||||
LIBCLI_LDAP_NDR_SRC = '''../libcli/ldap/ldap_ndr.c lib/ldb_compat.c'''
|
||||
|
||||
CLDAP_SRC = '''libads/cldap.c
|
||||
../libcli/cldap/cldap.c lib/ldb_compat.c
|
||||
../libcli/cldap/cldap.c
|
||||
../lib/util/idtree.c
|
||||
${LIBCLI_LDAP_MESSAGE_SRC} ${LIBCLI_LDAP_NDR_SRC}'''
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user