it turns out that all MS servers ignore the artifact struct_len fields
authorAndrew Tridgell <tridge@samba.org>
Fri, 14 Nov 2003 21:39:13 +0000 (21:39 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 14 Nov 2003 21:39:13 +0000 (21:39 +0000)
in OpenPolicy and OpenPolicy2, so we don't in fact need the
[struct_len] attribute. This makes our IDL much closer to the MS IDL.
(This used to be commit f0a8f063a680b5d0a68c5ac7cccf9c9a13adfb81)

source4/build/pidl/parser.pm
source4/librpc/idl/dfs.idl
source4/librpc/idl/lsa.idl
source4/librpc/ndr/ndr_dfs.c
source4/librpc/ndr/ndr_dfs.h
source4/librpc/ndr/ndr_lsa.c
source4/librpc/ndr/ndr_lsa.h
source4/librpc/rpc/rpc_dfs.c
source4/torture/rpc/lsa.c

index 7d9885312299369553d75a500a70aab42c927963..71c64cb5f7c1783f31741e15984853eddbafcf41 100644 (file)
@@ -189,10 +189,6 @@ sub ParseElementPrintScalar($$)
        my($var_prefix) = shift;
        my $cprefix = util::c_push_prefix($e);
 
-       if (util::has_property($e, "struct_len")) {
-               return;
-       }
-
        if (defined $e->{VALUE}) {
                $res .= "\tndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $e->{VALUE});\n";
        } elsif (util::has_direct_buffers($e)) {
@@ -393,27 +389,12 @@ sub ParseElementPullBuffer($$$)
 sub ParseStructPush($)
 {
        my($struct) = shift;
-       my($struct_len);
        my $conform_e;
 
        if (! defined $struct->{ELEMENTS}) {
                return;
        }
 
-       # see if we have a structure length
-       foreach my $e (@{$struct->{ELEMENTS}}) {
-               $e->{PARENT} = $struct;
-               if (util::has_property($e, "struct_len")) {
-                       $struct_len = $e;
-                       $e->{VALUE} = "0";
-               }
-       }       
-
-       if (defined $struct_len) {
-               $res .= "\tstruct ndr_push_save _save1, _save2, _save3;\n";
-               $res .= "\tndr_push_save(ndr, &_save1);\n";
-       }
-
        # see if the structure contains a conformant array. If it
        # does, then it must be the last element of the structure, and
        # we need to push the conformant length early, as it fits on
@@ -433,10 +414,7 @@ sub ParseStructPush($)
        $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n";
 
        foreach my $e (@{$struct->{ELEMENTS}}) {
-               if (defined($struct_len) && $e == $struct_len) {
-                       $res .= "\tNDR_CHECK(ndr_push_align(ndr, sizeof($e->{TYPE})));\n";
-                       $res .= "\tndr_push_save(ndr, &_save2);\n";
-               }
+               $e->{PARENT} = $struct;
                ParseElementPushScalar($e, "r->", "NDR_SCALARS");
        }       
 
@@ -446,14 +424,6 @@ sub ParseStructPush($)
                ParseElementPushBuffer($e, "r->", "NDR_BUFFERS");
        }
 
-       if (defined $struct_len) {
-               $res .= "\tndr_push_save(ndr, &_save3);\n";
-               $res .= "\tndr_push_restore(ndr, &_save2);\n";
-               $struct_len->{VALUE} = "_save3.offset - _save1.offset";
-               ParseElementPushScalar($struct_len, "r->", "NDR_SCALARS");
-               $res .= "\tndr_push_restore(ndr, &_save3);\n";
-       }
-
        $res .= "done:\n";
 }
 
@@ -479,7 +449,6 @@ sub ParseStructPrint($)
 sub ParseStructPull($)
 {
        my($struct) = shift;
-       my($struct_len);
        my $conform_e;
 
        if (! defined $struct->{ELEMENTS}) {
@@ -507,24 +476,6 @@ sub ParseStructPull($)
        }
 
 
-       # see if we have a structure length. If we do then we need to advance
-       # the ndr_pull offset to that length past the front of the structure
-       # when we have finished with the structure
-       # we also need to make sure that we limit the size of our parsing
-       # of this structure to the given size
-       foreach my $e (@{$struct->{ELEMENTS}}) {
-               if (util::has_property($e, "struct_len")) {
-                       $struct_len = $e;
-                       $e->{VALUE} = "&_size";
-               }
-       }       
-
-       if (defined $struct_len) {
-               $res .= "\tuint32 _size;\n";
-               $res .= "\tstruct ndr_pull_save _save;\n";
-               $res .= "\tndr_pull_save(ndr, &_save);\n";
-       }
-
        if (defined $conform_e) {
                $res .= "\tNDR_CHECK(ndr_pull_uint32(ndr, &$conform_e->{CONFORMANT_SIZE}));\n";
        }
@@ -535,9 +486,6 @@ sub ParseStructPull($)
        $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n";
        foreach my $e (@{$struct->{ELEMENTS}}) {
                ParseElementPullScalar($e, "r->", "NDR_SCALARS");
-               if (defined($struct_len) && $e == $struct_len) {
-                       $res .= "\tNDR_CHECK(ndr_pull_limit_size(ndr, _size, 4));\n";
-               }
        }       
 
        $res .= "buffers:\n";
@@ -546,11 +494,6 @@ sub ParseStructPull($)
                ParseElementPullBuffer($e, "r->", "NDR_BUFFERS");
        }
 
-       if (defined $struct_len) {
-               $res .= "\tndr_pull_restore(ndr, &_save);\n";
-               $res .= "\tNDR_CHECK(ndr_pull_advance(ndr, _size));\n";
-       }
-
        $res .= "done:\n";
 }
 
index 107a7d7a53146818b369b6d9e2fa32d47895ae47..1fb16b60ca80e887a688602f5398671f157f7487 100644 (file)
@@ -34,7 +34,7 @@
 
        /******************/
        /* Function: 0x03 */
-       NTSTATUS dfs_UNKNOWN3 ();
+       NTSTATUS dfs_SetInfo ();
 
        /******************/
        /* Function: 0x04 */
index e86ff5f4d3077fe71d04b3e8c5cb4b6826f49c6c..9e703d6c26ac08407c0f095676402723f5990f1c 100644 (file)
        /******************/
        /* Function: 0x06 */
        typedef struct {
-               [struct_len] uint32 _len;
+               uint32  len; /* ignored */
                uint16  impersonation_level;
                uint8   context_mode;
                uint8   effective_only;
        } lsa_QosInfo;
        
        typedef struct {
-               [struct_len] uint32 _len;
+               uint32 len; /* ignored */
                uint8 *root_dir;
                unistr *object_name;
                uint32 attributes;
index 60a125272063346da4ee67c3bc30475562e5d5b8..325e88adad9934eb0c912194d44eba2da719ae8e 100644 (file)
@@ -40,7 +40,7 @@ NTSTATUS ndr_push_dfs_Remove(struct ndr_push *ndr, struct dfs_Remove *r)
        return NT_STATUS_OK;
 }
 
-NTSTATUS ndr_push_dfs_UNKNOWN3(struct ndr_push *ndr, struct dfs_UNKNOWN3 *r)
+NTSTATUS ndr_push_dfs_SetInfo(struct ndr_push *ndr, struct dfs_SetInfo *r)
 {
 
        return NT_STATUS_OK;
@@ -425,7 +425,7 @@ NTSTATUS ndr_pull_dfs_Remove(struct ndr_pull *ndr, struct dfs_Remove *r)
        return NT_STATUS_OK;
 }
 
-NTSTATUS ndr_pull_dfs_UNKNOWN3(struct ndr_pull *ndr, struct dfs_UNKNOWN3 *r)
+NTSTATUS ndr_pull_dfs_SetInfo(struct ndr_pull *ndr, struct dfs_SetInfo *r)
 {
        NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result));
 
index c36477cd207365fef2f915314f0880e6cd3335cf..af46b3dabf835b0885fed288a805d58014844b9c 100644 (file)
@@ -38,7 +38,7 @@ struct dfs_Remove {
 
 };
 
-struct dfs_UNKNOWN3 {
+struct dfs_SetInfo {
        struct {
        } in;
 
@@ -195,6 +195,6 @@ struct dfs_Enum {
 #define DCERPC_DFS_EXIST 0
 #define DCERPC_DFS_ADD 1
 #define DCERPC_DFS_REMOVE 2
-#define DCERPC_DFS_UNKNOWN3 3
+#define DCERPC_DFS_SETINFO 3
 #define DCERPC_DFS_GETINFO 4
 #define DCERPC_DFS_ENUM 5
index 713e87cbbc7274c06f39056928e2cb9ac96cba7d..a480e9ca6247c70ed4e7eff0279e0b5f294e8109 100644 (file)
@@ -61,35 +61,23 @@ NTSTATUS ndr_push_lsa_ChangePassword(struct ndr_push *ndr, struct lsa_ChangePass
 
 static NTSTATUS ndr_push_lsa_QosInfo(struct ndr_push *ndr, int ndr_flags, struct lsa_QosInfo *r)
 {
-       struct ndr_push_save _save1, _save2, _save3;
-       ndr_push_save(ndr, &_save1);
        NDR_CHECK(ndr_push_align(ndr, 4));
        if (!(ndr_flags & NDR_SCALARS)) goto buffers;
-       NDR_CHECK(ndr_push_align(ndr, sizeof(uint32)));
-       ndr_push_save(ndr, &_save2);
-       NDR_CHECK(ndr_push_uint32(ndr, 0));
+       NDR_CHECK(ndr_push_uint32(ndr, r->len));
        NDR_CHECK(ndr_push_uint16(ndr, r->impersonation_level));
        NDR_CHECK(ndr_push_uint8(ndr, r->context_mode));
        NDR_CHECK(ndr_push_uint8(ndr, r->effective_only));
 buffers:
        if (!(ndr_flags & NDR_BUFFERS)) goto done;
-       ndr_push_save(ndr, &_save3);
-       ndr_push_restore(ndr, &_save2);
-       NDR_CHECK(ndr_push_uint32(ndr, _save3.offset - _save1.offset));
-       ndr_push_restore(ndr, &_save3);
 done:
        return NT_STATUS_OK;
 }
 
 static NTSTATUS ndr_push_lsa_ObjectAttribute(struct ndr_push *ndr, int ndr_flags, struct lsa_ObjectAttribute *r)
 {
-       struct ndr_push_save _save1, _save2, _save3;
-       ndr_push_save(ndr, &_save1);
        NDR_CHECK(ndr_push_align(ndr, 4));
        if (!(ndr_flags & NDR_SCALARS)) goto buffers;
-       NDR_CHECK(ndr_push_align(ndr, sizeof(uint32)));
-       ndr_push_save(ndr, &_save2);
-       NDR_CHECK(ndr_push_uint32(ndr, 0));
+       NDR_CHECK(ndr_push_uint32(ndr, r->len));
        NDR_CHECK(ndr_push_ptr(ndr, r->root_dir));
        NDR_CHECK(ndr_push_ptr(ndr, r->object_name));
        NDR_CHECK(ndr_push_uint32(ndr, r->attributes));
@@ -109,10 +97,6 @@ buffers:
        if (r->sec_qos) {
                NDR_CHECK(ndr_push_lsa_QosInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->sec_qos));
        }
-       ndr_push_save(ndr, &_save3);
-       ndr_push_restore(ndr, &_save2);
-       NDR_CHECK(ndr_push_uint32(ndr, _save3.offset - _save1.offset));
-       ndr_push_restore(ndr, &_save3);
 done:
        return NT_STATUS_OK;
 }
@@ -1630,6 +1614,7 @@ void ndr_print_lsa_QosInfo(struct ndr_print *ndr, const char *name, struct lsa_Q
 {
        ndr_print_struct(ndr, name, "lsa_QosInfo");
        ndr->depth++;
+       ndr_print_uint32(ndr, "len", r->len);
        ndr_print_uint16(ndr, "impersonation_level", r->impersonation_level);
        ndr_print_uint8(ndr, "context_mode", r->context_mode);
        ndr_print_uint8(ndr, "effective_only", r->effective_only);
@@ -1640,6 +1625,7 @@ void ndr_print_lsa_ObjectAttribute(struct ndr_print *ndr, const char *name, stru
 {
        ndr_print_struct(ndr, name, "lsa_ObjectAttribute");
        ndr->depth++;
+       ndr_print_uint32(ndr, "len", r->len);
        ndr_print_ptr(ndr, "root_dir", r->root_dir);
        ndr->depth++;
        if (r->root_dir) {
index 306afd5a2c4115c8ccfbbf00032bc0ecc317cfd5..109e88c84f136b655aaa76ac2987cac01e4b4b01 100644 (file)
@@ -86,12 +86,14 @@ struct lsa_ChangePassword {
 };
 
 struct lsa_QosInfo {
+       uint32 len;
        uint16 impersonation_level;
        uint8 context_mode;
        uint8 effective_only;
 };
 
 struct lsa_ObjectAttribute {
+       uint32 len;
        uint8 *root_dir;
        const char *object_name;
        uint32 attributes;
index c722530eeb50bcd7f4d32dc3980b93db535fb232..e4501676ddccadd0fee484782bdf436a64ba61c4 100644 (file)
@@ -39,12 +39,12 @@ NTSTATUS dcerpc_dfs_Remove(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct df
        return r->out.result;
 }
 
-NTSTATUS dcerpc_dfs_UNKNOWN3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct dfs_UNKNOWN3 *r)
+NTSTATUS dcerpc_dfs_SetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct dfs_SetInfo *r)
 {
        NTSTATUS status;
-       status = dcerpc_ndr_request(p, DCERPC_DFS_UNKNOWN3, mem_ctx,
-                                   (ndr_push_fn_t) ndr_push_dfs_UNKNOWN3,
-                                   (ndr_pull_fn_t) ndr_pull_dfs_UNKNOWN3,
+       status = dcerpc_ndr_request(p, DCERPC_DFS_SETINFO, mem_ctx,
+                                   (ndr_push_fn_t) ndr_push_dfs_SetInfo,
+                                   (ndr_pull_fn_t) ndr_pull_dfs_SetInfo,
                                    r);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
index 14db7e26e6db2b1b45c8bf3c84192f195371e273..5b3844396e5ae607505e96b7098fa11ef9da7cf8 100644 (file)
@@ -91,10 +91,12 @@ static BOOL test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
 
        printf("\ntesting OpenPolicy\n");
 
+       qos.len = 0;
        qos.impersonation_level = 2;
        qos.context_mode = 1;
        qos.effective_only = 0;
 
+       attr.len = 0;
        attr.root_dir = NULL;
        attr.object_name = NULL;
        attr.attributes = 0;
@@ -126,10 +128,12 @@ static BOOL test_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 
        printf("\ntesting OpenPolicy2\n");
 
+       qos.len = 0;
        qos.impersonation_level = 2;
        qos.context_mode = 1;
        qos.effective_only = 0;
 
+       attr.len = 0;
        attr.root_dir = NULL;
        attr.object_name = NULL;
        attr.attributes = 0;