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_smb3posix.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 : static inline _MAYBE_UNUSED_ long long ndr_sizeof2intmax(size_t var_size)
49 : {
50 : switch (var_size) {
51 : case 8:
52 : return INT64_MAX;
53 : case 4:
54 : return INT32_MAX;
55 : case 2:
56 : return INT16_MAX;
57 : case 1:
58 : return INT8_MAX;
59 : }
60 :
61 : return 0;
62 : }
63 :
64 : #include "librpc/gen_ndr/security.h"
65 : static PyTypeObject smb3_posix_cc_info_Type;
66 : static PyTypeObject smb3_file_posix_information_Type;
67 :
68 : static PyTypeObject *dom_sid_Type;
69 : static PyTypeObject *BaseObject_Type;
70 :
71 4 : static PyObject *py_smb3_posix_cc_info_get_nlinks(PyObject *obj, void *closure)
72 : {
73 4 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(obj);
74 : PyObject *py_nlinks;
75 4 : py_nlinks = PyLong_FromUnsignedLongLong((uint32_t)(object->nlinks));
76 4 : return py_nlinks;
77 : }
78 :
79 0 : static int py_smb3_posix_cc_info_set_nlinks(PyObject *py_obj, PyObject *value, void *closure)
80 : {
81 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
82 0 : if (value == NULL) {
83 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->nlinks");
84 0 : return -1;
85 : }
86 : {
87 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->nlinks));
88 0 : if (PyLong_Check(value)) {
89 : unsigned long long test_var;
90 0 : test_var = PyLong_AsUnsignedLongLong(value);
91 0 : if (PyErr_Occurred() != NULL) {
92 0 : return -1;
93 : }
94 0 : if (test_var > uint_max) {
95 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
96 : PyLong_Type.tp_name, uint_max, test_var);
97 0 : return -1;
98 : }
99 0 : object->nlinks = test_var;
100 : } else {
101 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
102 : PyLong_Type.tp_name);
103 0 : return -1;
104 : }
105 : }
106 0 : return 0;
107 : }
108 :
109 4 : static PyObject *py_smb3_posix_cc_info_get_reparse_tag(PyObject *obj, void *closure)
110 : {
111 4 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(obj);
112 : PyObject *py_reparse_tag;
113 4 : py_reparse_tag = PyLong_FromUnsignedLongLong((uint32_t)(object->reparse_tag));
114 4 : return py_reparse_tag;
115 : }
116 :
117 0 : static int py_smb3_posix_cc_info_set_reparse_tag(PyObject *py_obj, PyObject *value, void *closure)
118 : {
119 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
120 0 : if (value == NULL) {
121 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->reparse_tag");
122 0 : return -1;
123 : }
124 : {
125 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->reparse_tag));
126 0 : if (PyLong_Check(value)) {
127 : unsigned long long test_var;
128 0 : test_var = PyLong_AsUnsignedLongLong(value);
129 0 : if (PyErr_Occurred() != NULL) {
130 0 : return -1;
131 : }
132 0 : if (test_var > uint_max) {
133 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
134 : PyLong_Type.tp_name, uint_max, test_var);
135 0 : return -1;
136 : }
137 0 : object->reparse_tag = test_var;
138 : } else {
139 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
140 : PyLong_Type.tp_name);
141 0 : return -1;
142 : }
143 : }
144 0 : return 0;
145 : }
146 :
147 4 : static PyObject *py_smb3_posix_cc_info_get_posix_perms(PyObject *obj, void *closure)
148 : {
149 4 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(obj);
150 : PyObject *py_posix_perms;
151 4 : py_posix_perms = PyLong_FromUnsignedLongLong((uint32_t)(object->posix_perms));
152 4 : return py_posix_perms;
153 : }
154 :
155 0 : static int py_smb3_posix_cc_info_set_posix_perms(PyObject *py_obj, PyObject *value, void *closure)
156 : {
157 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
158 0 : if (value == NULL) {
159 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->posix_perms");
160 0 : return -1;
161 : }
162 : {
163 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->posix_perms));
164 0 : if (PyLong_Check(value)) {
165 : unsigned long long test_var;
166 0 : test_var = PyLong_AsUnsignedLongLong(value);
167 0 : if (PyErr_Occurred() != NULL) {
168 0 : return -1;
169 : }
170 0 : if (test_var > uint_max) {
171 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
172 : PyLong_Type.tp_name, uint_max, test_var);
173 0 : return -1;
174 : }
175 0 : object->posix_perms = test_var;
176 : } else {
177 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
178 : PyLong_Type.tp_name);
179 0 : return -1;
180 : }
181 : }
182 0 : return 0;
183 : }
184 :
185 4 : static PyObject *py_smb3_posix_cc_info_get_owner(PyObject *obj, void *closure)
186 : {
187 4 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(obj);
188 : PyObject *py_owner;
189 4 : py_owner = pytalloc_reference_ex(dom_sid_Type, pytalloc_get_mem_ctx(obj), &object->owner);
190 4 : return py_owner;
191 : }
192 :
193 0 : static int py_smb3_posix_cc_info_set_owner(PyObject *py_obj, PyObject *value, void *closure)
194 : {
195 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
196 0 : if (value == NULL) {
197 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->owner");
198 0 : return -1;
199 : }
200 0 : PY_CHECK_TYPE(dom_sid_Type, value, return -1;);
201 0 : if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
202 0 : PyErr_NoMemory();
203 0 : return -1;
204 : }
205 0 : object->owner = *(struct dom_sid *)pytalloc_get_ptr(value);
206 0 : return 0;
207 : }
208 :
209 4 : static PyObject *py_smb3_posix_cc_info_get_group(PyObject *obj, void *closure)
210 : {
211 4 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(obj);
212 : PyObject *py_group;
213 4 : py_group = pytalloc_reference_ex(dom_sid_Type, pytalloc_get_mem_ctx(obj), &object->group);
214 4 : return py_group;
215 : }
216 :
217 0 : static int py_smb3_posix_cc_info_set_group(PyObject *py_obj, PyObject *value, void *closure)
218 : {
219 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
220 0 : if (value == NULL) {
221 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->group");
222 0 : return -1;
223 : }
224 0 : PY_CHECK_TYPE(dom_sid_Type, value, return -1;);
225 0 : if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
226 0 : PyErr_NoMemory();
227 0 : return -1;
228 : }
229 0 : object->group = *(struct dom_sid *)pytalloc_get_ptr(value);
230 0 : return 0;
231 : }
232 :
233 : static PyGetSetDef py_smb3_posix_cc_info_getsetters[] = {
234 : {
235 : .name = discard_const_p(char, "nlinks"),
236 : .get = py_smb3_posix_cc_info_get_nlinks,
237 : .set = py_smb3_posix_cc_info_set_nlinks,
238 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
239 : },
240 : {
241 : .name = discard_const_p(char, "reparse_tag"),
242 : .get = py_smb3_posix_cc_info_get_reparse_tag,
243 : .set = py_smb3_posix_cc_info_set_reparse_tag,
244 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
245 : },
246 : {
247 : .name = discard_const_p(char, "posix_perms"),
248 : .get = py_smb3_posix_cc_info_get_posix_perms,
249 : .set = py_smb3_posix_cc_info_set_posix_perms,
250 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
251 : },
252 : {
253 : .name = discard_const_p(char, "owner"),
254 : .get = py_smb3_posix_cc_info_get_owner,
255 : .set = py_smb3_posix_cc_info_set_owner,
256 : .doc = discard_const_p(char, "PIDL-generated element of base type dom_sid")
257 : },
258 : {
259 : .name = discard_const_p(char, "group"),
260 : .get = py_smb3_posix_cc_info_get_group,
261 : .set = py_smb3_posix_cc_info_set_group,
262 : .doc = discard_const_p(char, "PIDL-generated element of base type dom_sid")
263 : },
264 : { .name = NULL }
265 : };
266 :
267 4 : static PyObject *py_smb3_posix_cc_info_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
268 : {
269 4 : return pytalloc_new(struct smb3_posix_cc_info, type);
270 : }
271 :
272 0 : static PyObject *py_smb3_posix_cc_info_ndr_pack(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
273 : {
274 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
275 0 : PyObject *ret = NULL;
276 : DATA_BLOB blob;
277 : enum ndr_err_code err;
278 0 : TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
279 0 : if (tmp_ctx == NULL) {
280 0 : PyErr_SetNdrError(NDR_ERR_ALLOC);
281 0 : return NULL;
282 : }
283 0 : err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_smb3_posix_cc_info);
284 0 : if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
285 0 : TALLOC_FREE(tmp_ctx);
286 0 : PyErr_SetNdrError(err);
287 0 : return NULL;
288 : }
289 :
290 0 : ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
291 0 : TALLOC_FREE(tmp_ctx);
292 0 : return ret;
293 : }
294 :
295 4 : static PyObject *py_smb3_posix_cc_info_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
296 : {
297 4 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
298 4 : DATA_BLOB blob = {.data = NULL, .length = 0};
299 4 : Py_ssize_t blob_length = 0;
300 : enum ndr_err_code err;
301 4 : const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
302 4 : PyObject *allow_remaining_obj = NULL;
303 4 : bool allow_remaining = false;
304 :
305 4 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
306 : discard_const_p(char *, kwnames),
307 : &blob.data, &blob_length,
308 : &allow_remaining_obj)) {
309 0 : return NULL;
310 : }
311 4 : blob.length = blob_length;
312 :
313 4 : if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
314 0 : allow_remaining = true;
315 : }
316 :
317 4 : if (allow_remaining) {
318 0 : err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_smb3_posix_cc_info);
319 : } else {
320 4 : err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_smb3_posix_cc_info);
321 : }
322 4 : if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
323 0 : PyErr_SetNdrError(err);
324 0 : return NULL;
325 : }
326 :
327 4 : Py_RETURN_NONE;
328 : }
329 :
330 0 : static PyObject *py_smb3_posix_cc_info_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
331 : {
332 0 : struct smb3_posix_cc_info *object = pytalloc_get_ptr(py_obj);
333 : PyObject *ret;
334 : char *retstr;
335 :
336 0 : retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_smb3_posix_cc_info, "smb3_posix_cc_info", object);
337 0 : ret = PyUnicode_FromString(retstr);
338 0 : talloc_free(retstr);
339 :
340 0 : return ret;
341 : }
342 :
343 : static PyMethodDef py_smb3_posix_cc_info_methods[] = {
344 : { "__ndr_pack__", (PyCFunction)py_smb3_posix_cc_info_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
345 : { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_smb3_posix_cc_info_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
346 : { "__ndr_print__", (PyCFunction)py_smb3_posix_cc_info_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
347 : { NULL, NULL, 0, NULL }
348 : };
349 :
350 :
351 : static PyTypeObject smb3_posix_cc_info_Type = {
352 : PyVarObject_HEAD_INIT(NULL, 0)
353 : .tp_name = "smb3posix.smb3_posix_cc_info",
354 : .tp_getset = py_smb3_posix_cc_info_getsetters,
355 : .tp_methods = py_smb3_posix_cc_info_methods,
356 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
357 : .tp_new = py_smb3_posix_cc_info_new,
358 : };
359 :
360 :
361 0 : static PyObject *py_smb3_file_posix_information_get_creation_time(PyObject *obj, void *closure)
362 : {
363 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
364 : PyObject *py_creation_time;
365 0 : py_creation_time = PyLong_FromUnsignedLongLong(object->creation_time);
366 0 : return py_creation_time;
367 : }
368 :
369 0 : static int py_smb3_file_posix_information_set_creation_time(PyObject *py_obj, PyObject *value, void *closure)
370 : {
371 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
372 0 : if (value == NULL) {
373 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->creation_time");
374 0 : return -1;
375 : }
376 : {
377 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->creation_time));
378 0 : if (PyLong_Check(value)) {
379 : unsigned long long test_var;
380 0 : test_var = PyLong_AsUnsignedLongLong(value);
381 0 : if (PyErr_Occurred() != NULL) {
382 0 : return -1;
383 : }
384 0 : if (test_var > uint_max) {
385 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
386 : PyLong_Type.tp_name, uint_max, test_var);
387 0 : return -1;
388 : }
389 0 : object->creation_time = test_var;
390 : } else {
391 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
392 : PyLong_Type.tp_name);
393 0 : return -1;
394 : }
395 : }
396 0 : return 0;
397 : }
398 :
399 0 : static PyObject *py_smb3_file_posix_information_get_last_access_time(PyObject *obj, void *closure)
400 : {
401 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
402 : PyObject *py_last_access_time;
403 0 : py_last_access_time = PyLong_FromUnsignedLongLong(object->last_access_time);
404 0 : return py_last_access_time;
405 : }
406 :
407 0 : static int py_smb3_file_posix_information_set_last_access_time(PyObject *py_obj, PyObject *value, void *closure)
408 : {
409 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
410 0 : if (value == NULL) {
411 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->last_access_time");
412 0 : return -1;
413 : }
414 : {
415 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->last_access_time));
416 0 : if (PyLong_Check(value)) {
417 : unsigned long long test_var;
418 0 : test_var = PyLong_AsUnsignedLongLong(value);
419 0 : if (PyErr_Occurred() != NULL) {
420 0 : return -1;
421 : }
422 0 : if (test_var > uint_max) {
423 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
424 : PyLong_Type.tp_name, uint_max, test_var);
425 0 : return -1;
426 : }
427 0 : object->last_access_time = test_var;
428 : } else {
429 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
430 : PyLong_Type.tp_name);
431 0 : return -1;
432 : }
433 : }
434 0 : return 0;
435 : }
436 :
437 0 : static PyObject *py_smb3_file_posix_information_get_last_write_time(PyObject *obj, void *closure)
438 : {
439 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
440 : PyObject *py_last_write_time;
441 0 : py_last_write_time = PyLong_FromUnsignedLongLong(object->last_write_time);
442 0 : return py_last_write_time;
443 : }
444 :
445 0 : static int py_smb3_file_posix_information_set_last_write_time(PyObject *py_obj, PyObject *value, void *closure)
446 : {
447 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
448 0 : if (value == NULL) {
449 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->last_write_time");
450 0 : return -1;
451 : }
452 : {
453 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->last_write_time));
454 0 : if (PyLong_Check(value)) {
455 : unsigned long long test_var;
456 0 : test_var = PyLong_AsUnsignedLongLong(value);
457 0 : if (PyErr_Occurred() != NULL) {
458 0 : return -1;
459 : }
460 0 : if (test_var > uint_max) {
461 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
462 : PyLong_Type.tp_name, uint_max, test_var);
463 0 : return -1;
464 : }
465 0 : object->last_write_time = test_var;
466 : } else {
467 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
468 : PyLong_Type.tp_name);
469 0 : return -1;
470 : }
471 : }
472 0 : return 0;
473 : }
474 :
475 0 : static PyObject *py_smb3_file_posix_information_get_change_time(PyObject *obj, void *closure)
476 : {
477 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
478 : PyObject *py_change_time;
479 0 : py_change_time = PyLong_FromUnsignedLongLong(object->change_time);
480 0 : return py_change_time;
481 : }
482 :
483 0 : static int py_smb3_file_posix_information_set_change_time(PyObject *py_obj, PyObject *value, void *closure)
484 : {
485 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
486 0 : if (value == NULL) {
487 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->change_time");
488 0 : return -1;
489 : }
490 : {
491 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->change_time));
492 0 : if (PyLong_Check(value)) {
493 : unsigned long long test_var;
494 0 : test_var = PyLong_AsUnsignedLongLong(value);
495 0 : if (PyErr_Occurred() != NULL) {
496 0 : return -1;
497 : }
498 0 : if (test_var > uint_max) {
499 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
500 : PyLong_Type.tp_name, uint_max, test_var);
501 0 : return -1;
502 : }
503 0 : object->change_time = test_var;
504 : } else {
505 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
506 : PyLong_Type.tp_name);
507 0 : return -1;
508 : }
509 : }
510 0 : return 0;
511 : }
512 :
513 0 : static PyObject *py_smb3_file_posix_information_get_end_of_file(PyObject *obj, void *closure)
514 : {
515 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
516 : PyObject *py_end_of_file;
517 0 : py_end_of_file = PyLong_FromUnsignedLongLong(object->end_of_file);
518 0 : return py_end_of_file;
519 : }
520 :
521 0 : static int py_smb3_file_posix_information_set_end_of_file(PyObject *py_obj, PyObject *value, void *closure)
522 : {
523 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
524 0 : if (value == NULL) {
525 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->end_of_file");
526 0 : return -1;
527 : }
528 : {
529 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->end_of_file));
530 0 : if (PyLong_Check(value)) {
531 : unsigned long long test_var;
532 0 : test_var = PyLong_AsUnsignedLongLong(value);
533 0 : if (PyErr_Occurred() != NULL) {
534 0 : return -1;
535 : }
536 0 : if (test_var > uint_max) {
537 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
538 : PyLong_Type.tp_name, uint_max, test_var);
539 0 : return -1;
540 : }
541 0 : object->end_of_file = test_var;
542 : } else {
543 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
544 : PyLong_Type.tp_name);
545 0 : return -1;
546 : }
547 : }
548 0 : return 0;
549 : }
550 :
551 0 : static PyObject *py_smb3_file_posix_information_get_allocation_size(PyObject *obj, void *closure)
552 : {
553 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
554 : PyObject *py_allocation_size;
555 0 : py_allocation_size = PyLong_FromUnsignedLongLong(object->allocation_size);
556 0 : return py_allocation_size;
557 : }
558 :
559 0 : static int py_smb3_file_posix_information_set_allocation_size(PyObject *py_obj, PyObject *value, void *closure)
560 : {
561 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
562 0 : if (value == NULL) {
563 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->allocation_size");
564 0 : return -1;
565 : }
566 : {
567 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->allocation_size));
568 0 : if (PyLong_Check(value)) {
569 : unsigned long long test_var;
570 0 : test_var = PyLong_AsUnsignedLongLong(value);
571 0 : if (PyErr_Occurred() != NULL) {
572 0 : return -1;
573 : }
574 0 : if (test_var > uint_max) {
575 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
576 : PyLong_Type.tp_name, uint_max, test_var);
577 0 : return -1;
578 : }
579 0 : object->allocation_size = test_var;
580 : } else {
581 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
582 : PyLong_Type.tp_name);
583 0 : return -1;
584 : }
585 : }
586 0 : return 0;
587 : }
588 :
589 0 : static PyObject *py_smb3_file_posix_information_get_file_attributes(PyObject *obj, void *closure)
590 : {
591 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
592 : PyObject *py_file_attributes;
593 0 : py_file_attributes = PyLong_FromUnsignedLongLong((uint32_t)(object->file_attributes));
594 0 : return py_file_attributes;
595 : }
596 :
597 0 : static int py_smb3_file_posix_information_set_file_attributes(PyObject *py_obj, PyObject *value, void *closure)
598 : {
599 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
600 0 : if (value == NULL) {
601 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->file_attributes");
602 0 : return -1;
603 : }
604 : {
605 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->file_attributes));
606 0 : if (PyLong_Check(value)) {
607 : unsigned long long test_var;
608 0 : test_var = PyLong_AsUnsignedLongLong(value);
609 0 : if (PyErr_Occurred() != NULL) {
610 0 : return -1;
611 : }
612 0 : if (test_var > uint_max) {
613 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
614 : PyLong_Type.tp_name, uint_max, test_var);
615 0 : return -1;
616 : }
617 0 : object->file_attributes = test_var;
618 : } else {
619 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
620 : PyLong_Type.tp_name);
621 0 : return -1;
622 : }
623 : }
624 0 : return 0;
625 : }
626 :
627 0 : static PyObject *py_smb3_file_posix_information_get_inode(PyObject *obj, void *closure)
628 : {
629 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
630 : PyObject *py_inode;
631 0 : py_inode = PyLong_FromUnsignedLongLong(object->inode);
632 0 : return py_inode;
633 : }
634 :
635 0 : static int py_smb3_file_posix_information_set_inode(PyObject *py_obj, PyObject *value, void *closure)
636 : {
637 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
638 0 : if (value == NULL) {
639 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->inode");
640 0 : return -1;
641 : }
642 : {
643 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->inode));
644 0 : if (PyLong_Check(value)) {
645 : unsigned long long test_var;
646 0 : test_var = PyLong_AsUnsignedLongLong(value);
647 0 : if (PyErr_Occurred() != NULL) {
648 0 : return -1;
649 : }
650 0 : if (test_var > uint_max) {
651 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
652 : PyLong_Type.tp_name, uint_max, test_var);
653 0 : return -1;
654 : }
655 0 : object->inode = test_var;
656 : } else {
657 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
658 : PyLong_Type.tp_name);
659 0 : return -1;
660 : }
661 : }
662 0 : return 0;
663 : }
664 :
665 0 : static PyObject *py_smb3_file_posix_information_get_device(PyObject *obj, void *closure)
666 : {
667 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
668 : PyObject *py_device;
669 0 : py_device = PyLong_FromUnsignedLongLong((uint32_t)(object->device));
670 0 : return py_device;
671 : }
672 :
673 0 : static int py_smb3_file_posix_information_set_device(PyObject *py_obj, PyObject *value, void *closure)
674 : {
675 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
676 0 : if (value == NULL) {
677 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->device");
678 0 : return -1;
679 : }
680 : {
681 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->device));
682 0 : if (PyLong_Check(value)) {
683 : unsigned long long test_var;
684 0 : test_var = PyLong_AsUnsignedLongLong(value);
685 0 : if (PyErr_Occurred() != NULL) {
686 0 : return -1;
687 : }
688 0 : if (test_var > uint_max) {
689 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
690 : PyLong_Type.tp_name, uint_max, test_var);
691 0 : return -1;
692 : }
693 0 : object->device = test_var;
694 : } else {
695 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
696 : PyLong_Type.tp_name);
697 0 : return -1;
698 : }
699 : }
700 0 : return 0;
701 : }
702 :
703 0 : static PyObject *py_smb3_file_posix_information_get_reserved(PyObject *obj, void *closure)
704 : {
705 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
706 : PyObject *py_reserved;
707 0 : py_reserved = PyLong_FromUnsignedLongLong((uint32_t)(object->reserved));
708 0 : return py_reserved;
709 : }
710 :
711 0 : static int py_smb3_file_posix_information_set_reserved(PyObject *py_obj, PyObject *value, void *closure)
712 : {
713 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
714 0 : if (value == NULL) {
715 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->reserved");
716 0 : return -1;
717 : }
718 : {
719 0 : const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->reserved));
720 0 : if (PyLong_Check(value)) {
721 : unsigned long long test_var;
722 0 : test_var = PyLong_AsUnsignedLongLong(value);
723 0 : if (PyErr_Occurred() != NULL) {
724 0 : return -1;
725 : }
726 0 : if (test_var > uint_max) {
727 0 : PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
728 : PyLong_Type.tp_name, uint_max, test_var);
729 0 : return -1;
730 : }
731 0 : object->reserved = test_var;
732 : } else {
733 0 : PyErr_Format(PyExc_TypeError, "Expected type %s",
734 : PyLong_Type.tp_name);
735 0 : return -1;
736 : }
737 : }
738 0 : return 0;
739 : }
740 :
741 0 : static PyObject *py_smb3_file_posix_information_get_cc(PyObject *obj, void *closure)
742 : {
743 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(obj);
744 : PyObject *py_cc;
745 0 : py_cc = pytalloc_reference_ex(&smb3_posix_cc_info_Type, pytalloc_get_mem_ctx(obj), &object->cc);
746 0 : return py_cc;
747 : }
748 :
749 0 : static int py_smb3_file_posix_information_set_cc(PyObject *py_obj, PyObject *value, void *closure)
750 : {
751 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
752 0 : if (value == NULL) {
753 0 : PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->cc");
754 0 : return -1;
755 : }
756 0 : PY_CHECK_TYPE(&smb3_posix_cc_info_Type, value, return -1;);
757 0 : if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
758 0 : PyErr_NoMemory();
759 0 : return -1;
760 : }
761 0 : object->cc = *(struct smb3_posix_cc_info *)pytalloc_get_ptr(value);
762 0 : return 0;
763 : }
764 :
765 : static PyGetSetDef py_smb3_file_posix_information_getsetters[] = {
766 : {
767 : .name = discard_const_p(char, "creation_time"),
768 : .get = py_smb3_file_posix_information_get_creation_time,
769 : .set = py_smb3_file_posix_information_set_creation_time,
770 : .doc = discard_const_p(char, "PIDL-generated element of base type NTTIME")
771 : },
772 : {
773 : .name = discard_const_p(char, "last_access_time"),
774 : .get = py_smb3_file_posix_information_get_last_access_time,
775 : .set = py_smb3_file_posix_information_set_last_access_time,
776 : .doc = discard_const_p(char, "PIDL-generated element of base type NTTIME")
777 : },
778 : {
779 : .name = discard_const_p(char, "last_write_time"),
780 : .get = py_smb3_file_posix_information_get_last_write_time,
781 : .set = py_smb3_file_posix_information_set_last_write_time,
782 : .doc = discard_const_p(char, "PIDL-generated element of base type NTTIME")
783 : },
784 : {
785 : .name = discard_const_p(char, "change_time"),
786 : .get = py_smb3_file_posix_information_get_change_time,
787 : .set = py_smb3_file_posix_information_set_change_time,
788 : .doc = discard_const_p(char, "PIDL-generated element of base type NTTIME")
789 : },
790 : {
791 : .name = discard_const_p(char, "end_of_file"),
792 : .get = py_smb3_file_posix_information_get_end_of_file,
793 : .set = py_smb3_file_posix_information_set_end_of_file,
794 : .doc = discard_const_p(char, "PIDL-generated element of base type hyper")
795 : },
796 : {
797 : .name = discard_const_p(char, "allocation_size"),
798 : .get = py_smb3_file_posix_information_get_allocation_size,
799 : .set = py_smb3_file_posix_information_set_allocation_size,
800 : .doc = discard_const_p(char, "PIDL-generated element of base type hyper")
801 : },
802 : {
803 : .name = discard_const_p(char, "file_attributes"),
804 : .get = py_smb3_file_posix_information_get_file_attributes,
805 : .set = py_smb3_file_posix_information_set_file_attributes,
806 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
807 : },
808 : {
809 : .name = discard_const_p(char, "inode"),
810 : .get = py_smb3_file_posix_information_get_inode,
811 : .set = py_smb3_file_posix_information_set_inode,
812 : .doc = discard_const_p(char, "PIDL-generated element of base type hyper")
813 : },
814 : {
815 : .name = discard_const_p(char, "device"),
816 : .get = py_smb3_file_posix_information_get_device,
817 : .set = py_smb3_file_posix_information_set_device,
818 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
819 : },
820 : {
821 : .name = discard_const_p(char, "reserved"),
822 : .get = py_smb3_file_posix_information_get_reserved,
823 : .set = py_smb3_file_posix_information_set_reserved,
824 : .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
825 : },
826 : {
827 : .name = discard_const_p(char, "cc"),
828 : .get = py_smb3_file_posix_information_get_cc,
829 : .set = py_smb3_file_posix_information_set_cc,
830 : .doc = discard_const_p(char, "PIDL-generated element of base type smb3_posix_cc_info")
831 : },
832 : { .name = NULL }
833 : };
834 :
835 0 : static PyObject *py_smb3_file_posix_information_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
836 : {
837 0 : return pytalloc_new(struct smb3_file_posix_information, type);
838 : }
839 :
840 0 : static PyObject *py_smb3_file_posix_information_ndr_pack(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
841 : {
842 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
843 0 : PyObject *ret = NULL;
844 : DATA_BLOB blob;
845 : enum ndr_err_code err;
846 0 : TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
847 0 : if (tmp_ctx == NULL) {
848 0 : PyErr_SetNdrError(NDR_ERR_ALLOC);
849 0 : return NULL;
850 : }
851 0 : err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_smb3_file_posix_information);
852 0 : if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
853 0 : TALLOC_FREE(tmp_ctx);
854 0 : PyErr_SetNdrError(err);
855 0 : return NULL;
856 : }
857 :
858 0 : ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
859 0 : TALLOC_FREE(tmp_ctx);
860 0 : return ret;
861 : }
862 :
863 0 : static PyObject *py_smb3_file_posix_information_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
864 : {
865 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
866 0 : DATA_BLOB blob = {.data = NULL, .length = 0};
867 0 : Py_ssize_t blob_length = 0;
868 : enum ndr_err_code err;
869 0 : const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
870 0 : PyObject *allow_remaining_obj = NULL;
871 0 : bool allow_remaining = false;
872 :
873 0 : if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
874 : discard_const_p(char *, kwnames),
875 : &blob.data, &blob_length,
876 : &allow_remaining_obj)) {
877 0 : return NULL;
878 : }
879 0 : blob.length = blob_length;
880 :
881 0 : if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
882 0 : allow_remaining = true;
883 : }
884 :
885 0 : if (allow_remaining) {
886 0 : err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_smb3_file_posix_information);
887 : } else {
888 0 : err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_smb3_file_posix_information);
889 : }
890 0 : if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
891 0 : PyErr_SetNdrError(err);
892 0 : return NULL;
893 : }
894 :
895 0 : Py_RETURN_NONE;
896 : }
897 :
898 0 : static PyObject *py_smb3_file_posix_information_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
899 : {
900 0 : struct smb3_file_posix_information *object = pytalloc_get_ptr(py_obj);
901 : PyObject *ret;
902 : char *retstr;
903 :
904 0 : retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_smb3_file_posix_information, "smb3_file_posix_information", object);
905 0 : ret = PyUnicode_FromString(retstr);
906 0 : talloc_free(retstr);
907 :
908 0 : return ret;
909 : }
910 :
911 : static PyMethodDef py_smb3_file_posix_information_methods[] = {
912 : { "__ndr_pack__", (PyCFunction)py_smb3_file_posix_information_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
913 : { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_smb3_file_posix_information_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
914 : { "__ndr_print__", (PyCFunction)py_smb3_file_posix_information_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
915 : { NULL, NULL, 0, NULL }
916 : };
917 :
918 :
919 : static PyTypeObject smb3_file_posix_information_Type = {
920 : PyVarObject_HEAD_INIT(NULL, 0)
921 : .tp_name = "smb3posix.smb3_file_posix_information",
922 : .tp_getset = py_smb3_file_posix_information_getsetters,
923 : .tp_methods = py_smb3_file_posix_information_methods,
924 : .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
925 : .tp_new = py_smb3_file_posix_information_new,
926 : };
927 :
928 : static PyMethodDef smb3posix_methods[] = {
929 : { NULL, NULL, 0, NULL }
930 : };
931 :
932 : static struct PyModuleDef moduledef = {
933 : PyModuleDef_HEAD_INIT,
934 : .m_name = "smb3posix",
935 : .m_doc = "smb3posix DCE/RPC",
936 : .m_size = -1,
937 : .m_methods = smb3posix_methods,
938 : };
939 2 : MODULE_INIT_FUNC(smb3posix)
940 : {
941 2 : PyObject *m = NULL;
942 2 : PyObject *dep_samba_dcerpc_security = NULL;
943 2 : PyObject *dep_talloc = NULL;
944 :
945 2 : dep_samba_dcerpc_security = PyImport_ImportModule("samba.dcerpc.security");
946 2 : if (dep_samba_dcerpc_security == NULL)
947 0 : goto out;
948 :
949 2 : dep_talloc = PyImport_ImportModule("talloc");
950 2 : if (dep_talloc == NULL)
951 0 : goto out;
952 :
953 2 : dom_sid_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_security, "dom_sid");
954 2 : if (dom_sid_Type == NULL)
955 0 : goto out;
956 :
957 2 : BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
958 2 : if (BaseObject_Type == NULL)
959 0 : goto out;
960 :
961 2 : smb3_posix_cc_info_Type.tp_base = BaseObject_Type;
962 2 : smb3_posix_cc_info_Type.tp_basicsize = pytalloc_BaseObject_size();
963 :
964 2 : smb3_file_posix_information_Type.tp_base = BaseObject_Type;
965 2 : smb3_file_posix_information_Type.tp_basicsize = pytalloc_BaseObject_size();
966 :
967 2 : if (PyType_Ready(&smb3_posix_cc_info_Type) < 0)
968 0 : goto out;
969 2 : if (PyType_Ready(&smb3_file_posix_information_Type) < 0)
970 0 : goto out;
971 : #ifdef PY_SMB3_POSIX_CC_INFO_PATCH
972 : PY_SMB3_POSIX_CC_INFO_PATCH(&smb3_posix_cc_info_Type);
973 : #endif
974 : #ifdef PY_SMB3_FILE_POSIX_INFORMATION_PATCH
975 : PY_SMB3_FILE_POSIX_INFORMATION_PATCH(&smb3_file_posix_information_Type);
976 : #endif
977 :
978 2 : m = PyModule_Create(&moduledef);
979 2 : if (m == NULL)
980 0 : goto out;
981 :
982 2 : Py_INCREF((PyObject *)(void *)&smb3_posix_cc_info_Type);
983 2 : PyModule_AddObject(m, "smb3_posix_cc_info", (PyObject *)(void *)&smb3_posix_cc_info_Type);
984 2 : Py_INCREF((PyObject *)(void *)&smb3_file_posix_information_Type);
985 2 : PyModule_AddObject(m, "smb3_file_posix_information", (PyObject *)(void *)&smb3_file_posix_information_Type);
986 : #ifdef PY_MOD_SMB3POSIX_PATCH
987 : PY_MOD_SMB3POSIX_PATCH(m);
988 : #endif
989 2 : out:
990 2 : Py_XDECREF(dep_samba_dcerpc_security);
991 2 : Py_XDECREF(dep_talloc);
992 2 : return m;
993 :
994 : }
|