[PATCH] ndr: use resized array for ndr tokens

Alexander Bokovoy ab at samba.org
Sun Feb 26 07:26:29 UTC 2017


On la, 25 helmi 2017, Andrew Bartlett wrote:
> On Sat, 2017-02-25 at 15:49 +1300, Douglas Bagnall wrote:
> > I wrote:
> > > OK, I see what you and Volker mean about talloc_array_length().
> > > 
> > > On 24/02/17 21:09, Stefan Metzmacher wrote:
> > > > Hi Douglas,
> > > > 
> > > > I think if we want, we can keep that ABI.
> > > > 
> > > > We could change
> > > > 
> > > > struct ndr_token_list {
> > > > 	struct ndr_token_list *prev, *next;
> > > > };
> > > > 
> > > > into
> > > > 
> > > > struct ndr_token_list {
> > > > 	struct ndr_token_list *array, *next_free;
> > > > };
> > > > 
> > > > The 'count' can calculated as
> > > > 
> > > > if (list->next_free != NULL) {
> > > > 	count = some pointer diff magic
> > > > } else {
> > > > 	count = talloc_array_length()
> > > > }
> > > 
> > > Yes, though there would be some slightly horrible casting involved.
> > 
> > Like this. It's (arguably) not too bad. No pointer diff magic is
> > needed because there is an unused uint32_t hanging around.
> 
> I really don't think that we should worry about changing the ABI here,
> but certainly we should declare it.
> 
> If you want to try not to break the ABI we certainly shouldn't cast it
> - just change the pointer type to struct ndr_token *, the structure
> size stays the same.  No API user has any business poking into the NDR
> tokens.
> 
> I'll note that the only user of libndr that I know of was openchange,
> which is dead (openchange.org still down), and that always required a
> rebuild for each Samba version anyway.  
> 
> Additionally please also note that I added a value to ndr_push for
> Samba 4.5 and forgot to bump the ABI, and while nobody has complained
> for that reason we 'owe' a major version bump anyway.
FreeIPA uses krb5pac and nbt but we can rebuild without any problem.

$ git grep 'ndr_\(push\|pull\|pack\)'
daemons/ipa-kdb/ipa_kdb_mspac.c:    ndr_err = ndr_push_union_blob(&pac_data, tmpctx, &pac_info,
daemons/ipa-kdb/ipa_kdb_mspac.c: (ndr_push_flags_fn_t)ndr_push_PAC_INFO);
daemons/ipa-kdb/ipa_kdb_mspac.c:    ndr_err = ndr_pull_union_blob(&pac_data, memctx, info,
daemons/ipa-kdb/ipa_kdb_mspac.c: (ndr_pull_flags_fn_t)ndr_pull_PAC_INFO);
daemons/ipa-kdb/ipa_kdb_mspac.c:    ndr_err = ndr_push_union_blob(&pac_data, memctx, info,
daemons/ipa-kdb/ipa_kdb_mspac.c: (ndr_push_flags_fn_t)ndr_push_PAC_INFO);
daemons/ipa-kdb/ipa_kdb_mspac.c:    ndr_err = ndr_pull_union_blob(&pac_data, memctx, info,
daemons/ipa-kdb/ipa_kdb_mspac.c: (ndr_pull_flags_fn_t)ndr_pull_PAC_INFO);
daemons/ipa-kdb/ipa_kdb_mspac.c:    ndr_err = ndr_push_union_blob(&pac_data, memctx, info,
daemons/ipa-kdb/ipa_kdb_mspac.c: (ndr_push_flags_fn_t)ndr_push_PAC_INFO);
daemons/ipa-sam/ipa_sam.c:enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r); /*available in libndr-samba.so */ 
daemons/ipa-sam/ipa_sam.c:      ndr_err = ndr_pull_struct_blob(auth_blob, tmp_ctx, &iopw,
daemons/ipa-sam/ipa_sam.c: (ndr_pull_flags_fn_t)ndr_pull_trustAuthInOutBlob);
daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c: (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags
daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c:    /* nlr->sockaddr_size (filled in by ndr_push) */
daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c:    ndr_err = ndr_push_struct_blob(&blob, nlr, nlr,
ipaserver/dcerpc.py:from samba.ndr import ndr_pack, ndr_print 
ipaserver/dcerpc.py:            security.dom_sid(sid).__ndr_pack__(),
ipaserver/dcerpc.py:        trustpass_blob = ndr_pack(trustpass)

-- 
/ Alexander Bokovoy



More information about the samba-technical mailing list