r18566: fixed the winreg pipe and winreg tests
authorAndrew Tridgell <tridge@samba.org>
Fri, 15 Sep 2006 20:36:38 +0000 (20:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:18:47 +0000 (14:18 -0500)
Jerry, there is a big difference on the wire between these two:

  [out] uint32 x;
and
  [out] uint32 *x;

if you change from

  [out] uint32 x;

then you need to change to:

  [out,ref] uint32 *x;

otherwise it changes the format on the wire, which means we are no
longer compatible with MS servers.

but be aware that even if you change to a ref ptr, you also need to
change all the client code to set all the return variables in the out
part of the structure. That's why I don't like the MIDL restriction of
forcing the use of ref pointers for output variables - it makes life
much harder when writing client code, and makes the code much more
error prone (just look at all the extra code needed to make this work
again).

I know we could auto-allocate these variables in the generated client
side NDR code, but if we did that then we would have no way of doing a
_real_ ref out pointer, which we really wanted to set to some already
allocated variable.

So please hold off on changing our idl to use the MIDL convention for
output variables until Jelmer and I have had a good "chat" about this :-)
(This used to be commit 555aed43ba3c08360ca7fa921622b80732a7f657)

source4/librpc/idl/winreg.idl
source4/rpc_server/winreg/rpc_winreg.c
source4/torture/rpc/winreg.c

index cbe60a96bab0522e8d4ba35451b208814dcda869..04521304e79d210455866ec4ceed9b19e706130d 100644 (file)
                [in,ref] policy_handle *handle,
                [in] winreg_String class_in,
                [out] winreg_String *class_out,
-               [out] uint32 *num_subkeys,
-               [out] uint32 *max_subkeylen,
-               [out] uint32 *max_subkeysize,
-               [out] uint32 *num_values,
-               [out] uint32 *max_valnamelen,
-               [out] uint32 *max_valbufsize,
-               [out] uint32 *secdescsize,
-               [out] NTTIME *last_changed_time
+               [out,ref] uint32 *num_subkeys,
+               [out,ref] uint32 *max_subkeylen,
+               [out,ref] uint32 *max_subkeysize,
+               [out,ref] uint32 *num_values,
+               [out,ref] uint32 *max_valnamelen,
+               [out,ref] uint32 *max_valbufsize,
+               [out,ref] uint32 *secdescsize,
+               [out,ref] NTTIME *last_changed_time
        );
 
        /******************/
        /******************/
        /* Function: 0x1a */
        WERROR winreg_GetVersion(
-               [in,ref] policy_handle *handle,
-               [out]    uint32 *version
+               [in,ref]     policy_handle *handle,
+               [out,ref]    uint32 *version
        );
 
        /******************/
index 86a78a5e9e61a7000963b6befa1ed1269e354423..adcbb749dac1a4691dfee8f24f0078454b1158a9 100644 (file)
@@ -523,7 +523,11 @@ static WERROR winreg_GetVersion(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 
        DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
 
+       r->out.version = talloc(mem_ctx, uint32_t);
+       NT_STATUS_HAVE_NO_MEMORY(r->out.version);
+
        *r->out.version = 5;
+
        return WERR_OK;
 }
 
index 025411f3bd020308bd46b1deab5622e0601484ac..370a023dd533c6624e2b6695cd2777b513813874 100644 (file)
@@ -54,10 +54,12 @@ static BOOL test_GetVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 {
        NTSTATUS status;
        struct winreg_GetVersion r;
-
+       uint32_t v;
        printf("\ntesting GetVersion\n");
 
+       ZERO_STRUCT(r);
        r.in.handle = handle;
+       r.out.version = &v;
 
        status = dcerpc_winreg_GetVersion(p, mem_ctx, &r);
 
@@ -372,10 +374,24 @@ static BOOL test_QueryInfoKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 {
        NTSTATUS status;
        struct winreg_QueryInfoKey r;
+       uint32_t num_subkeys, max_subkeylen, max_subkeysize,
+               num_values, max_valnamelen, max_valbufsize,
+               secdescsize;
+       NTTIME last_changed_time;
 
        printf("\ntesting QueryInfoKey\n");
 
+       ZERO_STRUCT(r);
        r.in.handle = handle;
+       r.out.num_subkeys = &num_subkeys;
+       r.out.max_subkeylen = &max_subkeylen;
+       r.out.max_subkeysize = &max_subkeysize;
+       r.out.num_values = &num_values;
+       r.out.max_valnamelen = &max_valnamelen;
+       r.out.max_valbufsize = &max_valbufsize;
+       r.out.secdescsize = &secdescsize;
+       r.out.last_changed_time = &last_changed_time;
+       
        init_winreg_String(&r.in.class_in, class);
        
        status = dcerpc_winreg_QueryInfoKey(p, mem_ctx, &r);