Changeset 745 for trunk/server/source4/scripting/python/pyglue.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/scripting/python/pyglue.c
r414 r745 18 18 */ 19 19 20 #include <Python.h> 20 21 #include "includes.h" 21 #include "ldb.h"22 #include "ldb_errors.h"23 #include "ldb_wrap.h"24 #include "param/param.h"25 #include "auth/credentials/credentials.h"26 #include "dsdb/samdb/samdb.h"27 #include "lib/ldb-samba/ldif_handlers.h"28 #include "librpc/ndr/libndr.h"29 22 #include "version.h" 30 #include <Python.h>31 #include "lib/ldb/pyldb.h"32 #include "libcli/util/pyerrors.h"33 #include "libcli/security/security.h"34 #include "auth/pyauth.h"35 23 #include "param/pyparam.h" 36 #include "auth/credentials/pycredentials.h" 37 38 #ifndef Py_RETURN_NONE 39 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None 40 #endif 41 42 /* FIXME: These should be in a header file somewhere, once we finish moving 43 * away from SWIG .. */ 44 #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \ 45 /* if (!PyLdb_Check(py_ldb)) { \ 46 PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \ 47 return NULL; \ 48 } */\ 49 ldb = PyLdb_AsLdbContext(py_ldb); 50 51 static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ctx) 52 { 53 if (ret == LDB_ERR_PYTHON_EXCEPTION) 54 return; /* Python exception should already be set, just keep that */ 55 56 PyErr_SetObject(error, 57 Py_BuildValue(discard_const_p(char, "(i,s)"), ret, 58 ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); 59 } 60 61 static PyObject *py_ldb_get_exception(void) 62 { 63 PyObject *mod = PyImport_ImportModule("ldb"); 64 if (mod == NULL) 65 return NULL; 66 67 return PyObject_GetAttrString(mod, "LdbError"); 68 } 24 #include "lib/socket/netif.h" 25 26 void init_glue(void); 69 27 70 28 static PyObject *py_generate_random_str(PyObject *self, PyObject *args) … … 82 40 } 83 41 42 static PyObject *py_generate_random_password(PyObject *self, PyObject *args) 43 { 44 int min, max; 45 PyObject *ret; 46 char *retstr; 47 if (!PyArg_ParseTuple(args, "ii", &min, &max)) 48 return NULL; 49 50 retstr = generate_random_password(NULL, min, max); 51 if (retstr == NULL) { 52 return NULL; 53 } 54 ret = PyString_FromString(retstr); 55 talloc_free(retstr); 56 return ret; 57 } 58 84 59 static PyObject *py_unix2nttime(PyObject *self, PyObject *args) 85 60 { … … 91 66 unix_to_nt_time(&nt, t); 92 67 93 return PyInt_FromLong((uint64_t)nt); 68 return PyLong_FromLongLong((uint64_t)nt); 69 } 70 71 static PyObject *py_nttime2unix(PyObject *self, PyObject *args) 72 { 73 time_t t; 74 NTTIME nt; 75 if (!PyArg_ParseTuple(args, "K", &nt)) 76 return NULL; 77 78 t = nt_time_to_unix(nt); 79 80 return PyInt_FromLong((uint64_t)t); 81 } 82 83 static PyObject *py_nttime2string(PyObject *self, PyObject *args) 84 { 85 PyObject *ret; 86 NTTIME nt; 87 TALLOC_CTX *tmp_ctx; 88 const char *string; 89 if (!PyArg_ParseTuple(args, "K", &nt)) 90 return NULL; 91 92 tmp_ctx = talloc_new(NULL); 93 if (tmp_ctx == NULL) { 94 PyErr_NoMemory(); 95 return NULL; 96 } 97 98 string = nt_time_string(tmp_ctx, nt); 99 ret = PyString_FromString(string); 100 101 talloc_free(tmp_ctx); 102 103 return ret; 94 104 } 95 105 … … 103 113 } 104 114 105 static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args) 106 { 107 PyObject *py_creds, *py_ldb; 108 struct cli_credentials *creds; 109 struct ldb_context *ldb; 110 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_creds)) 111 return NULL; 112 113 PyErr_LDB_OR_RAISE(py_ldb, ldb); 114 115 creds = cli_credentials_from_py_object(py_creds); 116 if (creds == NULL) { 117 PyErr_SetString(PyExc_TypeError, "Expected credentials object"); 118 return NULL; 119 } 120 121 ldb_set_opaque(ldb, "credentials", creds); 122 123 Py_RETURN_NONE; 124 } 125 126 static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args) 127 { 128 PyObject *py_lp_ctx, *py_ldb; 115 static PyObject *py_get_debug_level(PyObject *self) 116 { 117 return PyInt_FromLong(DEBUGLEVEL); 118 } 119 120 /* 121 return the list of interface IPs we have configured 122 takes an loadparm context, returns a list of IPs in string form 123 124 Does not return addresses on 127.0.0.0/8 125 */ 126 static PyObject *py_interface_ips(PyObject *self, PyObject *args) 127 { 128 PyObject *pylist; 129 int count; 130 TALLOC_CTX *tmp_ctx; 131 PyObject *py_lp_ctx; 129 132 struct loadparm_context *lp_ctx; 130 struct ldb_context *ldb; 131 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_lp_ctx)) 132 return NULL; 133 134 PyErr_LDB_OR_RAISE(py_ldb, ldb); 135 136 lp_ctx = lp_from_py_object(py_lp_ctx); 133 struct interface *ifaces; 134 int i, ifcount; 135 int all_interfaces; 136 137 if (!PyArg_ParseTuple(args, "Oi", &py_lp_ctx, &all_interfaces)) 138 return NULL; 139 140 tmp_ctx = talloc_new(NULL); 141 if (tmp_ctx == NULL) { 142 PyErr_NoMemory(); 143 return NULL; 144 } 145 146 lp_ctx = lpcfg_from_py_object(tmp_ctx, py_lp_ctx); 137 147 if (lp_ctx == NULL) { 138 PyErr_SetString(PyExc_TypeError, "Expected loadparm object"); 139 return NULL; 140 } 141 142 ldb_set_opaque(ldb, "loadparm", lp_ctx); 143 144 Py_RETURN_NONE; 145 } 146 147 148 static PyObject *py_ldb_set_session_info(PyObject *self, PyObject *args) 149 { 150 PyObject *py_session_info, *py_ldb; 151 struct auth_session_info *info; 152 struct ldb_context *ldb; 153 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_session_info)) 154 return NULL; 155 156 PyErr_LDB_OR_RAISE(py_ldb, ldb); 157 /*if (!PyAuthSession_Check(py_session_info)) { 158 PyErr_SetString(PyExc_TypeError, "Expected session info object"); 159 return NULL; 160 }*/ 161 162 info = PyAuthSession_AsSession(py_session_info); 163 164 ldb_set_opaque(ldb, "sessionInfo", info); 165 166 Py_RETURN_NONE; 167 } 168 169 static PyObject *py_ldb_set_utf8_casefold(PyObject *self, PyObject *args) 170 { 171 PyObject *py_ldb; 172 struct ldb_context *ldb; 173 174 if (!PyArg_ParseTuple(args, "O", &py_ldb)) 175 return NULL; 176 177 PyErr_LDB_OR_RAISE(py_ldb, ldb); 178 179 ldb_set_utf8_fns(ldb, NULL, wrap_casefold); 180 181 Py_RETURN_NONE; 182 } 183 184 static PyObject *py_samdb_set_domain_sid(PyLdbObject *self, PyObject *args) 185 { 186 PyObject *py_ldb, *py_sid; 187 struct ldb_context *ldb; 188 struct dom_sid *sid; 189 bool ret; 190 191 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_sid)) 192 return NULL; 193 194 PyErr_LDB_OR_RAISE(py_ldb, ldb); 195 196 sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid)); 197 198 ret = samdb_set_domain_sid(ldb, sid); 199 if (!ret) { 200 PyErr_SetString(PyExc_RuntimeError, "set_domain_sid failed"); 201 return NULL; 202 } 203 Py_RETURN_NONE; 204 } 205 206 static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args) 207 { 208 PyObject *py_ldb; 209 struct ldb_context *ldb; 210 const struct dom_sid *sid; 211 PyObject *ret; 212 char *retstr; 213 214 if (!PyArg_ParseTuple(args, "O", &py_ldb)) 215 return NULL; 216 217 PyErr_LDB_OR_RAISE(py_ldb, ldb); 218 219 sid = samdb_domain_sid(ldb); 220 if (!sid) { 221 PyErr_SetString(PyExc_RuntimeError, "samdb_domain_sid failed"); 222 return NULL; 223 } 224 retstr = dom_sid_string(NULL, sid); 225 ret = PyString_FromString(retstr); 226 talloc_free(retstr); 227 return ret; 228 } 229 230 static PyObject *py_ldb_register_samba_handlers(PyObject *self, PyObject *args) 231 { 232 PyObject *py_ldb; 233 struct ldb_context *ldb; 234 int ret; 235 236 if (!PyArg_ParseTuple(args, "O", &py_ldb)) 237 return NULL; 238 239 PyErr_LDB_OR_RAISE(py_ldb, ldb); 240 ret = ldb_register_samba_handlers(ldb); 241 242 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb); 243 Py_RETURN_NONE; 244 } 245 246 static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args) 247 { 248 PyObject *py_ldb, *py_guid; 249 bool ret; 250 struct GUID guid; 251 struct ldb_context *ldb; 252 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_guid)) 253 return NULL; 254 255 PyErr_LDB_OR_RAISE(py_ldb, ldb); 256 GUID_from_string(PyString_AsString(py_guid), &guid); 257 258 ret = samdb_set_ntds_invocation_id(ldb, &guid); 259 if (!ret) { 260 PyErr_SetString(PyExc_RuntimeError, "set_ntds_invocation_id failed"); 261 return NULL; 262 } 263 Py_RETURN_NONE; 264 } 265 266 static PyObject *py_dsdb_set_opaque_integer(PyObject *self, PyObject *args) 267 { 268 PyObject *py_ldb; 269 int value; 270 int *old_val, *new_val; 271 char *py_opaque_name, *opaque_name_talloc; 272 struct ldb_context *ldb; 273 TALLOC_CTX *tmp_ctx; 274 275 if (!PyArg_ParseTuple(args, "Osi", &py_ldb, &py_opaque_name, &value)) 276 return NULL; 277 278 PyErr_LDB_OR_RAISE(py_ldb, ldb); 279 280 /* see if we have a cached copy */ 281 old_val = (int *)ldb_get_opaque(ldb, 282 py_opaque_name); 283 284 if (old_val) { 285 *old_val = value; 286 Py_RETURN_NONE; 287 } 288 289 tmp_ctx = talloc_new(ldb); 290 if (tmp_ctx == NULL) { 291 goto failed; 292 } 293 294 new_val = talloc(tmp_ctx, int); 295 if (!new_val) { 296 goto failed; 297 } 298 299 opaque_name_talloc = talloc_strdup(tmp_ctx, py_opaque_name); 300 if (!opaque_name_talloc) { 301 goto failed; 302 } 303 304 *new_val = value; 305 306 /* cache the domain_sid in the ldb */ 307 if (ldb_set_opaque(ldb, opaque_name_talloc, new_val) != LDB_SUCCESS) { 308 goto failed; 309 } 310 311 talloc_steal(ldb, new_val); 312 talloc_steal(ldb, opaque_name_talloc); 148 talloc_free(tmp_ctx); 149 return NULL; 150 } 151 152 load_interfaces(tmp_ctx, lpcfg_interfaces(lp_ctx), &ifaces); 153 154 count = iface_count(ifaces); 155 156 /* first count how many are not loopback addresses */ 157 for (ifcount = i = 0; i<count; i++) { 158 const char *ip = iface_n_ip(ifaces, i); 159 if (!(!all_interfaces && iface_same_net(ip, "127.0.0.1", "255.0.0.0"))) { 160 ifcount++; 161 } 162 } 163 164 pylist = PyList_New(ifcount); 165 for (ifcount = i = 0; i<count; i++) { 166 const char *ip = iface_n_ip(ifaces, i); 167 if (!(!all_interfaces && iface_same_net(ip, "127.0.0.1", "255.0.0.0"))) { 168 PyList_SetItem(pylist, ifcount, PyString_FromString(ip)); 169 ifcount++; 170 } 171 } 313 172 talloc_free(tmp_ctx); 314 315 Py_RETURN_NONE; 316 317 failed: 318 talloc_free(tmp_ctx); 319 PyErr_SetString(PyExc_RuntimeError, "Failed to set opaque integer into the ldb!\n"); 320 return NULL; 321 } 322 323 static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args) 324 { 325 PyObject *py_ldb; 326 struct ldb_context *ldb; 327 int ret; 328 if (!PyArg_ParseTuple(args, "O", &py_ldb)) 329 return NULL; 330 331 PyErr_LDB_OR_RAISE(py_ldb, ldb); 332 333 ret = dsdb_set_global_schema(ldb); 334 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb); 335 336 Py_RETURN_NONE; 337 } 338 339 static PyObject *py_dsdb_set_schema_from_ldif(PyObject *self, PyObject *args) 340 { 341 WERROR result; 342 char *pf, *df; 343 PyObject *py_ldb; 344 struct ldb_context *ldb; 345 346 if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &pf, &df)) 347 return NULL; 348 349 PyErr_LDB_OR_RAISE(py_ldb, ldb); 350 351 result = dsdb_set_schema_from_ldif(ldb, pf, df); 352 PyErr_WERROR_IS_ERR_RAISE(result); 353 354 Py_RETURN_NONE; 355 } 356 357 static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self, PyObject *args) 358 { 359 char *target_str, *mapping; 360 PyObject *py_ldb; 361 struct ldb_context *ldb; 362 PyObject *ret; 363 char *retstr; 364 365 if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &target_str, &mapping)) 366 return NULL; 367 368 PyErr_LDB_OR_RAISE(py_ldb, ldb); 369 370 retstr = dsdb_convert_schema_to_openldap(ldb, target_str, mapping); 371 if (!retstr) { 372 PyErr_SetString(PyExc_RuntimeError, "dsdb_convert_schema_to_openldap failed"); 373 return NULL; 374 } 375 ret = PyString_FromString(retstr); 376 talloc_free(retstr); 377 return ret; 378 } 379 380 static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObject *args) 381 { 382 PyObject *py_ldb; 383 struct ldb_context *ldb; 384 WERROR result; 385 struct dsdb_schema *schema; 386 387 if (!PyArg_ParseTuple(args, "O", &py_ldb)) 388 return NULL; 389 390 PyErr_LDB_OR_RAISE(py_ldb, ldb); 391 392 schema = dsdb_get_schema(ldb); 393 if (!schema) { 394 PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on ldb!\n"); 395 return NULL; 396 } 397 398 result = dsdb_write_prefixes_from_schema_to_ldb(NULL, ldb, schema); 399 PyErr_WERROR_IS_ERR_RAISE(result); 400 401 Py_RETURN_NONE; 402 } 403 404 static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args) 405 { 406 PyObject *py_ldb; 407 struct ldb_context *ldb; 408 PyObject *py_from_ldb; 409 struct ldb_context *from_ldb; 410 struct dsdb_schema *schema; 411 int ret; 412 if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_from_ldb)) 413 return NULL; 414 415 PyErr_LDB_OR_RAISE(py_ldb, ldb); 416 417 PyErr_LDB_OR_RAISE(py_from_ldb, from_ldb); 418 419 schema = dsdb_get_schema(from_ldb); 420 if (!schema) { 421 PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on 'from' ldb!\n"); 422 return NULL; 423 } 424 425 ret = dsdb_reference_schema(ldb, schema, true); 426 PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb); 427 428 Py_RETURN_NONE; 429 } 430 431 static PyObject *py_dom_sid_to_rid(PyLdbObject *self, PyObject *args) 432 { 433 PyObject *py_sid; 434 struct dom_sid *sid; 435 uint32_t rid; 436 NTSTATUS status; 437 438 if(!PyArg_ParseTuple(args, "O", &py_sid)) 439 return NULL; 440 441 sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid)); 442 443 status = dom_sid_split_rid(NULL, sid, NULL, &rid); 444 if (!NT_STATUS_IS_OK(status)) { 445 PyErr_SetString(PyExc_RuntimeError, "dom_sid_split_rid failed"); 446 return NULL; 447 } 448 449 return PyInt_FromLong(rid); 173 return pylist; 450 174 } 451 175 452 176 static PyMethodDef py_misc_methods[] = { 453 177 { "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS, 454 "random_password(len) -> string\n" 455 "Generate random password with specified length." }, 178 "generate_random_str(len) -> string\n" 179 "Generate random string with specified length." }, 180 { "generate_random_password", (PyCFunction)py_generate_random_password, 181 METH_VARARGS, "generate_random_password(min, max) -> string\n" 182 "Generate random password with a length >= min and <= max." }, 456 183 { "unix2nttime", (PyCFunction)py_unix2nttime, METH_VARARGS, 457 184 "unix2nttime(timestamp) -> nttime" }, 458 { "ldb_set_credentials", (PyCFunction)py_ldb_set_credentials, METH_VARARGS, 459 "ldb_set_credentials(ldb, credentials) -> None\n" 460 "Set credentials to use when connecting." }, 461 { "ldb_set_session_info", (PyCFunction)py_ldb_set_session_info, METH_VARARGS, 462 "ldb_set_session_info(ldb, session_info)\n" 463 "Set session info to use when connecting." }, 464 { "ldb_set_loadparm", (PyCFunction)py_ldb_set_loadparm, METH_VARARGS, 465 "ldb_set_loadparm(ldb, session_info)\n" 466 "Set loadparm context to use when connecting." }, 467 { "samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid, METH_VARARGS, 468 "samdb_set_domain_sid(samdb, sid)\n" 469 "Set SID of domain to use." }, 470 { "samdb_get_domain_sid", (PyCFunction)py_samdb_get_domain_sid, METH_VARARGS, 471 "samdb_get_domain_sid(samdb)\n" 472 "Get SID of domain in use." }, 473 { "ldb_register_samba_handlers", (PyCFunction)py_ldb_register_samba_handlers, METH_VARARGS, 474 "ldb_register_samba_handlers(ldb)\n" 475 "Register Samba-specific LDB modules and schemas." }, 476 { "ldb_set_utf8_casefold", (PyCFunction)py_ldb_set_utf8_casefold, METH_VARARGS, 477 "ldb_set_utf8_casefold(ldb)\n" 478 "Set the right Samba casefolding function for UTF8 charset." }, 479 { "dsdb_set_ntds_invocation_id", (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS, 480 NULL }, 481 { "dsdb_set_opaque_integer", (PyCFunction)py_dsdb_set_opaque_integer, METH_VARARGS, 482 NULL }, 483 { "dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema, METH_VARARGS, 484 NULL }, 485 { "dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS, 486 NULL }, 487 { "dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS, 488 NULL }, 489 { "dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS, 490 NULL }, 491 { "dsdb_convert_schema_to_openldap", (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS, 492 NULL }, 493 { "dom_sid_to_rid", (PyCFunction)py_dom_sid_to_rid, METH_VARARGS, 494 NULL }, 185 { "nttime2unix", (PyCFunction)py_nttime2unix, METH_VARARGS, 186 "nttime2unix(nttime) -> timestamp" }, 187 { "nttime2string", (PyCFunction)py_nttime2string, METH_VARARGS, 188 "nttime2string(nttime) -> string" }, 495 189 { "set_debug_level", (PyCFunction)py_set_debug_level, METH_VARARGS, 496 190 "set debug level" }, 191 { "get_debug_level", (PyCFunction)py_get_debug_level, METH_NOARGS, 192 "get debug level" }, 193 { "interface_ips", (PyCFunction)py_interface_ips, METH_VARARGS, 194 "get interface IP address list"}, 497 195 { NULL } 498 196 }; 499 197 500 void init glue(void)198 void init_glue(void) 501 199 { 502 200 PyObject *m; 503 201 504 m = Py_InitModule3("glue", py_misc_methods, 202 debug_setup_talloc_log(); 203 204 m = Py_InitModule3("_glue", py_misc_methods, 505 205 "Python bindings for miscellaneous Samba functions."); 506 206 if (m == NULL) 507 207 return; 508 208 509 PyModule_AddObject(m, "version", PyString_FromString(SAMBA_VERSION_STRING)); 510 511 /* "userAccountControl" flags */ 512 PyModule_AddObject(m, "UF_NORMAL_ACCOUNT", PyInt_FromLong(UF_NORMAL_ACCOUNT)); 513 PyModule_AddObject(m, "UF_TEMP_DUPLICATE_ACCOUNT", PyInt_FromLong(UF_TEMP_DUPLICATE_ACCOUNT)); 514 PyModule_AddObject(m, "UF_SERVER_TRUST_ACCOUNT", PyInt_FromLong(UF_SERVER_TRUST_ACCOUNT)); 515 PyModule_AddObject(m, "UF_WORKSTATION_TRUST_ACCOUNT", PyInt_FromLong(UF_WORKSTATION_TRUST_ACCOUNT)); 516 PyModule_AddObject(m, "UF_INTERDOMAIN_TRUST_ACCOUNT", PyInt_FromLong(UF_INTERDOMAIN_TRUST_ACCOUNT)); 517 PyModule_AddObject(m, "UF_PASSWD_NOTREQD", PyInt_FromLong(UF_PASSWD_NOTREQD)); 518 PyModule_AddObject(m, "UF_ACCOUNTDISABLE", PyInt_FromLong(UF_ACCOUNTDISABLE)); 519 520 /* "groupType" flags */ 521 PyModule_AddObject(m, "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_BUILTIN_LOCAL_GROUP)); 522 PyModule_AddObject(m, "GTYPE_SECURITY_GLOBAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_GLOBAL_GROUP)); 523 PyModule_AddObject(m, "GTYPE_SECURITY_DOMAIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_DOMAIN_LOCAL_GROUP)); 524 PyModule_AddObject(m, "GTYPE_SECURITY_UNIVERSAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_UNIVERSAL_GROUP)); 525 PyModule_AddObject(m, "GTYPE_DISTRIBUTION_GLOBAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_GLOBAL_GROUP)); 526 PyModule_AddObject(m, "GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP)); 527 PyModule_AddObject(m, "GTYPE_DISTRIBUTION_UNIVERSAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_UNIVERSAL_GROUP)); 528 529 /* "sAMAccountType" flags */ 530 PyModule_AddObject(m, "ATYPE_NORMAL_ACCOUNT", PyInt_FromLong(ATYPE_NORMAL_ACCOUNT)); 531 PyModule_AddObject(m, "ATYPE_WORKSTATION_TRUST", PyInt_FromLong(ATYPE_WORKSTATION_TRUST)); 532 PyModule_AddObject(m, "ATYPE_INTERDOMAIN_TRUST", PyInt_FromLong(ATYPE_INTERDOMAIN_TRUST)); 533 PyModule_AddObject(m, "ATYPE_SECURITY_GLOBAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_GLOBAL_GROUP)); 534 PyModule_AddObject(m, "ATYPE_SECURITY_LOCAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_LOCAL_GROUP)); 535 PyModule_AddObject(m, "ATYPE_SECURITY_UNIVERSAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_UNIVERSAL_GROUP)); 536 PyModule_AddObject(m, "ATYPE_DISTRIBUTION_GLOBAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_GLOBAL_GROUP)); 537 PyModule_AddObject(m, "ATYPE_DISTRIBUTION_LOCAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_LOCAL_GROUP)); 538 PyModule_AddObject(m, "ATYPE_DISTRIBUTION_UNIVERSAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_UNIVERSAL_GROUP)); 539 540 /* "domainFunctionality", "forestFunctionality" flags in the rootDSE */ 541 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2000", PyInt_FromLong(DS_DOMAIN_FUNCTION_2000)); 542 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003_MIXED", PyInt_FromLong(DS_DOMAIN_FUNCTION_2003_MIXED)); 543 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003", PyInt_FromLong(DS_DOMAIN_FUNCTION_2003)); 544 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008", PyInt_FromLong(DS_DOMAIN_FUNCTION_2008)); 545 PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008_R2", PyInt_FromLong(DS_DOMAIN_FUNCTION_2008_R2)); 546 547 /* "domainControllerFunctionality" flags in the rootDSE */ 548 PyModule_AddObject(m, "DS_DC_FUNCTION_2000", PyInt_FromLong(DS_DC_FUNCTION_2000)); 549 PyModule_AddObject(m, "DS_DC_FUNCTION_2003", PyInt_FromLong(DS_DC_FUNCTION_2003)); 550 PyModule_AddObject(m, "DS_DC_FUNCTION_2008", PyInt_FromLong(DS_DC_FUNCTION_2008)); 551 PyModule_AddObject(m, "DS_DC_FUNCTION_2008_R2", PyInt_FromLong(DS_DC_FUNCTION_2008_R2)); 552 } 553 209 PyModule_AddObject(m, "version", 210 PyString_FromString(SAMBA_VERSION_STRING)); 211 212 /* one of the most annoying things about python scripts is 213 that they don't die when you hit control-C. This fixes that 214 sillyness. As we do all database operations using 215 transactions, this is also safe. 216 */ 217 signal(SIGINT, SIG_DFL); 218 } 219
Note:
See TracChangeset
for help on using the changeset viewer.