RPC handles cannot be differentiated in source3 RPC server

Jeremy Allison jra at samba.org
Tue Apr 28 18:14:41 UTC 2020


On Tue, Apr 28, 2020 at 05:31:31PM +0300, Alexander Bokovoy wrote:
> I started looking where this 'first bit must be null' comes from and
> after few refactorings I got down to the commit Jeremy did in 1998 while
> merging NTDOM branch server code:
> 
> commit fdeea341ed1bae670382e45eb731db1b5838ad21
> Author: Jeremy Allison <jra at samba.org>
> Date:   Wed Mar 11 21:11:04 1998 +0000
> 
>     "For I have laboured mightily on Luke's code, and hath broken
>     all I saw" - the book of Jeremy, chapter 1 :-).
> 
>     So here is the mega-merge of the NTDOM branch server code.
>     It doesn't include the new client side pieces, we'll look
>     at that later.
> 
>     ....
> 
> In source4 DCE RPC server code we have dcesrv_handle_create() which
> allows to pass the handle type explicitly. Indeed, there
> dcesrv_lsa_OpenTrustedDomain_common() does explictly call
> dcesrv_handle_create() with the correct handle type:
> 
>         handle = dcesrv_handle_create(dce_call, LSA_HANDLE_TRUSTED_DOMAIN);
> 
> 
> The fix would be pretty obvious: update create_policy_hnd() and its
> internal implementation to pass-through the handle type. This should not
> affect many places:
> 
> $ git grep create_policy_hnd
> source3/rpc_server/epmapper/srv_epmapper.c:             ok = create_policy_hnd(p, r->out.entry_handle, eps);
> source3/rpc_server/epmapper/srv_epmapper.c:             ok = create_policy_hnd(p, r->out.entry_handle, eps);
> source3/rpc_server/eventlog/srv_eventlog_nt.c:  if ( !create_policy_hnd( p, hnd, elog ) ) {
> source3/rpc_server/lsa/srv_lsa_nt.c:    if (!create_policy_hnd(p, handle, info)) {
> source3/rpc_server/mdssvc/srv_mdssvc_nt.c:      if (!create_policy_hnd(p, handle, mds_ctx)) {
> source3/rpc_server/rpc_handles.c:  If "data_ptr" is given, this must be a talloc'ed object, create_policy_hnd
> source3/rpc_server/rpc_handles.c:               DEBUG(0,("create_policy_hnd: ERROR: too many handles (%d) on this pipe.\n",
> source3/rpc_server/rpc_handles.c:               DEBUG(0,("create_policy_hnd: ERROR: out of memory!\n"));
> source3/rpc_server/rpc_handles.c:bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd,
> source3/rpc_server/rpc_pipes.h:bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
> source3/rpc_server/spoolss/srv_spoolss_nt.c:    if (!create_policy_hnd(p, hnd, new_printer)) {
> source3/rpc_server/svcctl/srv_svcctl_nt.c:      if ( !create_policy_hnd( p, handle, info ) ) {
> source3/rpc_server/winreg/srv_winreg_nt.c:      if ( !create_policy_hnd( p, hnd, key ) ) {
> source3/rpc_server/winreg/srv_winreg_nt.c:      if (!create_policy_hnd(p, r->out.new_handle, new_key)) {
> 
> Anyone has anything against this change?

Thanks a *LOT* for the deep dive Alexander. Much appreciated
cleaning up my old mistakes (of which I'm sure there are many
more to find :-).

Put in an MR and I'll review !

Jeremy.



More information about the samba-technical mailing list