~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source3/librpc/gen_ndr/py_misc.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:
 
1
 
 
2
/* Python wrapper functions auto-generated by pidl */
 
3
#include <Python.h>
 
4
#include "includes.h"
 
5
#include <pytalloc.h>
 
6
#include "librpc/rpc/pyrpc.h"
 
7
#include "librpc/rpc/pyrpc_util.h"
 
8
#include "librpc/gen_ndr/ndr_misc.h"
 
9
#include "librpc/gen_ndr/ndr_misc_c.h"
 
10
 
 
11
staticforward PyTypeObject GUID_Type;
 
12
staticforward PyTypeObject ndr_syntax_id_Type;
 
13
staticforward PyTypeObject policy_handle_Type;
 
14
staticforward PyTypeObject KRB5_EDATA_NTSTATUS_Type;
 
15
 
 
16
void initmisc(void);static PyTypeObject *Object_Type;
 
17
#include "librpc/ndr/py_misc.c"
 
18
 
 
19
 
 
20
static PyObject *py_GUID_get_time_low(PyObject *obj, void *closure)
 
21
{
 
22
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(obj);
 
23
        PyObject *py_time_low;
 
24
        py_time_low = PyInt_FromLong(object->time_low);
 
25
        return py_time_low;
 
26
}
 
27
 
 
28
static int py_GUID_set_time_low(PyObject *py_obj, PyObject *value, void *closure)
 
29
{
 
30
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
31
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
32
        object->time_low = PyInt_AsLong(value);
 
33
        return 0;
 
34
}
 
35
 
 
36
static PyObject *py_GUID_get_time_mid(PyObject *obj, void *closure)
 
37
{
 
38
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(obj);
 
39
        PyObject *py_time_mid;
 
40
        py_time_mid = PyInt_FromLong(object->time_mid);
 
41
        return py_time_mid;
 
42
}
 
43
 
 
44
static int py_GUID_set_time_mid(PyObject *py_obj, PyObject *value, void *closure)
 
45
{
 
46
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
47
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
48
        object->time_mid = PyInt_AsLong(value);
 
49
        return 0;
 
50
}
 
51
 
 
52
static PyObject *py_GUID_get_time_hi_and_version(PyObject *obj, void *closure)
 
53
{
 
54
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(obj);
 
55
        PyObject *py_time_hi_and_version;
 
56
        py_time_hi_and_version = PyInt_FromLong(object->time_hi_and_version);
 
57
        return py_time_hi_and_version;
 
58
}
 
59
 
 
60
static int py_GUID_set_time_hi_and_version(PyObject *py_obj, PyObject *value, void *closure)
 
61
{
 
62
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
63
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
64
        object->time_hi_and_version = PyInt_AsLong(value);
 
65
        return 0;
 
66
}
 
67
 
 
68
static PyObject *py_GUID_get_clock_seq(PyObject *obj, void *closure)
 
69
{
 
70
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(obj);
 
71
        PyObject *py_clock_seq;
 
72
        py_clock_seq = PyList_New(2);
 
73
        if (py_clock_seq == NULL) {
 
74
                return NULL;
 
75
        }
 
76
        {
 
77
                int clock_seq_cntr_0;
 
78
                for (clock_seq_cntr_0 = 0; clock_seq_cntr_0 < 2; clock_seq_cntr_0++) {
 
79
                        PyObject *py_clock_seq_0;
 
80
                        py_clock_seq_0 = PyInt_FromLong(object->clock_seq[clock_seq_cntr_0]);
 
81
                        PyList_SetItem(py_clock_seq, clock_seq_cntr_0, py_clock_seq_0);
 
82
                }
 
83
        }
 
84
        return py_clock_seq;
 
85
}
 
86
 
 
87
static int py_GUID_set_clock_seq(PyObject *py_obj, PyObject *value, void *closure)
 
88
{
 
89
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
90
        PY_CHECK_TYPE(&PyList_Type, value, return -1;);
 
91
        {
 
92
                int clock_seq_cntr_0;
 
93
                for (clock_seq_cntr_0 = 0; clock_seq_cntr_0 < PyList_GET_SIZE(value); clock_seq_cntr_0++) {
 
94
                        PY_CHECK_TYPE(&PyInt_Type, PyList_GET_ITEM(value, clock_seq_cntr_0), return -1;);
 
95
                        object->clock_seq[clock_seq_cntr_0] = PyInt_AsLong(PyList_GET_ITEM(value, clock_seq_cntr_0));
 
96
                }
 
97
        }
 
98
        return 0;
 
99
}
 
100
 
 
101
static PyObject *py_GUID_get_node(PyObject *obj, void *closure)
 
102
{
 
103
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(obj);
 
104
        PyObject *py_node;
 
105
        py_node = PyList_New(6);
 
106
        if (py_node == NULL) {
 
107
                return NULL;
 
108
        }
 
109
        {
 
110
                int node_cntr_0;
 
111
                for (node_cntr_0 = 0; node_cntr_0 < 6; node_cntr_0++) {
 
112
                        PyObject *py_node_0;
 
113
                        py_node_0 = PyInt_FromLong(object->node[node_cntr_0]);
 
114
                        PyList_SetItem(py_node, node_cntr_0, py_node_0);
 
115
                }
 
116
        }
 
117
        return py_node;
 
118
}
 
119
 
 
120
static int py_GUID_set_node(PyObject *py_obj, PyObject *value, void *closure)
 
121
{
 
122
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
123
        PY_CHECK_TYPE(&PyList_Type, value, return -1;);
 
124
        {
 
125
                int node_cntr_0;
 
126
                for (node_cntr_0 = 0; node_cntr_0 < PyList_GET_SIZE(value); node_cntr_0++) {
 
127
                        PY_CHECK_TYPE(&PyInt_Type, PyList_GET_ITEM(value, node_cntr_0), return -1;);
 
128
                        object->node[node_cntr_0] = PyInt_AsLong(PyList_GET_ITEM(value, node_cntr_0));
 
129
                }
 
130
        }
 
131
        return 0;
 
132
}
 
133
 
 
134
static PyGetSetDef py_GUID_getsetters[] = {
 
135
        { discard_const_p(char, "time_low"), py_GUID_get_time_low, py_GUID_set_time_low },
 
136
        { discard_const_p(char, "time_mid"), py_GUID_get_time_mid, py_GUID_set_time_mid },
 
137
        { discard_const_p(char, "time_hi_and_version"), py_GUID_get_time_hi_and_version, py_GUID_set_time_hi_and_version },
 
138
        { discard_const_p(char, "clock_seq"), py_GUID_get_clock_seq, py_GUID_set_clock_seq },
 
139
        { discard_const_p(char, "node"), py_GUID_get_node, py_GUID_set_node },
 
140
        { NULL }
 
141
};
 
142
 
 
143
static PyObject *py_GUID_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 
144
{
 
145
        return py_talloc_new(struct GUID, type);
 
146
}
 
147
 
 
148
static PyObject *py_GUID_ndr_pack(PyObject *py_obj)
 
149
{
 
150
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
151
        DATA_BLOB blob;
 
152
        enum ndr_err_code err;
 
153
        err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_GUID);
 
154
        if (err != NDR_ERR_SUCCESS) {
 
155
                PyErr_SetNdrError(err);
 
156
                return NULL;
 
157
        }
 
158
 
 
159
        return PyString_FromStringAndSize((char *)blob.data, blob.length);
 
160
}
 
161
 
 
162
static PyObject *py_GUID_ndr_unpack(PyObject *py_obj, PyObject *args)
 
163
{
 
164
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
165
        DATA_BLOB blob;
 
166
        enum ndr_err_code err;
 
167
        if (!PyArg_ParseTuple(args, "s#:__ndr_unpack__", &blob.data, &blob.length))
 
168
                return NULL;
 
169
 
 
170
        err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_GUID);
 
171
        if (err != NDR_ERR_SUCCESS) {
 
172
                PyErr_SetNdrError(err);
 
173
                return NULL;
 
174
        }
 
175
 
 
176
        Py_RETURN_NONE;
 
177
}
 
178
 
 
179
static PyObject *py_GUID_ndr_print(PyObject *py_obj)
 
180
{
 
181
        struct GUID *object = (struct GUID *)py_talloc_get_ptr(py_obj);
 
182
        PyObject *ret;
 
183
        char *retstr;
 
184
 
 
185
        retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_GUID, "GUID", object);
 
186
        ret = PyString_FromString(retstr);
 
187
        talloc_free(retstr);
 
188
 
 
189
        return ret;
 
190
}
 
191
 
 
192
static PyMethodDef py_GUID_methods[] = {
 
193
        { "__ndr_pack__", (PyCFunction)py_GUID_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
 
194
        { "__ndr_unpack__", (PyCFunction)py_GUID_ndr_unpack, METH_VARARGS, "S.ndr_unpack(class, blob) -> None\nNDR unpack" },
 
195
        { "__ndr_print__", (PyCFunction)py_GUID_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
 
196
        { NULL, NULL, 0, NULL }
 
197
};
 
198
 
 
199
 
 
200
static PyTypeObject GUID_Type = {
 
201
        PyObject_HEAD_INIT(NULL) 0,
 
202
        .tp_name = "misc.GUID",
 
203
        .tp_getset = py_GUID_getsetters,
 
204
        .tp_methods = py_GUID_methods,
 
205
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 
206
        .tp_basicsize = sizeof(py_talloc_Object),
 
207
        .tp_new = py_GUID_new,
 
208
};
 
209
 
 
210
 
 
211
static PyObject *py_ndr_syntax_id_get_uuid(PyObject *obj, void *closure)
 
212
{
 
213
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(obj);
 
214
        PyObject *py_uuid;
 
215
        py_uuid = py_talloc_reference_ex(&GUID_Type, py_talloc_get_mem_ctx(obj), &object->uuid);
 
216
        return py_uuid;
 
217
}
 
218
 
 
219
static int py_ndr_syntax_id_set_uuid(PyObject *py_obj, PyObject *value, void *closure)
 
220
{
 
221
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(py_obj);
 
222
        PY_CHECK_TYPE(&GUID_Type, value, return -1;);
 
223
        if (talloc_reference(py_talloc_get_mem_ctx(py_obj), py_talloc_get_mem_ctx(value)) == NULL) {
 
224
                PyErr_NoMemory();
 
225
                return -1;
 
226
        }
 
227
        object->uuid = *(struct GUID *)py_talloc_get_ptr(value);
 
228
        return 0;
 
229
}
 
230
 
 
231
static PyObject *py_ndr_syntax_id_get_if_version(PyObject *obj, void *closure)
 
232
{
 
233
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(obj);
 
234
        PyObject *py_if_version;
 
235
        py_if_version = PyInt_FromLong(object->if_version);
 
236
        return py_if_version;
 
237
}
 
238
 
 
239
static int py_ndr_syntax_id_set_if_version(PyObject *py_obj, PyObject *value, void *closure)
 
240
{
 
241
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(py_obj);
 
242
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
243
        object->if_version = PyInt_AsLong(value);
 
244
        return 0;
 
245
}
 
246
 
 
247
static PyGetSetDef py_ndr_syntax_id_getsetters[] = {
 
248
        { discard_const_p(char, "uuid"), py_ndr_syntax_id_get_uuid, py_ndr_syntax_id_set_uuid },
 
249
        { discard_const_p(char, "if_version"), py_ndr_syntax_id_get_if_version, py_ndr_syntax_id_set_if_version },
 
250
        { NULL }
 
251
};
 
252
 
 
253
static PyObject *py_ndr_syntax_id_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 
254
{
 
255
        return py_talloc_new(struct ndr_syntax_id, type);
 
256
}
 
257
 
 
258
static PyObject *py_ndr_syntax_id_ndr_pack(PyObject *py_obj)
 
259
{
 
260
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(py_obj);
 
261
        DATA_BLOB blob;
 
262
        enum ndr_err_code err;
 
263
        err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_ndr_syntax_id);
 
264
        if (err != NDR_ERR_SUCCESS) {
 
265
                PyErr_SetNdrError(err);
 
266
                return NULL;
 
267
        }
 
268
 
 
269
        return PyString_FromStringAndSize((char *)blob.data, blob.length);
 
270
}
 
271
 
 
272
static PyObject *py_ndr_syntax_id_ndr_unpack(PyObject *py_obj, PyObject *args)
 
273
{
 
274
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(py_obj);
 
275
        DATA_BLOB blob;
 
276
        enum ndr_err_code err;
 
277
        if (!PyArg_ParseTuple(args, "s#:__ndr_unpack__", &blob.data, &blob.length))
 
278
                return NULL;
 
279
 
 
280
        err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_ndr_syntax_id);
 
281
        if (err != NDR_ERR_SUCCESS) {
 
282
                PyErr_SetNdrError(err);
 
283
                return NULL;
 
284
        }
 
285
 
 
286
        Py_RETURN_NONE;
 
287
}
 
288
 
 
289
static PyObject *py_ndr_syntax_id_ndr_print(PyObject *py_obj)
 
290
{
 
291
        struct ndr_syntax_id *object = (struct ndr_syntax_id *)py_talloc_get_ptr(py_obj);
 
292
        PyObject *ret;
 
293
        char *retstr;
 
294
 
 
295
        retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_ndr_syntax_id, "ndr_syntax_id", object);
 
296
        ret = PyString_FromString(retstr);
 
297
        talloc_free(retstr);
 
298
 
 
299
        return ret;
 
300
}
 
301
 
 
302
static PyMethodDef py_ndr_syntax_id_methods[] = {
 
303
        { "__ndr_pack__", (PyCFunction)py_ndr_syntax_id_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
 
304
        { "__ndr_unpack__", (PyCFunction)py_ndr_syntax_id_ndr_unpack, METH_VARARGS, "S.ndr_unpack(class, blob) -> None\nNDR unpack" },
 
305
        { "__ndr_print__", (PyCFunction)py_ndr_syntax_id_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
 
306
        { NULL, NULL, 0, NULL }
 
307
};
 
308
 
 
309
 
 
310
static PyTypeObject ndr_syntax_id_Type = {
 
311
        PyObject_HEAD_INIT(NULL) 0,
 
312
        .tp_name = "misc.ndr_syntax_id",
 
313
        .tp_getset = py_ndr_syntax_id_getsetters,
 
314
        .tp_methods = py_ndr_syntax_id_methods,
 
315
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 
316
        .tp_basicsize = sizeof(py_talloc_Object),
 
317
        .tp_new = py_ndr_syntax_id_new,
 
318
};
 
319
 
 
320
 
 
321
static PyObject *py_policy_handle_get_handle_type(PyObject *obj, void *closure)
 
322
{
 
323
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(obj);
 
324
        PyObject *py_handle_type;
 
325
        py_handle_type = PyInt_FromLong(object->handle_type);
 
326
        return py_handle_type;
 
327
}
 
328
 
 
329
static int py_policy_handle_set_handle_type(PyObject *py_obj, PyObject *value, void *closure)
 
330
{
 
331
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(py_obj);
 
332
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
333
        object->handle_type = PyInt_AsLong(value);
 
334
        return 0;
 
335
}
 
336
 
 
337
static PyObject *py_policy_handle_get_uuid(PyObject *obj, void *closure)
 
338
{
 
339
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(obj);
 
340
        PyObject *py_uuid;
 
341
        py_uuid = py_talloc_reference_ex(&GUID_Type, py_talloc_get_mem_ctx(obj), &object->uuid);
 
342
        return py_uuid;
 
343
}
 
344
 
 
345
static int py_policy_handle_set_uuid(PyObject *py_obj, PyObject *value, void *closure)
 
346
{
 
347
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(py_obj);
 
348
        PY_CHECK_TYPE(&GUID_Type, value, return -1;);
 
349
        if (talloc_reference(py_talloc_get_mem_ctx(py_obj), py_talloc_get_mem_ctx(value)) == NULL) {
 
350
                PyErr_NoMemory();
 
351
                return -1;
 
352
        }
 
353
        object->uuid = *(struct GUID *)py_talloc_get_ptr(value);
 
354
        return 0;
 
355
}
 
356
 
 
357
static PyGetSetDef py_policy_handle_getsetters[] = {
 
358
        { discard_const_p(char, "handle_type"), py_policy_handle_get_handle_type, py_policy_handle_set_handle_type },
 
359
        { discard_const_p(char, "uuid"), py_policy_handle_get_uuid, py_policy_handle_set_uuid },
 
360
        { NULL }
 
361
};
 
362
 
 
363
static PyObject *py_policy_handle_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 
364
{
 
365
        return py_talloc_new(struct policy_handle, type);
 
366
}
 
367
 
 
368
static PyObject *py_policy_handle_ndr_pack(PyObject *py_obj)
 
369
{
 
370
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(py_obj);
 
371
        DATA_BLOB blob;
 
372
        enum ndr_err_code err;
 
373
        err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_policy_handle);
 
374
        if (err != NDR_ERR_SUCCESS) {
 
375
                PyErr_SetNdrError(err);
 
376
                return NULL;
 
377
        }
 
378
 
 
379
        return PyString_FromStringAndSize((char *)blob.data, blob.length);
 
380
}
 
381
 
 
382
static PyObject *py_policy_handle_ndr_unpack(PyObject *py_obj, PyObject *args)
 
383
{
 
384
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(py_obj);
 
385
        DATA_BLOB blob;
 
386
        enum ndr_err_code err;
 
387
        if (!PyArg_ParseTuple(args, "s#:__ndr_unpack__", &blob.data, &blob.length))
 
388
                return NULL;
 
389
 
 
390
        err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_policy_handle);
 
391
        if (err != NDR_ERR_SUCCESS) {
 
392
                PyErr_SetNdrError(err);
 
393
                return NULL;
 
394
        }
 
395
 
 
396
        Py_RETURN_NONE;
 
397
}
 
398
 
 
399
static PyObject *py_policy_handle_ndr_print(PyObject *py_obj)
 
400
{
 
401
        struct policy_handle *object = (struct policy_handle *)py_talloc_get_ptr(py_obj);
 
402
        PyObject *ret;
 
403
        char *retstr;
 
404
 
 
405
        retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_policy_handle, "policy_handle", object);
 
406
        ret = PyString_FromString(retstr);
 
407
        talloc_free(retstr);
 
408
 
 
409
        return ret;
 
410
}
 
411
 
 
412
static PyMethodDef py_policy_handle_methods[] = {
 
413
        { "__ndr_pack__", (PyCFunction)py_policy_handle_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
 
414
        { "__ndr_unpack__", (PyCFunction)py_policy_handle_ndr_unpack, METH_VARARGS, "S.ndr_unpack(class, blob) -> None\nNDR unpack" },
 
415
        { "__ndr_print__", (PyCFunction)py_policy_handle_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
 
416
        { NULL, NULL, 0, NULL }
 
417
};
 
418
 
 
419
 
 
420
static PyTypeObject policy_handle_Type = {
 
421
        PyObject_HEAD_INIT(NULL) 0,
 
422
        .tp_name = "misc.policy_handle",
 
423
        .tp_getset = py_policy_handle_getsetters,
 
424
        .tp_methods = py_policy_handle_methods,
 
425
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 
426
        .tp_basicsize = sizeof(py_talloc_Object),
 
427
        .tp_new = py_policy_handle_new,
 
428
};
 
429
 
 
430
 
 
431
static PyObject *py_KRB5_EDATA_NTSTATUS_get_ntstatus(PyObject *obj, void *closure)
 
432
{
 
433
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(obj);
 
434
        PyObject *py_ntstatus;
 
435
        py_ntstatus = PyErr_FromNTSTATUS(object->ntstatus);
 
436
        return py_ntstatus;
 
437
}
 
438
 
 
439
static int py_KRB5_EDATA_NTSTATUS_set_ntstatus(PyObject *py_obj, PyObject *value, void *closure)
 
440
{
 
441
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(py_obj);
 
442
        object->ntstatus = NT_STATUS(PyInt_AsLong(value));
 
443
        return 0;
 
444
}
 
445
 
 
446
static PyObject *py_KRB5_EDATA_NTSTATUS_get_unknown1(PyObject *obj, void *closure)
 
447
{
 
448
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(obj);
 
449
        PyObject *py_unknown1;
 
450
        py_unknown1 = PyInt_FromLong(object->unknown1);
 
451
        return py_unknown1;
 
452
}
 
453
 
 
454
static int py_KRB5_EDATA_NTSTATUS_set_unknown1(PyObject *py_obj, PyObject *value, void *closure)
 
455
{
 
456
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(py_obj);
 
457
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
458
        object->unknown1 = PyInt_AsLong(value);
 
459
        return 0;
 
460
}
 
461
 
 
462
static PyObject *py_KRB5_EDATA_NTSTATUS_get_unknown2(PyObject *obj, void *closure)
 
463
{
 
464
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(obj);
 
465
        PyObject *py_unknown2;
 
466
        py_unknown2 = PyInt_FromLong(object->unknown2);
 
467
        return py_unknown2;
 
468
}
 
469
 
 
470
static int py_KRB5_EDATA_NTSTATUS_set_unknown2(PyObject *py_obj, PyObject *value, void *closure)
 
471
{
 
472
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(py_obj);
 
473
        PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
 
474
        object->unknown2 = PyInt_AsLong(value);
 
475
        return 0;
 
476
}
 
477
 
 
478
static PyGetSetDef py_KRB5_EDATA_NTSTATUS_getsetters[] = {
 
479
        { discard_const_p(char, "ntstatus"), py_KRB5_EDATA_NTSTATUS_get_ntstatus, py_KRB5_EDATA_NTSTATUS_set_ntstatus },
 
480
        { discard_const_p(char, "unknown1"), py_KRB5_EDATA_NTSTATUS_get_unknown1, py_KRB5_EDATA_NTSTATUS_set_unknown1 },
 
481
        { discard_const_p(char, "unknown2"), py_KRB5_EDATA_NTSTATUS_get_unknown2, py_KRB5_EDATA_NTSTATUS_set_unknown2 },
 
482
        { NULL }
 
483
};
 
484
 
 
485
static PyObject *py_KRB5_EDATA_NTSTATUS_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 
486
{
 
487
        return py_talloc_new(struct KRB5_EDATA_NTSTATUS, type);
 
488
}
 
489
 
 
490
static PyObject *py_KRB5_EDATA_NTSTATUS_ndr_pack(PyObject *py_obj)
 
491
{
 
492
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(py_obj);
 
493
        DATA_BLOB blob;
 
494
        enum ndr_err_code err;
 
495
        err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_KRB5_EDATA_NTSTATUS);
 
496
        if (err != NDR_ERR_SUCCESS) {
 
497
                PyErr_SetNdrError(err);
 
498
                return NULL;
 
499
        }
 
500
 
 
501
        return PyString_FromStringAndSize((char *)blob.data, blob.length);
 
502
}
 
503
 
 
504
static PyObject *py_KRB5_EDATA_NTSTATUS_ndr_unpack(PyObject *py_obj, PyObject *args)
 
505
{
 
506
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(py_obj);
 
507
        DATA_BLOB blob;
 
508
        enum ndr_err_code err;
 
509
        if (!PyArg_ParseTuple(args, "s#:__ndr_unpack__", &blob.data, &blob.length))
 
510
                return NULL;
 
511
 
 
512
        err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_KRB5_EDATA_NTSTATUS);
 
513
        if (err != NDR_ERR_SUCCESS) {
 
514
                PyErr_SetNdrError(err);
 
515
                return NULL;
 
516
        }
 
517
 
 
518
        Py_RETURN_NONE;
 
519
}
 
520
 
 
521
static PyObject *py_KRB5_EDATA_NTSTATUS_ndr_print(PyObject *py_obj)
 
522
{
 
523
        struct KRB5_EDATA_NTSTATUS *object = (struct KRB5_EDATA_NTSTATUS *)py_talloc_get_ptr(py_obj);
 
524
        PyObject *ret;
 
525
        char *retstr;
 
526
 
 
527
        retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_KRB5_EDATA_NTSTATUS, "KRB5_EDATA_NTSTATUS", object);
 
528
        ret = PyString_FromString(retstr);
 
529
        talloc_free(retstr);
 
530
 
 
531
        return ret;
 
532
}
 
533
 
 
534
static PyMethodDef py_KRB5_EDATA_NTSTATUS_methods[] = {
 
535
        { "__ndr_pack__", (PyCFunction)py_KRB5_EDATA_NTSTATUS_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
 
536
        { "__ndr_unpack__", (PyCFunction)py_KRB5_EDATA_NTSTATUS_ndr_unpack, METH_VARARGS, "S.ndr_unpack(class, blob) -> None\nNDR unpack" },
 
537
        { "__ndr_print__", (PyCFunction)py_KRB5_EDATA_NTSTATUS_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
 
538
        { NULL, NULL, 0, NULL }
 
539
};
 
540
 
 
541
 
 
542
static PyTypeObject KRB5_EDATA_NTSTATUS_Type = {
 
543
        PyObject_HEAD_INIT(NULL) 0,
 
544
        .tp_name = "misc.KRB5_EDATA_NTSTATUS",
 
545
        .tp_getset = py_KRB5_EDATA_NTSTATUS_getsetters,
 
546
        .tp_methods = py_KRB5_EDATA_NTSTATUS_methods,
 
547
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 
548
        .tp_basicsize = sizeof(py_talloc_Object),
 
549
        .tp_new = py_KRB5_EDATA_NTSTATUS_new,
 
550
};
 
551
 
 
552
PyObject *py_import_winreg_Data(TALLOC_CTX *mem_ctx, int level, union winreg_Data *in)
 
553
{
 
554
        PyObject *ret;
 
555
 
 
556
        switch (level) {
 
557
                case REG_NONE:
 
558
                        ret = Py_None;
 
559
                        Py_INCREF(ret);
 
560
                        return ret;
 
561
 
 
562
                case REG_SZ:
 
563
                        ret = PyString_FromStringOrNULL(in->string);
 
564
                        return ret;
 
565
 
 
566
                case REG_EXPAND_SZ:
 
567
                        ret = PyString_FromStringOrNULL(in->string);
 
568
                        return ret;
 
569
 
 
570
                case REG_BINARY:
 
571
                        ret = PyString_FromStringAndSize((char *)(in->binary).data, (in->binary).length);
 
572
                        return ret;
 
573
 
 
574
                case REG_DWORD:
 
575
                        ret = PyInt_FromLong(in->value);
 
576
                        return ret;
 
577
 
 
578
                case REG_DWORD_BIG_ENDIAN:
 
579
                        ret = PyInt_FromLong(in->value);
 
580
                        return ret;
 
581
 
 
582
                case REG_MULTI_SZ:
 
583
                        ret = PyCObject_FromTallocPtr(in->string_array);
 
584
                        return ret;
 
585
 
 
586
                default:
 
587
                        ret = PyString_FromStringAndSize((char *)(in->data).data, (in->data).length);
 
588
                        return ret;
 
589
 
 
590
        }
 
591
        PyErr_SetString(PyExc_TypeError, "unknown union level");
 
592
        return NULL;
 
593
}
 
594
 
 
595
union winreg_Data *py_export_winreg_Data(TALLOC_CTX *mem_ctx, int level, PyObject *in)
 
596
{
 
597
        union winreg_Data *ret = talloc_zero(mem_ctx, union winreg_Data);
 
598
        switch (level) {
 
599
                case REG_NONE:
 
600
                        break;
 
601
 
 
602
                case REG_SZ:
 
603
                        ret->string = talloc_strdup(mem_ctx, PyString_AS_STRING(in));
 
604
                        break;
 
605
 
 
606
                case REG_EXPAND_SZ:
 
607
                        ret->string = talloc_strdup(mem_ctx, PyString_AS_STRING(in));
 
608
                        break;
 
609
 
 
610
                case REG_BINARY:
 
611
                        ret->binary = data_blob_talloc(mem_ctx, PyString_AS_STRING(in), PyString_GET_SIZE(in));
 
612
                        break;
 
613
 
 
614
                case REG_DWORD:
 
615
                        PY_CHECK_TYPE(&PyInt_Type, in, talloc_free(ret); return NULL;);
 
616
                        ret->value = PyInt_AsLong(in);
 
617
                        break;
 
618
 
 
619
                case REG_DWORD_BIG_ENDIAN:
 
620
                        PY_CHECK_TYPE(&PyInt_Type, in, talloc_free(ret); return NULL;);
 
621
                        ret->value = PyInt_AsLong(in);
 
622
                        break;
 
623
 
 
624
                case REG_MULTI_SZ:
 
625
                        ret->string_array = PyCObject_AsVoidPtr(in);
 
626
                        break;
 
627
 
 
628
                default:
 
629
                        ret->data = data_blob_talloc(mem_ctx, PyString_AS_STRING(in), PyString_GET_SIZE(in));
 
630
                        break;
 
631
 
 
632
        }
 
633
 
 
634
        return ret;
 
635
}
 
636
 
 
637
static PyMethodDef misc_methods[] = {
 
638
        { NULL, NULL, 0, NULL }
 
639
};
 
640
 
 
641
void initmisc(void)
 
642
{
 
643
        PyObject *m;
 
644
        PyObject *dep_talloc;
 
645
 
 
646
        dep_talloc = PyImport_ImportModule("talloc");
 
647
        if (dep_talloc == NULL)
 
648
                return;
 
649
 
 
650
        Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
 
651
        if (Object_Type == NULL)
 
652
                return;
 
653
 
 
654
        GUID_Type.tp_base = Object_Type;
 
655
 
 
656
        ndr_syntax_id_Type.tp_base = Object_Type;
 
657
 
 
658
        policy_handle_Type.tp_base = Object_Type;
 
659
 
 
660
        KRB5_EDATA_NTSTATUS_Type.tp_base = Object_Type;
 
661
 
 
662
        if (PyType_Ready(&GUID_Type) < 0)
 
663
                return;
 
664
        if (PyType_Ready(&ndr_syntax_id_Type) < 0)
 
665
                return;
 
666
        if (PyType_Ready(&policy_handle_Type) < 0)
 
667
                return;
 
668
        if (PyType_Ready(&KRB5_EDATA_NTSTATUS_Type) < 0)
 
669
                return;
 
670
#ifdef PY_GUID_PATCH
 
671
        PY_GUID_PATCH(&GUID_Type);
 
672
#endif
 
673
#ifdef PY_NDR_SYNTAX_ID_PATCH
 
674
        PY_NDR_SYNTAX_ID_PATCH(&ndr_syntax_id_Type);
 
675
#endif
 
676
#ifdef PY_POLICY_HANDLE_PATCH
 
677
        PY_POLICY_HANDLE_PATCH(&policy_handle_Type);
 
678
#endif
 
679
#ifdef PY_KRB5_EDATA_NTSTATUS_PATCH
 
680
        PY_KRB5_EDATA_NTSTATUS_PATCH(&KRB5_EDATA_NTSTATUS_Type);
 
681
#endif
 
682
 
 
683
        m = Py_InitModule3("misc", misc_methods, "misc DCE/RPC");
 
684
        if (m == NULL)
 
685
                return;
 
686
 
 
687
        PyModule_AddObject(m, "REG_SZ", PyInt_FromLong(REG_SZ));
 
688
        PyModule_AddObject(m, "REG_EXPAND_SZ", PyInt_FromLong(REG_EXPAND_SZ));
 
689
        PyModule_AddObject(m, "SEC_CHAN_WKSTA", PyInt_FromLong(SEC_CHAN_WKSTA));
 
690
        PyModule_AddObject(m, "SEC_CHAN_DOMAIN", PyInt_FromLong(SEC_CHAN_DOMAIN));
 
691
        PyModule_AddObject(m, "REG_RESOURCE_REQUIREMENTS_LIST", PyInt_FromLong(REG_RESOURCE_REQUIREMENTS_LIST));
 
692
        PyModule_AddObject(m, "SEC_CHAN_NULL", PyInt_FromLong(SEC_CHAN_NULL));
 
693
        PyModule_AddObject(m, "REG_FULL_RESOURCE_DESCRIPTOR", PyInt_FromLong(REG_FULL_RESOURCE_DESCRIPTOR));
 
694
        PyModule_AddObject(m, "REG_BINARY", PyInt_FromLong(REG_BINARY));
 
695
        PyModule_AddObject(m, "SEC_CHAN_DNS_DOMAIN", PyInt_FromLong(SEC_CHAN_DNS_DOMAIN));
 
696
        PyModule_AddObject(m, "SEC_CHAN_BDC", PyInt_FromLong(SEC_CHAN_BDC));
 
697
        PyModule_AddObject(m, "REG_RESOURCE_LIST", PyInt_FromLong(REG_RESOURCE_LIST));
 
698
        PyModule_AddObject(m, "REG_DWORD", PyInt_FromLong(REG_DWORD));
 
699
        PyModule_AddObject(m, "REG_MULTI_SZ", PyInt_FromLong(REG_MULTI_SZ));
 
700
        PyModule_AddObject(m, "SEC_CHAN_LANMAN", PyInt_FromLong(SEC_CHAN_LANMAN));
 
701
        PyModule_AddObject(m, "REG_DWORD_BIG_ENDIAN", PyInt_FromLong(REG_DWORD_BIG_ENDIAN));
 
702
        PyModule_AddObject(m, "REG_QWORD", PyInt_FromLong(REG_QWORD));
 
703
        PyModule_AddObject(m, "SEC_CHAN_RODC", PyInt_FromLong(SEC_CHAN_RODC));
 
704
        PyModule_AddObject(m, "REG_LINK", PyInt_FromLong(REG_LINK));
 
705
        PyModule_AddObject(m, "REG_NONE", PyInt_FromLong(REG_NONE));
 
706
        PyModule_AddObject(m, "SEC_CHAN_LOCAL", PyInt_FromLong(SEC_CHAN_LOCAL));
 
707
        Py_INCREF((PyObject *)(void *)&GUID_Type);
 
708
        PyModule_AddObject(m, "GUID", (PyObject *)(void *)&GUID_Type);
 
709
        Py_INCREF((PyObject *)(void *)&ndr_syntax_id_Type);
 
710
        PyModule_AddObject(m, "ndr_syntax_id", (PyObject *)(void *)&ndr_syntax_id_Type);
 
711
        Py_INCREF((PyObject *)(void *)&policy_handle_Type);
 
712
        PyModule_AddObject(m, "policy_handle", (PyObject *)(void *)&policy_handle_Type);
 
713
        Py_INCREF((PyObject *)(void *)&KRB5_EDATA_NTSTATUS_Type);
 
714
        PyModule_AddObject(m, "KRB5_EDATA_NTSTATUS", (PyObject *)(void *)&KRB5_EDATA_NTSTATUS_Type);
 
715
#ifdef PY_MOD_MISC_PATCH
 
716
        PY_MOD_MISC_PATCH(m);
 
717
#endif
 
718
 
 
719
}