~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source4/torture/rpc/autoidl.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
*/
21
21
 
22
22
#include "includes.h"
23
 
#include "torture/torture.h"
24
23
#include "librpc/gen_ndr/ndr_drsuapi_c.h"
25
 
#include "librpc/gen_ndr/ndr_misc.h"
26
24
#include "librpc/ndr/ndr_table.h"
27
 
#include "torture/rpc/rpc.h"
28
 
#include "librpc/rpc/dcerpc_proto.h"
 
25
#include "torture/rpc/torture_rpc.h"
29
26
 
30
27
 
31
28
#if 1
32
29
/*
33
30
  get a DRSUAPI policy handle
34
31
*/
35
 
static bool get_policy_handle(struct dcerpc_pipe *p,
36
 
                              TALLOC_CTX *mem_ctx, 
 
32
static bool get_policy_handle(struct dcerpc_binding_handle *b,
 
33
                              TALLOC_CTX *mem_ctx,
37
34
                              struct policy_handle *handle)
38
35
{
39
36
        NTSTATUS status;
42
39
        ZERO_STRUCT(r);
43
40
        r.out.bind_handle = handle;
44
41
 
45
 
        status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r);
 
42
        status = dcerpc_drsuapi_DsBind_r(b, mem_ctx, &r);
46
43
        if (!NT_STATUS_IS_OK(status)) {
47
44
                printf("drsuapi_DsBind failed - %s\n", nt_errstr(status));
48
45
                return false;
54
51
/*
55
52
  get a SAMR handle
56
53
*/
57
 
static bool get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
 
54
static bool get_policy_handle(struct dcerpc_binding_handle *b,
 
55
                              TALLOC_CTX *mem_ctx,
58
56
                              struct policy_handle *handle)
59
57
{
60
58
        NTSTATUS status;
64
62
        r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
65
63
        r.out.connect_handle = handle;
66
64
 
67
 
        status = dcerpc_samr_Connect(p, mem_ctx, &r);
 
65
        status = dcerpc_samr_Connect_r(b, mem_ctx, &r);
68
66
        if (!NT_STATUS_IS_OK(status)) {
69
67
                printf("samr_Connect failed - %s\n", nt_errstr(status));
70
68
                return false;
83
81
                return;
84
82
        }
85
83
 
86
 
        ndr_push_struct_blob(&b2, mem_ctx, NULL, handle, (ndr_push_flags_fn_t)ndr_push_policy_handle);
 
84
        ndr_push_struct_blob(&b2, mem_ctx, handle, (ndr_push_flags_fn_t)ndr_push_policy_handle);
87
85
 
88
86
        memcpy(blob->data, b2.data, 20);
89
87
}
126
124
 
127
125
        /* work out how much to expand to get a non fault */
128
126
        for (n=0;n<2000;n++) {
 
127
                uint32_t out_flags = 0;
 
128
 
129
129
                stub_in = data_blob(NULL, base_in->length + n);
130
130
                data_blob_clear(&stub_in);
131
131
                memcpy(stub_in.data, base_in->data, insert_ofs);
132
132
                memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs);
133
133
 
134
 
                status = dcerpc_request(p, NULL, opnum, tctx, &stub_in, &stub_out);
135
 
 
136
 
                if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
 
134
                status = dcerpc_binding_handle_raw_call(p->binding_handle,
 
135
                                                        NULL, opnum,
 
136
                                                        0, /* in_flags */
 
137
                                                        stub_in.data,
 
138
                                                        stub_in.length,
 
139
                                                        tctx,
 
140
                                                        &stub_out.data,
 
141
                                                        &stub_out.length,
 
142
                                                        &out_flags);
 
143
                if (NT_STATUS_IS_OK(status)) {
137
144
                        print_depth(depth);
138
145
                        printf("expand by %d gives %s\n", n, nt_errstr(status));
139
146
                        if (n >= 4) {
144
151
                } else {
145
152
#if 0
146
153
                        print_depth(depth);
147
 
                        printf("expand by %d gives fault %s\n", n, dcerpc_errstr(tctx, p->last_fault_code));
 
154
                        printf("expand by %d gives fault %s\n", n, nt_errstr(status));
148
155
#endif
149
156
                }
150
 
                if (p->last_fault_code == 5) {
 
157
                if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
151
158
                        reopen(tctx, &p, iface);
152
159
                }
153
160
        }
171
178
 
172
179
        /* work out which elements are pointers */
173
180
        for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) {
 
181
                uint32_t out_flags = 0;
 
182
 
174
183
                SIVAL(stub_in.data, ofs, 1);
175
 
                status = dcerpc_request(p, NULL, opnum, tctx, &stub_in, &stub_out);
176
 
 
177
 
                if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
 
184
 
 
185
                status = dcerpc_binding_handle_raw_call(p->binding_handle,
 
186
                                                        NULL, opnum,
 
187
                                                        0, /* in_flags */
 
188
                                                        stub_in.data,
 
189
                                                        stub_in.length,
 
190
                                                        tctx,
 
191
                                                        &stub_out.data,
 
192
                                                        &stub_out.length,
 
193
                                                        &out_flags);
 
194
 
 
195
                if (!NT_STATUS_IS_OK(status)) {
178
196
                        print_depth(depth);
179
197
                        printf("possible ptr at ofs %d - fault %s\n", 
180
 
                               ofs-min_ofs, dcerpc_errstr(tctx, p->last_fault_code));
181
 
                        if (p->last_fault_code == 5) {
 
198
                               ofs-min_ofs, nt_errstr(status));
 
199
                        if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
182
200
                                reopen(tctx, &p, iface);
183
201
                        }
184
202
                        if (depth == 0) {
206
224
 
207
225
        reopen(tctx, &p, iface);
208
226
 
209
 
        get_policy_handle(p, tctx, &handle);
 
227
        get_policy_handle(p->binding_handle, tctx, &handle);
210
228
 
211
229
        /* work out the minimum amount of input data */
212
230
        for (i=0;i<2000;i++) {
 
231
                uint32_t out_flags = 0;
 
232
 
213
233
                stub_in = data_blob(NULL, i);
214
234
                data_blob_clear(&stub_in);
215
235
 
216
 
 
217
 
                status = dcerpc_request(p, NULL, opnum, tctx, &stub_in, &stub_out);
 
236
                status = dcerpc_binding_handle_raw_call(p->binding_handle,
 
237
                                                        NULL, opnum,
 
238
                                                        0, /* in_flags */
 
239
                                                        stub_in.data,
 
240
                                                        stub_in.length,
 
241
                                                        tctx,
 
242
                                                        &stub_out.data,
 
243
                                                        &stub_out.length,
 
244
                                                        &out_flags);
218
245
 
219
246
                if (NT_STATUS_IS_OK(status)) {
220
247
                        printf("opnum %d   min_input %d - output %d\n", 
227
254
 
228
255
                fill_blob_handle(&stub_in, tctx, &handle);
229
256
 
230
 
                status = dcerpc_request(p, NULL, opnum, tctx, &stub_in, &stub_out);
 
257
                status = dcerpc_binding_handle_raw_call(p->binding_handle,
 
258
                                                        NULL, opnum,
 
259
                                                        0, /* in_flags */
 
260
                                                        stub_in.data,
 
261
                                                        stub_in.length,
 
262
                                                        tctx,
 
263
                                                        &stub_out.data,
 
264
                                                        &stub_out.length,
 
265
                                                        &out_flags);
231
266
 
232
267
                if (NT_STATUS_IS_OK(status)) {
233
268
                        printf("opnum %d   min_input %d - output %d (with handle)\n", 
238
273
                        return;
239
274
                }
240
275
 
241
 
                if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
242
 
                        printf("opnum %d  size %d fault %s\n", opnum, i, dcerpc_errstr(tctx, p->last_fault_code));
243
 
                        if (p->last_fault_code == 5) {
 
276
                if (!NT_STATUS_IS_OK(status)) {
 
277
                        printf("opnum %d  size %d fault %s\n", opnum, i, nt_errstr(status));
 
278
                        if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
244
279
                                reopen(tctx, &p, iface);
245
280
                        }
246
281
                        continue;