diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-09-17 12:33:44 +1000 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-09-20 16:15:03 -0700 |
commit | d7bc452a893a77eb21b547cd8cdf8b420c60ab5d (patch) | |
tree | 32803f84567980382f85b0164e9e9f10a99c1bbd | |
parent | d44e86b473554ad549993c928af68e348ccefe2b (diff) | |
download | samba-d7bc452a893a77eb21b547cd8cdf8b420c60ab5d.tar.gz samba-d7bc452a893a77eb21b547cd8cdf8b420c60ab5d.tar.bz2 samba-d7bc452a893a77eb21b547cd8cdf8b420c60ab5d.zip |
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>
-rw-r--r-- | source3/Makefile.in | 10 | ||||
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/lib/util_sid.c | 20 | ||||
-rw-r--r-- | source3/lib/util_uuid.c | 13 | ||||
-rw-r--r-- | source3/libads/ldap_schema.c | 3 | ||||
-rw-r--r-- | source3/passdb/pdb_ads.c | 21 | ||||
-rw-r--r-- | source3/winbindd/idmap_ad.c | 5 | ||||
-rw-r--r-- | source3/winbindd/idmap_adex/gc_util.c | 3 | ||||
-rw-r--r-- | source3/winbindd/idmap_adex/provider_unified.c | 3 | ||||
-rw-r--r-- | source3/winbindd/winbindd_ads.c | 5 | ||||
-rw-r--r-- | source3/wscript_build | 4 |
11 files changed, 31 insertions, 58 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index ce8c865cb3..20a67969e0 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -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) diff --git a/source3/include/proto.h b/source3/include/proto.h index 5bb91c53eb..e715b579f6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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 */ diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index d75c8e2c97..d28333f9da 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.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; diff --git a/source3/lib/util_uuid.c b/source3/lib/util_uuid.c index 656ba2a57c..225ac72c6c 100644 --- a/source3/lib/util_uuid.c +++ b/source3/lib/util_uuid.c @@ -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); -} diff --git a/source3/libads/ldap_schema.c b/source3/libads/ldap_schema.c index 80ec45c73c..66c9bf4b57 100644 --- a/source3/libads/ldap_schema.c +++ b/source3/libads/ldap_schema.c @@ -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; } diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c index 9eb5b6067e..fb2a5e3c9d 100644 --- a/source3/passdb/pdb_ads.c +++ b/source3/passdb/pdb_ads.c @@ -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; } diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c index f2e47a7042..9f2f260951 100644 --- a/source3/winbindd/idmap_ad.c +++ b/source3/winbindd/idmap_ad.c @@ -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); diff --git a/source3/winbindd/idmap_adex/gc_util.c b/source3/winbindd/idmap_adex/gc_util.c index 56bd9542f6..77b318cb2d 100644 --- a/source3/winbindd/idmap_adex/gc_util.c +++ b/source3/winbindd/idmap_adex/gc_util.c @@ -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); diff --git a/source3/winbindd/idmap_adex/provider_unified.c b/source3/winbindd/idmap_adex/provider_unified.c index 191f77159c..9f5cc884a5 100644 --- a/source3/winbindd/idmap_adex/provider_unified.c +++ b/source3/winbindd/idmap_adex/provider_unified.c @@ -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); diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c index 367d38ba15..fa498d63df 100644 --- a/source3/winbindd/winbindd_ads.c +++ b/source3/winbindd/winbindd_ads.c @@ -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; } diff --git a/source3/wscript_build b/source3/wscript_build index e5ad33bab4..6c37348495 100644 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -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}''' |