Line data Source code
1 :
2 : /* Python wrapper functions auto-generated by pidl */
3 : #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
4 : #include "lib/replace/system/python.h"
5 : #include "python/py3compat.h"
6 : #include "includes.h"
7 : #include "python/modules.h"
8 : #include <pytalloc.h>
9 : #include "librpc/rpc/pyrpc.h"
10 : #include "librpc/rpc/pyrpc_util.h"
11 : #include "bin/default/librpc/gen_ndr/ndr_smb_acl.h"
12 :
13 :
14 : /*
15 : * Suppress compiler warnings if the generated code does not call these
16 : * functions
17 : */
18 : #ifndef _MAYBE_UNUSED_
19 : #ifdef __has_attribute
20 : #if __has_attribute(unused)
21 : #define _MAYBE_UNUSED_ __attribute__ ((unused))
22 : #else
23 : #define _MAYBE_UNUSED_
24 : #endif
25 : #endif
26 : #endif
27 : /*
28 : * These functions are here to ensure they can be optimized out by
29 : * the compiler based on the constant input values
30 : */
31 :
32 0 : static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
33 : {
34 0 : switch (var_size) {
35 0 : case 8:
36 0 : return UINT64_MAX;
37 0 : case 4:
38 0 : return UINT32_MAX;
39 0 : case 2:
40 0 : return UINT16_MAX;
41 0 : case 1:
42 0 : return UINT8_MAX;
43 : }
44 :
45 0 : return 0;
46 : }
47 :
48 0 : static inline _MAYBE_UNUSED_ long long ndr_sizeof2intmax(size_t var_size)
49 : {
50 0 : switch (var_size) {
51 0 : case 8:
52 0 : return INT64_MAX;
53 0 : case 4:
54 0 : return INT32_MAX;
55 0 : case 2:
56 0 : return INT16_MAX;
57 0 : case 1:
58 0 : return INT8_MAX;
59 : }
60 :
61 0 : return 0;
62 : }
63 :
64 : static PyTypeObject smb_acl_user_Type;
65 : static PyTypeObject smb_acl_group_Type;
66 : static PyTypeObject smb_acl_entry_info_Type;
67 : static PyTypeObject smb_acl_entry_Type;
68 : static PyTypeObject smb_acl_t_Type;
69 : static PyTypeObject smb_acl_wrapper_Type;
70 :
71 : static PyTypeObject *BaseObject_Type;
72 :
73 528 : static PyObject *py_smb_acl_user_get_uid(PyObject *obj, void *closure)
74 : {
75 528 : struct smb_acl_user *object = pytalloc_get_ptr(obj);
76 : PyObject *py_uid;
77 528 : py_uid = PyLong_FromUnsignedLongLong(object->uid);
78 528 : return py_uid;
79 : }
80 :
81 0 : static int py_smb_acl_user_set_uid(PyObject *py_obj, PyObject *value, void *closure)
82 : {
83 0 : struct smb_acl_user *object = pytalloc_get_ptr(py_obj);
84 0 : if (value == NULL) {
85 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->uid");
86 0 : return -1;
87 : }
88 : {
89 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->uid));
90 0 : if (PyLong_Check(value)) {
91 : unsigned long long test_var;
92 0 : test_var = PyLong_AsUnsignedLongLong(value);
93 0 : if (PyErr_Occurred() != NULL) {
94 0 : return -1;
95 : }
96 0 : if (test_var > uint_max) {
97 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
98 : PyLong_Type.tp_name, uint_max, test_var);
99 0 : return -1;
100 : }
101 0 : object->uid = test_var;
102 : } else {
103 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
104 : PyLong_Type.tp_name);
105 0 : return -1;
106 : }
107 : }
108 0 : return 0;
109 : }
110 :
111 : static PyGetSetDef py_smb_acl_user_getsetters[] = {
112 : {
113 : .name = discard_const_p(char, "uid"),
114 : .get = py_smb_acl_user_get_uid,
115 : .set = py_smb_acl_user_set_uid,
116 : .doc = discard_const_p(char, "PIDL-generated element of base type uid_t")
117 : },
118 : { .name = NULL }
119 : };
120 :
121 0 : static PyObject *py_smb_acl_user_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
122 : {
123 0 : return pytalloc_new(struct smb_acl_user, type);
124 : }
125 :
126 :
127 : static PyTypeObject smb_acl_user_Type = {
128 : PyVarObject_HEAD_INIT(NULL, 0)
129 : .tp_name = "smb_acl.user",
130 : .tp_getset = py_smb_acl_user_getsetters,
131 : .tp_methods = NULL,
132 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
133 : .tp_new = py_smb_acl_user_new,
134 : };
135 :
136 :
137 456 : static PyObject *py_smb_acl_group_get_gid(PyObject *obj, void *closure)
138 : {
139 456 : struct smb_acl_group *object = pytalloc_get_ptr(obj);
140 : PyObject *py_gid;
141 456 : py_gid = PyLong_FromUnsignedLongLong(object->gid);
142 456 : return py_gid;
143 : }
144 :
145 0 : static int py_smb_acl_group_set_gid(PyObject *py_obj, PyObject *value, void *closure)
146 : {
147 0 : struct smb_acl_group *object = pytalloc_get_ptr(py_obj);
148 0 : if (value == NULL) {
149 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->gid");
150 0 : return -1;
151 : }
152 : {
153 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->gid));
154 0 : if (PyLong_Check(value)) {
155 : unsigned long long test_var;
156 0 : test_var = PyLong_AsUnsignedLongLong(value);
157 0 : if (PyErr_Occurred() != NULL) {
158 0 : return -1;
159 : }
160 0 : if (test_var > uint_max) {
161 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
162 : PyLong_Type.tp_name, uint_max, test_var);
163 0 : return -1;
164 : }
165 0 : object->gid = test_var;
166 : } else {
167 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
168 : PyLong_Type.tp_name);
169 0 : return -1;
170 : }
171 : }
172 0 : return 0;
173 : }
174 :
175 : static PyGetSetDef py_smb_acl_group_getsetters[] = {
176 : {
177 : .name = discard_const_p(char, "gid"),
178 : .get = py_smb_acl_group_get_gid,
179 : .set = py_smb_acl_group_set_gid,
180 : .doc = discard_const_p(char, "PIDL-generated element of base type gid_t")
181 : },
182 : { .name = NULL }
183 : };
184 :
185 0 : static PyObject *py_smb_acl_group_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
186 : {
187 0 : return pytalloc_new(struct smb_acl_group, type);
188 : }
189 :
190 :
191 : static PyTypeObject smb_acl_group_Type = {
192 : PyVarObject_HEAD_INIT(NULL, 0)
193 : .tp_name = "smb_acl.group",
194 : .tp_getset = py_smb_acl_group_getsetters,
195 : .tp_methods = NULL,
196 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
197 : .tp_new = py_smb_acl_group_new,
198 : };
199 :
200 984 : static PyObject *py_import_smb_acl_entry_info(TALLOC_CTX *mem_ctx, int level, union smb_acl_entry_info *in)
201 : {
202 : PyObject *ret;
203 :
204 984 : switch (level) {
205 528 : case SMB_ACL_USER:
206 528 : ret = pytalloc_reference_ex(&smb_acl_user_Type, mem_ctx, &in->user);
207 528 : return ret;
208 :
209 0 : case SMB_ACL_USER_OBJ:
210 0 : ret = Py_None;
211 0 : Py_INCREF(ret);
212 0 : return ret;
213 :
214 456 : case SMB_ACL_GROUP:
215 456 : ret = pytalloc_reference_ex(&smb_acl_group_Type, mem_ctx, &in->group);
216 456 : return ret;
217 :
218 0 : case SMB_ACL_GROUP_OBJ:
219 0 : ret = Py_None;
220 0 : Py_INCREF(ret);
221 0 : return ret;
222 :
223 0 : case SMB_ACL_OTHER:
224 0 : ret = Py_None;
225 0 : Py_INCREF(ret);
226 0 : return ret;
227 :
228 0 : case SMB_ACL_MASK:
229 0 : ret = Py_None;
230 0 : Py_INCREF(ret);
231 0 : return ret;
232 :
233 : }
234 0 : PyErr_SetString(PyExc_TypeError, "unknown union level");
235 0 : return NULL;
236 : }
237 :
238 0 : static union smb_acl_entry_info *py_export_smb_acl_entry_info(TALLOC_CTX *mem_ctx, int level, PyObject *in)
239 : {
240 0 : union smb_acl_entry_info *ret = talloc_zero(mem_ctx, union smb_acl_entry_info);
241 0 : switch (level) {
242 0 : case SMB_ACL_USER:
243 0 : if (in == NULL) {
244 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->user");
245 0 : talloc_free(ret); return NULL;
246 : }
247 0 : PY_CHECK_TYPE(&smb_acl_user_Type, in, talloc_free(ret); return NULL;);
248 0 : if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
249 0 : PyErr_NoMemory();
250 0 : talloc_free(ret); return NULL;
251 : }
252 0 : ret->user = *(struct smb_acl_user *)pytalloc_get_ptr(in);
253 0 : break;
254 :
255 0 : case SMB_ACL_USER_OBJ:
256 0 : break;
257 :
258 0 : case SMB_ACL_GROUP:
259 0 : if (in == NULL) {
260 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->group");
261 0 : talloc_free(ret); return NULL;
262 : }
263 0 : PY_CHECK_TYPE(&smb_acl_group_Type, in, talloc_free(ret); return NULL;);
264 0 : if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
265 0 : PyErr_NoMemory();
266 0 : talloc_free(ret); return NULL;
267 : }
268 0 : ret->group = *(struct smb_acl_group *)pytalloc_get_ptr(in);
269 0 : break;
270 :
271 0 : case SMB_ACL_GROUP_OBJ:
272 0 : break;
273 :
274 0 : case SMB_ACL_OTHER:
275 0 : break;
276 :
277 0 : case SMB_ACL_MASK:
278 0 : break;
279 :
280 0 : default:
281 0 : PyErr_SetString(PyExc_TypeError, "invalid union level value");
282 0 : talloc_free(ret);
283 0 : ret = NULL;
284 : }
285 :
286 0 : return ret;
287 : }
288 :
289 984 : static PyObject *py_smb_acl_entry_info_import(PyTypeObject *type, PyObject *args, PyObject *kwargs)
290 : {
291 984 : const char * const kwnames[] = { "mem_ctx", "level", "in", NULL };
292 984 : PyObject *mem_ctx_obj = NULL;
293 984 : TALLOC_CTX *mem_ctx = NULL;
294 984 : int level = 0;
295 984 : PyObject *in_obj = NULL;
296 984 : union smb_acl_entry_info *in = NULL;
297 :
298 984 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO:import",
299 : discard_const_p(char *, kwnames),
300 : &mem_ctx_obj,
301 : &level,
302 : &in_obj)) {
303 0 : return NULL;
304 : }
305 984 : mem_ctx = pytalloc_get_ptr(mem_ctx_obj);
306 984 : if (mem_ctx == NULL) {
307 0 : PyErr_SetString(PyExc_TypeError, "mem_ctx is NULL)!");
308 0 : return NULL;
309 : }
310 984 : in = (union smb_acl_entry_info *)pytalloc_get_ptr(in_obj);
311 984 : if (in == NULL) {
312 0 : PyErr_Format(PyExc_TypeError, "in needs to be a pointer to union smb_acl_entry_info!");
313 0 : return NULL;
314 : }
315 :
316 984 : return py_import_smb_acl_entry_info(mem_ctx, level, in);
317 : }
318 :
319 0 : static PyObject *py_smb_acl_entry_info_export(PyTypeObject *type, PyObject *args, PyObject *kwargs)
320 : {
321 0 : const char * const kwnames[] = { "mem_ctx", "level", "in", NULL };
322 0 : PyObject *mem_ctx_obj = NULL;
323 0 : TALLOC_CTX *mem_ctx = NULL;
324 0 : int level = 0;
325 0 : PyObject *in = NULL;
326 0 : union smb_acl_entry_info *out = NULL;
327 :
328 0 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO:export",
329 : discard_const_p(char *, kwnames),
330 : &mem_ctx_obj,
331 : &level,
332 : &in)) {
333 0 : return NULL;
334 : }
335 0 : mem_ctx = pytalloc_get_ptr(mem_ctx_obj);
336 0 : if (mem_ctx == NULL) {
337 0 : PyErr_SetString(PyExc_TypeError, "mem_ctx is NULL)!");
338 0 : return NULL;
339 : }
340 :
341 0 : out = py_export_smb_acl_entry_info(mem_ctx, level, in);
342 0 : if (out == NULL) {
343 0 : return NULL;
344 : }
345 :
346 0 : return pytalloc_GenericObject_reference(out);
347 : }
348 :
349 : static PyMethodDef py_smb_acl_entry_info_methods[] = {
350 : { "__import__", PY_DISCARD_FUNC_SIG(PyCFunction,py_smb_acl_entry_info_import),
351 : METH_VARARGS|METH_KEYWORDS|METH_CLASS,
352 : "T.__import__(mem_ctx, level, in) => ret." },
353 : { "__export__", PY_DISCARD_FUNC_SIG(PyCFunction,py_smb_acl_entry_info_export),
354 : METH_VARARGS|METH_KEYWORDS|METH_CLASS,
355 : "T.__export__(mem_ctx, level, in) => ret." },
356 : { NULL, NULL, 0, NULL }
357 : };
358 :
359 0 : static PyObject *py_smb_acl_entry_info_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
360 : {
361 0 : PyErr_Format(PyExc_TypeError, "New %s Objects are not supported", type->tp_name);
362 0 : return NULL;
363 : }
364 :
365 :
366 : static PyTypeObject smb_acl_entry_info_Type = {
367 : PyVarObject_HEAD_INIT(NULL, 0)
368 : .tp_name = "smb_acl.entry_info",
369 : .tp_getset = NULL,
370 : .tp_methods = py_smb_acl_entry_info_methods,
371 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
372 : .tp_new = py_smb_acl_entry_info_new,
373 : };
374 :
375 :
376 3312 : static PyObject *py_smb_acl_entry_get_a_type(PyObject *obj, void *closure)
377 : {
378 3312 : struct smb_acl_entry *object = pytalloc_get_ptr(obj);
379 : PyObject *py_a_type;
380 3312 : py_a_type = PyLong_FromLong((uint16_t)(object->a_type));
381 3312 : return py_a_type;
382 : }
383 :
384 0 : static int py_smb_acl_entry_set_a_type(PyObject *py_obj, PyObject *value, void *closure)
385 : {
386 0 : struct smb_acl_entry *object = pytalloc_get_ptr(py_obj);
387 0 : if (value == NULL) {
388 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->a_type");
389 0 : return -1;
390 : }
391 : {
392 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->a_type));
393 0 : if (PyLong_Check(value)) {
394 : unsigned long long test_var;
395 0 : test_var = PyLong_AsUnsignedLongLong(value);
396 0 : if (PyErr_Occurred() != NULL) {
397 0 : return -1;
398 : }
399 0 : if (test_var > uint_max) {
400 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
401 : PyLong_Type.tp_name, uint_max, test_var);
402 0 : return -1;
403 : }
404 0 : object->a_type = test_var;
405 : } else {
406 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
407 : PyLong_Type.tp_name);
408 0 : return -1;
409 : }
410 : }
411 0 : return 0;
412 : }
413 :
414 984 : static PyObject *py_smb_acl_entry_get_info(PyObject *obj, void *closure)
415 : {
416 984 : struct smb_acl_entry *object = pytalloc_get_ptr(obj);
417 : PyObject *py_info;
418 984 : py_info = pyrpc_import_union(&smb_acl_entry_info_Type, pytalloc_get_mem_ctx(obj), object->a_type, &object->info, "union smb_acl_entry_info");
419 984 : if (py_info == NULL) {
420 0 : return NULL;
421 : }
422 984 : return py_info;
423 : }
424 :
425 0 : static int py_smb_acl_entry_set_info(PyObject *py_obj, PyObject *value, void *closure)
426 : {
427 0 : struct smb_acl_entry *object = pytalloc_get_ptr(py_obj);
428 0 : if (value == NULL) {
429 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->info");
430 0 : return -1;
431 : }
432 : {
433 : union smb_acl_entry_info *info_switch_0;
434 0 : info_switch_0 = (union smb_acl_entry_info *)pyrpc_export_union(&smb_acl_entry_info_Type, pytalloc_get_mem_ctx(py_obj), object->a_type, value, "union smb_acl_entry_info");
435 0 : if (info_switch_0 == NULL) {
436 0 : return -1;
437 : }
438 0 : object->info = *info_switch_0;
439 : }
440 0 : return 0;
441 : }
442 :
443 1656 : static PyObject *py_smb_acl_entry_get_a_perm(PyObject *obj, void *closure)
444 : {
445 1656 : struct smb_acl_entry *object = pytalloc_get_ptr(obj);
446 : PyObject *py_a_perm;
447 1656 : py_a_perm = PyLong_FromUnsignedLongLong((uint32_t)(object->a_perm));
448 1656 : return py_a_perm;
449 : }
450 :
451 0 : static int py_smb_acl_entry_set_a_perm(PyObject *py_obj, PyObject *value, void *closure)
452 : {
453 0 : struct smb_acl_entry *object = pytalloc_get_ptr(py_obj);
454 0 : if (value == NULL) {
455 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->a_perm");
456 0 : return -1;
457 : }
458 : {
459 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->a_perm));
460 0 : if (PyLong_Check(value)) {
461 : unsigned long long test_var;
462 0 : test_var = PyLong_AsUnsignedLongLong(value);
463 0 : if (PyErr_Occurred() != NULL) {
464 0 : return -1;
465 : }
466 0 : if (test_var > uint_max) {
467 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
468 : PyLong_Type.tp_name, uint_max, test_var);
469 0 : return -1;
470 : }
471 0 : object->a_perm = test_var;
472 : } else {
473 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
474 : PyLong_Type.tp_name);
475 0 : return -1;
476 : }
477 : }
478 0 : return 0;
479 : }
480 :
481 : static PyGetSetDef py_smb_acl_entry_getsetters[] = {
482 : {
483 : .name = discard_const_p(char, "a_type"),
484 : .get = py_smb_acl_entry_get_a_type,
485 : .set = py_smb_acl_entry_set_a_type,
486 : .doc = discard_const_p(char, "PIDL-generated element of base type smb_acl_tag_t")
487 : },
488 : {
489 : .name = discard_const_p(char, "info"),
490 : .get = py_smb_acl_entry_get_info,
491 : .set = py_smb_acl_entry_set_info,
492 : .doc = discard_const_p(char, "PIDL-generated element of base type smb_acl_entry_info")
493 : },
494 : {
495 : .name = discard_const_p(char, "a_perm"),
496 : .get = py_smb_acl_entry_get_a_perm,
497 : .set = py_smb_acl_entry_set_a_perm,
498 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
499 : },
500 : { .name = NULL }
501 : };
502 :
503 0 : static PyObject *py_smb_acl_entry_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
504 : {
505 0 : return pytalloc_new(struct smb_acl_entry, type);
506 : }
507 :
508 :
509 : static PyTypeObject smb_acl_entry_Type = {
510 : PyVarObject_HEAD_INIT(NULL, 0)
511 : .tp_name = "smb_acl.entry",
512 : .tp_getset = py_smb_acl_entry_getsetters,
513 : .tp_methods = NULL,
514 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
515 : .tp_new = py_smb_acl_entry_new,
516 : };
517 :
518 :
519 84 : static PyObject *py_smb_acl_t_get_count(PyObject *obj, void *closure)
520 : {
521 84 : struct smb_acl_t *object = pytalloc_get_ptr(obj);
522 : PyObject *py_count;
523 84 : py_count = PyLong_FromLong(object->count);
524 84 : return py_count;
525 : }
526 :
527 0 : static int py_smb_acl_t_set_count(PyObject *py_obj, PyObject *value, void *closure)
528 : {
529 0 : struct smb_acl_t *object = pytalloc_get_ptr(py_obj);
530 0 : if (value == NULL) {
531 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->count");
532 0 : return -1;
533 : }
534 : {
535 0 : const long long int_max = ndr_sizeof2intmax(sizeof(object->count));
536 0 : const long long int_min = -int_max - 1;
537 0 : if (PyLong_Check(value)) {
538 : long long test_var;
539 0 : test_var = PyLong_AsLongLong(value);
540 0 : if (PyErr_Occurred() != NULL) {
541 0 : return -1;
542 : }
543 0 : if (test_var < int_min || test_var > int_max) {
544 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range %lld - %lld, got %lld",
545 : PyLong_Type.tp_name, int_min, int_max, test_var);
546 0 : return -1;
547 : }
548 0 : object->count = test_var;
549 : } else {
550 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
551 : PyLong_Type.tp_name);
552 0 : return -1;
553 : }
554 : }
555 0 : return 0;
556 : }
557 :
558 0 : static PyObject *py_smb_acl_t_get_next(PyObject *obj, void *closure)
559 : {
560 0 : struct smb_acl_t *object = pytalloc_get_ptr(obj);
561 : PyObject *py_next;
562 0 : py_next = PyLong_FromLong(object->next);
563 0 : return py_next;
564 : }
565 :
566 0 : static int py_smb_acl_t_set_next(PyObject *py_obj, PyObject *value, void *closure)
567 : {
568 0 : struct smb_acl_t *object = pytalloc_get_ptr(py_obj);
569 0 : if (value == NULL) {
570 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->next");
571 0 : return -1;
572 : }
573 : {
574 0 : const long long int_max = ndr_sizeof2intmax(sizeof(object->next));
575 0 : const long long int_min = -int_max - 1;
576 0 : if (PyLong_Check(value)) {
577 : long long test_var;
578 0 : test_var = PyLong_AsLongLong(value);
579 0 : if (PyErr_Occurred() != NULL) {
580 0 : return -1;
581 : }
582 0 : if (test_var < int_min || test_var > int_max) {
583 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range %lld - %lld, got %lld",
584 : PyLong_Type.tp_name, int_min, int_max, test_var);
585 0 : return -1;
586 : }
587 0 : object->next = test_var;
588 : } else {
589 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
590 : PyLong_Type.tp_name);
591 0 : return -1;
592 : }
593 : }
594 0 : return 0;
595 : }
596 :
597 2232 : static PyObject *py_smb_acl_t_get_acl(PyObject *obj, void *closure)
598 : {
599 2232 : struct smb_acl_t *object = pytalloc_get_ptr(obj);
600 : PyObject *py_acl;
601 2232 : py_acl = PyList_New(object->count);
602 2232 : if (py_acl == NULL) {
603 0 : return NULL;
604 : }
605 : {
606 : int acl_cntr_0;
607 30168 : for (acl_cntr_0 = 0; acl_cntr_0 < (object->count); acl_cntr_0++) {
608 : PyObject *py_acl_0;
609 27936 : py_acl_0 = pytalloc_reference_ex(&smb_acl_entry_Type, object->acl, &(object->acl)[acl_cntr_0]);
610 27936 : PyList_SetItem(py_acl, acl_cntr_0, py_acl_0);
611 : }
612 : }
613 2232 : return py_acl;
614 : }
615 :
616 0 : static int py_smb_acl_t_set_acl(PyObject *py_obj, PyObject *value, void *closure)
617 : {
618 0 : struct smb_acl_t *object = pytalloc_get_ptr(py_obj);
619 0 : if (value == NULL) {
620 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->acl");
621 0 : return -1;
622 : }
623 0 : PY_CHECK_TYPE(&PyList_Type, value, return -1;);
624 : {
625 : int acl_cntr_0;
626 0 : object->acl = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->acl, PyList_GET_SIZE(value));
627 0 : if (!object->acl) { return -1; }
628 0 : talloc_set_name_const(object->acl, "ARRAY: object->acl");
629 0 : for (acl_cntr_0 = 0; acl_cntr_0 < PyList_GET_SIZE(value); acl_cntr_0++) {
630 0 : if (PyList_GET_ITEM(value, acl_cntr_0) == NULL) {
631 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->acl)[acl_cntr_0]");
632 0 : return -1;
633 : }
634 0 : PY_CHECK_TYPE(&smb_acl_entry_Type, PyList_GET_ITEM(value, acl_cntr_0), return -1;);
635 0 : if (talloc_reference(object->acl, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, acl_cntr_0))) == NULL) {
636 0 : PyErr_NoMemory();
637 0 : return -1;
638 : }
639 0 : (object->acl)[acl_cntr_0] = *(struct smb_acl_entry *)pytalloc_get_ptr(PyList_GET_ITEM(value, acl_cntr_0));
640 : }
641 : }
642 0 : return 0;
643 : }
644 :
645 : static PyGetSetDef py_smb_acl_t_getsetters[] = {
646 : {
647 : .name = discard_const_p(char, "count"),
648 : .get = py_smb_acl_t_get_count,
649 : .set = py_smb_acl_t_set_count,
650 : .doc = discard_const_p(char, "PIDL-generated element of base type int32")
651 : },
652 : {
653 : .name = discard_const_p(char, "next"),
654 : .get = py_smb_acl_t_get_next,
655 : .set = py_smb_acl_t_set_next,
656 : .doc = discard_const_p(char, "PIDL-generated element of base type int32")
657 : },
658 : {
659 : .name = discard_const_p(char, "acl"),
660 : .get = py_smb_acl_t_get_acl,
661 : .set = py_smb_acl_t_set_acl,
662 : .doc = discard_const_p(char, "PIDL-generated element of base type smb_acl_entry")
663 : },
664 : { .name = NULL }
665 : };
666 :
667 0 : static PyObject *py_smb_acl_t_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
668 : {
669 0 : return pytalloc_new(struct smb_acl_t, type);
670 : }
671 :
672 :
673 : static PyTypeObject smb_acl_t_Type = {
674 : PyVarObject_HEAD_INIT(NULL, 0)
675 : .tp_name = "smb_acl.t",
676 : .tp_getset = py_smb_acl_t_getsetters,
677 : .tp_methods = NULL,
678 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
679 : .tp_new = py_smb_acl_t_new,
680 : };
681 :
682 :
683 0 : static PyObject *py_smb_acl_wrapper_get_access_acl(PyObject *obj, void *closure)
684 : {
685 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(obj);
686 : PyObject *py_access_acl;
687 0 : if (object->access_acl == NULL) {
688 0 : Py_RETURN_NONE;
689 : }
690 0 : if (object->access_acl == NULL) {
691 0 : py_access_acl = Py_None;
692 0 : Py_INCREF(py_access_acl);
693 : } else {
694 0 : py_access_acl = pytalloc_reference_ex(&smb_acl_t_Type, object->access_acl, object->access_acl);
695 : }
696 0 : return py_access_acl;
697 : }
698 :
699 0 : static int py_smb_acl_wrapper_set_access_acl(PyObject *py_obj, PyObject *value, void *closure)
700 : {
701 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(py_obj);
702 0 : talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->access_acl));
703 0 : if (value == NULL) {
704 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->access_acl");
705 0 : return -1;
706 : }
707 0 : if (value == Py_None) {
708 0 : object->access_acl = NULL;
709 : } else {
710 0 : object->access_acl = NULL;
711 0 : PY_CHECK_TYPE(&smb_acl_t_Type, value, return -1;);
712 0 : if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
713 0 : PyErr_NoMemory();
714 0 : return -1;
715 : }
716 0 : object->access_acl = (struct smb_acl_t *)pytalloc_get_ptr(value);
717 : }
718 0 : return 0;
719 : }
720 :
721 0 : static PyObject *py_smb_acl_wrapper_get_default_acl(PyObject *obj, void *closure)
722 : {
723 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(obj);
724 : PyObject *py_default_acl;
725 0 : if (object->default_acl == NULL) {
726 0 : Py_RETURN_NONE;
727 : }
728 0 : if (object->default_acl == NULL) {
729 0 : py_default_acl = Py_None;
730 0 : Py_INCREF(py_default_acl);
731 : } else {
732 0 : py_default_acl = pytalloc_reference_ex(&smb_acl_t_Type, object->default_acl, object->default_acl);
733 : }
734 0 : return py_default_acl;
735 : }
736 :
737 0 : static int py_smb_acl_wrapper_set_default_acl(PyObject *py_obj, PyObject *value, void *closure)
738 : {
739 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(py_obj);
740 0 : talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->default_acl));
741 0 : if (value == NULL) {
742 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->default_acl");
743 0 : return -1;
744 : }
745 0 : if (value == Py_None) {
746 0 : object->default_acl = NULL;
747 : } else {
748 0 : object->default_acl = NULL;
749 0 : PY_CHECK_TYPE(&smb_acl_t_Type, value, return -1;);
750 0 : if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
751 0 : PyErr_NoMemory();
752 0 : return -1;
753 : }
754 0 : object->default_acl = (struct smb_acl_t *)pytalloc_get_ptr(value);
755 : }
756 0 : return 0;
757 : }
758 :
759 0 : static PyObject *py_smb_acl_wrapper_get_owner(PyObject *obj, void *closure)
760 : {
761 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(obj);
762 : PyObject *py_owner;
763 0 : py_owner = PyLong_FromUnsignedLongLong(object->owner);
764 0 : return py_owner;
765 : }
766 :
767 0 : static int py_smb_acl_wrapper_set_owner(PyObject *py_obj, PyObject *value, void *closure)
768 : {
769 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(py_obj);
770 0 : if (value == NULL) {
771 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->owner");
772 0 : return -1;
773 : }
774 : {
775 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->owner));
776 0 : if (PyLong_Check(value)) {
777 : unsigned long long test_var;
778 0 : test_var = PyLong_AsUnsignedLongLong(value);
779 0 : if (PyErr_Occurred() != NULL) {
780 0 : return -1;
781 : }
782 0 : if (test_var > uint_max) {
783 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
784 : PyLong_Type.tp_name, uint_max, test_var);
785 0 : return -1;
786 : }
787 0 : object->owner = test_var;
788 : } else {
789 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
790 : PyLong_Type.tp_name);
791 0 : return -1;
792 : }
793 : }
794 0 : return 0;
795 : }
796 :
797 0 : static PyObject *py_smb_acl_wrapper_get_group(PyObject *obj, void *closure)
798 : {
799 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(obj);
800 : PyObject *py_group;
801 0 : py_group = PyLong_FromUnsignedLongLong(object->group);
802 0 : return py_group;
803 : }
804 :
805 0 : static int py_smb_acl_wrapper_set_group(PyObject *py_obj, PyObject *value, void *closure)
806 : {
807 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(py_obj);
808 0 : if (value == NULL) {
809 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->group");
810 0 : return -1;
811 : }
812 : {
813 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->group));
814 0 : if (PyLong_Check(value)) {
815 : unsigned long long test_var;
816 0 : test_var = PyLong_AsUnsignedLongLong(value);
817 0 : if (PyErr_Occurred() != NULL) {
818 0 : return -1;
819 : }
820 0 : if (test_var > uint_max) {
821 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
822 : PyLong_Type.tp_name, uint_max, test_var);
823 0 : return -1;
824 : }
825 0 : object->group = test_var;
826 : } else {
827 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
828 : PyLong_Type.tp_name);
829 0 : return -1;
830 : }
831 : }
832 0 : return 0;
833 : }
834 :
835 0 : static PyObject *py_smb_acl_wrapper_get_mode(PyObject *obj, void *closure)
836 : {
837 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(obj);
838 : PyObject *py_mode;
839 0 : py_mode = PyLong_FromUnsignedLongLong((uint32_t)(object->mode));
840 0 : return py_mode;
841 : }
842 :
843 0 : static int py_smb_acl_wrapper_set_mode(PyObject *py_obj, PyObject *value, void *closure)
844 : {
845 0 : struct smb_acl_wrapper *object = pytalloc_get_ptr(py_obj);
846 0 : if (value == NULL) {
847 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->mode");
848 0 : return -1;
849 : }
850 : {
851 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->mode));
852 0 : if (PyLong_Check(value)) {
853 : unsigned long long test_var;
854 0 : test_var = PyLong_AsUnsignedLongLong(value);
855 0 : if (PyErr_Occurred() != NULL) {
856 0 : return -1;
857 : }
858 0 : if (test_var > uint_max) {
859 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
860 : PyLong_Type.tp_name, uint_max, test_var);
861 0 : return -1;
862 : }
863 0 : object->mode = test_var;
864 : } else {
865 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
866 : PyLong_Type.tp_name);
867 0 : return -1;
868 : }
869 : }
870 0 : return 0;
871 : }
872 :
873 : static PyGetSetDef py_smb_acl_wrapper_getsetters[] = {
874 : {
875 : .name = discard_const_p(char, "access_acl"),
876 : .get = py_smb_acl_wrapper_get_access_acl,
877 : .set = py_smb_acl_wrapper_set_access_acl,
878 : .doc = discard_const_p(char, "PIDL-generated element of base type smb_acl_t")
879 : },
880 : {
881 : .name = discard_const_p(char, "default_acl"),
882 : .get = py_smb_acl_wrapper_get_default_acl,
883 : .set = py_smb_acl_wrapper_set_default_acl,
884 : .doc = discard_const_p(char, "PIDL-generated element of base type smb_acl_t")
885 : },
886 : {
887 : .name = discard_const_p(char, "owner"),
888 : .get = py_smb_acl_wrapper_get_owner,
889 : .set = py_smb_acl_wrapper_set_owner,
890 : .doc = discard_const_p(char, "PIDL-generated element of base type uid_t")
891 : },
892 : {
893 : .name = discard_const_p(char, "group"),
894 : .get = py_smb_acl_wrapper_get_group,
895 : .set = py_smb_acl_wrapper_set_group,
896 : .doc = discard_const_p(char, "PIDL-generated element of base type gid_t")
897 : },
898 : {
899 : .name = discard_const_p(char, "mode"),
900 : .get = py_smb_acl_wrapper_get_mode,
901 : .set = py_smb_acl_wrapper_set_mode,
902 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
903 : },
904 : { .name = NULL }
905 : };
906 :
907 0 : static PyObject *py_smb_acl_wrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
908 : {
909 0 : return pytalloc_new(struct smb_acl_wrapper, type);
910 : }
911 :
912 :
913 : static PyTypeObject smb_acl_wrapper_Type = {
914 : PyVarObject_HEAD_INIT(NULL, 0)
915 : .tp_name = "smb_acl.wrapper",
916 : .tp_getset = py_smb_acl_wrapper_getsetters,
917 : .tp_methods = NULL,
918 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
919 : .tp_new = py_smb_acl_wrapper_new,
920 : };
921 :
922 : static PyMethodDef smb_acl_methods[] = {
923 : { NULL, NULL, 0, NULL }
924 : };
925 :
926 : static struct PyModuleDef moduledef = {
927 : PyModuleDef_HEAD_INIT,
928 : .m_name = "smb_acl",
929 : .m_doc = "smb_acl DCE/RPC",
930 : .m_size = -1,
931 : .m_methods = smb_acl_methods,
932 : };
933 4 : MODULE_INIT_FUNC(smb_acl)
934 : {
935 4 : PyObject *m = NULL;
936 4 : PyObject *dep_talloc = NULL;
937 :
938 4 : dep_talloc = PyImport_ImportModule("talloc");
939 4 : if (dep_talloc == NULL)
940 0 : goto out;
941 :
942 4 : BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
943 4 : if (BaseObject_Type == NULL)
944 0 : goto out;
945 :
946 4 : smb_acl_user_Type.tp_base = BaseObject_Type;
947 4 : smb_acl_user_Type.tp_basicsize = pytalloc_BaseObject_size();
948 :
949 4 : smb_acl_group_Type.tp_base = BaseObject_Type;
950 4 : smb_acl_group_Type.tp_basicsize = pytalloc_BaseObject_size();
951 :
952 4 : smb_acl_entry_info_Type.tp_base = BaseObject_Type;
953 4 : smb_acl_entry_info_Type.tp_basicsize = pytalloc_BaseObject_size();
954 :
955 4 : smb_acl_entry_Type.tp_base = BaseObject_Type;
956 4 : smb_acl_entry_Type.tp_basicsize = pytalloc_BaseObject_size();
957 :
958 4 : smb_acl_t_Type.tp_base = BaseObject_Type;
959 4 : smb_acl_t_Type.tp_basicsize = pytalloc_BaseObject_size();
960 :
961 4 : smb_acl_wrapper_Type.tp_base = BaseObject_Type;
962 4 : smb_acl_wrapper_Type.tp_basicsize = pytalloc_BaseObject_size();
963 :
964 4 : if (PyType_Ready(&smb_acl_user_Type) < 0)
965 0 : goto out;
966 4 : if (PyType_Ready(&smb_acl_group_Type) < 0)
967 0 : goto out;
968 4 : if (PyType_Ready(&smb_acl_entry_info_Type) < 0)
969 0 : goto out;
970 4 : if (PyType_Ready(&smb_acl_entry_Type) < 0)
971 0 : goto out;
972 4 : if (PyType_Ready(&smb_acl_t_Type) < 0)
973 0 : goto out;
974 4 : if (PyType_Ready(&smb_acl_wrapper_Type) < 0)
975 0 : goto out;
976 : #ifdef PY_USER_PATCH
977 : PY_USER_PATCH(&smb_acl_user_Type);
978 : #endif
979 : #ifdef PY_GROUP_PATCH
980 : PY_GROUP_PATCH(&smb_acl_group_Type);
981 : #endif
982 : #ifdef PY_ENTRY_INFO_PATCH
983 : PY_ENTRY_INFO_PATCH(&smb_acl_entry_info_Type);
984 : #endif
985 : #ifdef PY_ENTRY_PATCH
986 : PY_ENTRY_PATCH(&smb_acl_entry_Type);
987 : #endif
988 : #ifdef PY_T_PATCH
989 : PY_T_PATCH(&smb_acl_t_Type);
990 : #endif
991 : #ifdef PY_WRAPPER_PATCH
992 : PY_WRAPPER_PATCH(&smb_acl_wrapper_Type);
993 : #endif
994 :
995 4 : m = PyModule_Create(&moduledef);
996 4 : if (m == NULL)
997 0 : goto out;
998 :
999 4 : PyModule_AddObject(m, "SMB_ACL_READ", PyLong_FromUnsignedLongLong(4));
1000 4 : PyModule_AddObject(m, "SMB_ACL_WRITE", PyLong_FromUnsignedLongLong(2));
1001 4 : PyModule_AddObject(m, "SMB_ACL_EXECUTE", PyLong_FromUnsignedLongLong(1));
1002 4 : PyModule_AddObject(m, "SMB_ACL_FIRST_ENTRY", PyLong_FromUnsignedLongLong(0));
1003 4 : PyModule_AddObject(m, "SMB_ACL_NEXT_ENTRY", PyLong_FromUnsignedLongLong(1));
1004 4 : PyModule_AddObject(m, "SMB_ACL_TYPE_ACCESS", PyLong_FromUnsignedLongLong(0));
1005 4 : PyModule_AddObject(m, "SMB_ACL_TYPE_DEFAULT", PyLong_FromUnsignedLongLong(1));
1006 4 : PyModule_AddObject(m, "SMB_ACL_TAG_INVALID", PyLong_FromLong((uint16_t)(SMB_ACL_TAG_INVALID)));
1007 4 : PyModule_AddObject(m, "SMB_ACL_USER", PyLong_FromLong((uint16_t)(SMB_ACL_USER)));
1008 4 : PyModule_AddObject(m, "SMB_ACL_USER_OBJ", PyLong_FromLong((uint16_t)(SMB_ACL_USER_OBJ)));
1009 4 : PyModule_AddObject(m, "SMB_ACL_GROUP", PyLong_FromLong((uint16_t)(SMB_ACL_GROUP)));
1010 4 : PyModule_AddObject(m, "SMB_ACL_GROUP_OBJ", PyLong_FromLong((uint16_t)(SMB_ACL_GROUP_OBJ)));
1011 4 : PyModule_AddObject(m, "SMB_ACL_OTHER", PyLong_FromLong((uint16_t)(SMB_ACL_OTHER)));
1012 4 : PyModule_AddObject(m, "SMB_ACL_MASK", PyLong_FromLong((uint16_t)(SMB_ACL_MASK)));
1013 2 : Py_INCREF((PyObject *)(void *)&smb_acl_user_Type);
1014 4 : PyModule_AddObject(m, "user", (PyObject *)(void *)&smb_acl_user_Type);
1015 2 : Py_INCREF((PyObject *)(void *)&smb_acl_group_Type);
1016 4 : PyModule_AddObject(m, "group", (PyObject *)(void *)&smb_acl_group_Type);
1017 2 : Py_INCREF((PyObject *)(void *)&smb_acl_entry_info_Type);
1018 4 : PyModule_AddObject(m, "entry_info", (PyObject *)(void *)&smb_acl_entry_info_Type);
1019 2 : Py_INCREF((PyObject *)(void *)&smb_acl_entry_Type);
1020 4 : PyModule_AddObject(m, "entry", (PyObject *)(void *)&smb_acl_entry_Type);
1021 2 : Py_INCREF((PyObject *)(void *)&smb_acl_t_Type);
1022 4 : PyModule_AddObject(m, "t", (PyObject *)(void *)&smb_acl_t_Type);
1023 2 : Py_INCREF((PyObject *)(void *)&smb_acl_wrapper_Type);
1024 4 : PyModule_AddObject(m, "wrapper", (PyObject *)(void *)&smb_acl_wrapper_Type);
1025 : #ifdef PY_MOD_SMB_ACL_PATCH
1026 : PY_MOD_SMB_ACL_PATCH(m);
1027 : #endif
1028 4 : out:
1029 4 : Py_XDECREF(dep_talloc);
1030 4 : return m;
1031 :
1032 : }
|