Changeset 988 for vendor/current/source4/lib/registry
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/lib/registry
- Files:
-
- 2 deleted
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/lib/registry/hive.c
r740 r988 36 36 char peek[20]; 37 37 38 /* Check for directory */39 if (directory_exist(location)) {40 return reg_open_directory(parent_ctx, location, root);41 }42 43 38 fd = open(location, O_RDWR); 44 39 if (fd == -1) { … … 49 44 50 45 num = read(fd, peek, 20); 46 close(fd); 51 47 if (num == -1) { 52 48 return WERR_BADFILE; … … 54 50 55 51 if (!strncmp(peek, "regf", 4)) { 56 close(fd);57 52 return reg_open_regf_file(parent_ctx, location, root); 58 53 } else if (!strncmp(peek, "TDB file", 8)) { 59 close(fd);60 54 return reg_open_ldb_file(parent_ctx, location, session_info, 61 55 credentials, ev_ctx, lp_ctx, root); -
vendor/current/source4/lib/registry/ldb.c
r740 r988 66 66 convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, 67 67 val->data, val->length, 68 (void **)&data->data, &data->length , false);68 (void **)&data->data, &data->length); 69 69 } else { 70 70 data->data = NULL; … … 160 160 ret2 = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, 161 161 (void *)data.data, data.length, 162 (void **)&val->data, &val->length, 163 false); 162 (void **)&val->data, &val->length); 164 163 if (ret2) { 165 164 ret = ldb_msg_add_value(msg, "data", val, NULL); … … 410 409 int ret; 411 410 412 ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_BASE, attrs, "(dn=*)"); 411 ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_BASE, attrs, 412 NULL); 413 413 414 414 if (ret != LDB_SUCCESS) { … … 505 505 W_ERROR_HAVE_NO_MEMORY(ldb_path); 506 506 507 ret = ldb_search(c, mem_ctx, &res, ldb_path, LDB_SCOPE_BASE, NULL, "(key=*)"); 507 ret = ldb_search(c, mem_ctx, &res, ldb_path, LDB_SCOPE_BASE, NULL, 508 NULL); 508 509 509 510 if (ret != LDB_SUCCESS) { … … 646 647 msg->dn = ldb_dn_copy(msg, kd->dn); 647 648 W_ERROR_HAVE_NO_MEMORY(msg->dn); 648 ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL); 649 ldb_msg_add_empty(msg, "type", LDB_FLAG_MOD_DELETE, NULL); 649 ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL); 650 if (ret != LDB_SUCCESS) { 651 return WERR_FOOBAR; 652 } 653 ret = ldb_msg_add_empty(msg, "type", LDB_FLAG_MOD_DELETE, 654 NULL); 655 if (ret != LDB_SUCCESS) { 656 return WERR_FOOBAR; 657 } 650 658 651 659 ret = ldb_modify(kd->ldb, msg); … … 653 661 talloc_free(msg); 654 662 655 if (ret != LDB_SUCCESS) { 663 if (ret == LDB_ERR_NO_SUCH_ATTRIBUTE) { 664 return WERR_BADFILE; 665 } else if (ret != LDB_SUCCESS) { 656 666 DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb))); 657 667 return WERR_FOOBAR; -
vendor/current/source4/lib/registry/local.c
r740 r988 81 81 int el; 82 82 83 if (path == NULL ) {83 if (path == NULL || path[0] == '\0') { 84 84 return WERR_INVALID_PARAM; 85 85 } … … 104 104 } 105 105 106 while (curbegin != NULL && *curbegin){106 do { 107 107 if (curend != NULL) 108 108 *curend = '\0'; … … 125 125 curbegin = curend + 1; 126 126 curend = strchr(curbegin, '\\'); 127 } 127 } while (curbegin[0] != '\0'); 128 128 talloc_free(orig); 129 129 … … 185 185 int el; 186 186 187 if (path == NULL ) {187 if (path == NULL || path[0] == '\0') { 188 188 return WERR_INVALID_PARAM; 189 189 } … … 208 208 } 209 209 210 while (curbegin != NULL && *curbegin){210 do { 211 211 if (curend != NULL) 212 212 *curend = '\0'; … … 234 234 curbegin = curend + 1; 235 235 curend = strchr(curbegin, '\\'); 236 } 236 } while (curbegin[0] != '\0'); 237 237 talloc_free(orig); 238 238 -
vendor/current/source4/lib/registry/man/regdiff.1.xml
r740 r988 6 6 <refentrytitle>regdiff</refentrytitle> 7 7 <manvolnum>1</manvolnum> 8 <refmiscinfo class="source">Samba</refmiscinfo> 9 <refmiscinfo class="manual">System Administration tools</refmiscinfo> 10 <refmiscinfo class="version">4.0</refmiscinfo> 8 11 </refmeta> 9 12 … … 19 22 <arg choice="opt">--help</arg> 20 23 <arg choice="opt">--backend=BACKEND</arg> 21 <arg choice="opt">--backend=BACKEND</arg>22 24 <arg choice="opt">--credentials=CREDENTIALS</arg> 23 <arg choice="opt">--credentials=CREDENTIALS</arg>24 <arg choice="opt">location</arg>25 25 <arg choice="opt">location</arg> 26 26 </cmdsynopsis> -
vendor/current/source4/lib/registry/man/regpatch.1.xml
r740 r988 6 6 <refentrytitle>regpatch</refentrytitle> 7 7 <manvolnum>1</manvolnum> 8 <refmiscinfo class="source">Samba</refmiscinfo> 9 <refmiscinfo class="manual">System Administration tools</refmiscinfo> 10 <refmiscinfo class="version">4.0</refmiscinfo> 8 11 </refmeta> 9 12 -
vendor/current/source4/lib/registry/man/regshell.1.xml
r740 r988 6 6 <refentrytitle>regshell</refentrytitle> 7 7 <manvolnum>1</manvolnum> 8 <refmiscinfo class="source">Samba</refmiscinfo> 9 <refmiscinfo class="manual">System Administration tools</refmiscinfo> 10 <refmiscinfo class="version">4.0</refmiscinfo> 8 11 </refmeta> 9 12 -
vendor/current/source4/lib/registry/man/regtree.1.xml
r740 r988 6 6 <refentrytitle>regtree</refentrytitle> 7 7 <manvolnum>1</manvolnum> 8 <refmiscinfo class="source">Samba</refmiscinfo> 9 <refmiscinfo class="manual">System Administration tools</refmiscinfo> 10 <refmiscinfo class="version">4.0</refmiscinfo> 8 11 </refmeta> 9 12 -
vendor/current/source4/lib/registry/patchfile_dotreg.c
r740 r988 71 71 const DATA_BLOB data) 72 72 { 73 size_t converted_size = 0; 73 74 char *ret = NULL; 74 75 … … 80 81 case REG_SZ: 81 82 convert_string_talloc(mem_ctx, 82 83 (void **)&ret, NULL, false);83 CH_UTF16, CH_UNIX, data.data, data.length, 84 (void **)&ret, &converted_size); 84 85 break; 85 86 case REG_DWORD: … … 235 236 bool result; 236 237 char *type_str = NULL; 237 char *data_str ;238 char *value ;238 char *data_str = NULL; 239 char *value = NULL; 239 240 bool continue_next_line = 0; 240 241 -
vendor/current/source4/lib/registry/patchfile_preg.c
r740 r988 188 188 } 189 189 190 strncpy(preg_header.hdr, "PReg", 4);190 memcpy(preg_header.hdr, "PReg", sizeof(preg_header.hdr)); 191 191 SIVAL(&preg_header.version, 0, 1); 192 192 write(data->fd, (uint8_t *)&preg_header, sizeof(preg_header)); -
vendor/current/source4/lib/registry/pyregistry.c
r740 r988 23 23 #include "libcli/util/pyerrors.h" 24 24 #include "lib/registry/registry.h" 25 #include "lib/talloc/pytalloc.h"25 #include <pytalloc.h> 26 26 #include "lib/events/events.h" 27 27 #include "auth/credentials/pycredentials.h" … … 32 32 extern PyTypeObject PyHiveKey; 33 33 34 /*#define PyRegistryKey_AsRegistryKey(obj) py_talloc_get_type(obj, struct registry_key)*/ 35 #define PyRegistry_AsRegistryContext(obj) ((struct registry_context *)py_talloc_get_ptr(obj)) 36 #define PyHiveKey_AsHiveKey(obj) ((struct hive_key*)py_talloc_get_ptr(obj)) 34 void initregistry(void); 35 36 /*#define PyRegistryKey_AsRegistryKey(obj) pytalloc_get_type(obj, struct registry_key)*/ 37 #define PyRegistry_AsRegistryContext(obj) ((struct registry_context *)pytalloc_get_ptr(obj)) 38 #define PyHiveKey_AsHiveKey(obj) ((struct hive_key*)pytalloc_get_ptr(obj)) 37 39 38 40 … … 48 50 49 51 result = reg_get_predefined_key_by_name(ctx, name, &key); 50 PyErr_WERROR_ IS_ERR_RAISE(result);51 52 return py _talloc_steal(&PyRegistryKey, key);52 PyErr_WERROR_NOT_OK_RAISE(result); 53 54 return pytalloc_steal(&PyRegistryKey, key); 53 55 } 54 56 … … 63 65 64 66 result = reg_key_del_abs(ctx, path); 65 PyErr_WERROR_ IS_ERR_RAISE(result);67 PyErr_WERROR_NOT_OK_RAISE(result); 66 68 67 69 Py_RETURN_NONE; … … 79 81 80 82 result = reg_get_predefined_key(ctx, hkey, &key); 81 PyErr_WERROR_ IS_ERR_RAISE(result);82 83 return py _talloc_steal(&PyRegistryKey, key);83 PyErr_WERROR_NOT_OK_RAISE(result); 84 85 return pytalloc_steal(&PyRegistryKey, key); 84 86 } 85 87 … … 93 95 94 96 result = reg_diff_apply(ctx, filename); 95 PyErr_WERROR_ IS_ERR_RAISE(result);97 PyErr_WERROR_NOT_OK_RAISE(result); 96 98 97 99 Py_RETURN_NONE; … … 126 128 127 129 result = reg_mount_hive(ctx, PyHiveKey_AsHiveKey(py_hivekey), hkey, elements); 128 PyErr_WERROR_ IS_ERR_RAISE(result);130 PyErr_WERROR_NOT_OK_RAISE(result); 129 131 130 132 Py_RETURN_NONE; … … 136 138 struct registry_context *ctx; 137 139 result = reg_open_local(NULL, &ctx); 138 PyErr_WERROR_ IS_ERR_RAISE(result);139 return py _talloc_steal(&PyRegistry, ctx);140 PyErr_WERROR_NOT_OK_RAISE(result); 141 return pytalloc_steal(&PyRegistry, ctx); 140 142 } 141 143 … … 159 161 .tp_methods = registry_methods, 160 162 .tp_new = registry_new, 161 .tp_basicsize = sizeof(py_talloc_Object),162 163 .tp_flags = Py_TPFLAGS_DEFAULT, 163 164 }; … … 174 175 result = hive_key_del(NULL, key, name); 175 176 176 PyErr_WERROR_ IS_ERR_RAISE(result);177 PyErr_WERROR_NOT_OK_RAISE(result); 177 178 178 179 Py_RETURN_NONE; … … 185 186 186 187 result = hive_key_flush(key); 187 PyErr_WERROR_ IS_ERR_RAISE(result);188 PyErr_WERROR_NOT_OK_RAISE(result); 188 189 189 190 Py_RETURN_NONE; … … 201 202 result = hive_key_del_value(NULL, key, name); 202 203 203 PyErr_WERROR_ IS_ERR_RAISE(result);204 PyErr_WERROR_NOT_OK_RAISE(result); 204 205 205 206 Py_RETURN_NONE; … … 211 212 uint32_t type; 212 213 DATA_BLOB value; 214 Py_ssize_t value_length = 0; 213 215 WERROR result; 214 216 struct hive_key *key = PyHiveKey_AsHiveKey(self); 215 217 216 if (!PyArg_ParseTuple(args, "siz#", &name, &type, &value.data, &value.length)) 217 return NULL; 218 if (!PyArg_ParseTuple(args, "siz#", &name, &type, &value.data, &value_length)) { 219 return NULL; 220 } 221 value.length = value_length; 218 222 219 223 if (value.data != NULL) … … 222 226 result = hive_key_del_value(NULL, key, name); 223 227 224 PyErr_WERROR_ IS_ERR_RAISE(result);228 PyErr_WERROR_NOT_OK_RAISE(result); 225 229 226 230 Py_RETURN_NONE; … … 284 288 285 289 result = reg_open_hive(NULL, location, session_info, credentials, 286 tevent_context_init(NULL),290 samba_tevent_context_init(NULL), 287 291 lp_ctx, &hive_key); 288 292 talloc_free(mem_ctx); 289 PyErr_WERROR_ IS_ERR_RAISE(result);290 291 return py _talloc_steal(&PyHiveKey, hive_key);293 PyErr_WERROR_NOT_OK_RAISE(result); 294 295 return pytalloc_steal(&PyHiveKey, hive_key); 292 296 } 293 297 … … 296 300 .tp_methods = hive_key_methods, 297 301 .tp_new = hive_new, 298 .tp_basicsize = sizeof(py_talloc_Object),299 302 .tp_flags = Py_TPFLAGS_DEFAULT, 300 303 }; … … 302 305 PyTypeObject PyRegistryKey = { 303 306 .tp_name = "RegistryKey", 304 .tp_basicsize = sizeof(py_talloc_Object),305 307 .tp_flags = Py_TPFLAGS_DEFAULT, 306 308 }; … … 353 355 } 354 356 355 return py_talloc_steal(&PyRegistry, reg_ctx); 356 } 357 358 static PyObject *py_open_directory(PyObject *self, PyObject *args) 359 { 360 char *location; 361 WERROR result; 362 struct hive_key *key; 363 364 if (!PyArg_ParseTuple(args, "s", &location)) 365 return NULL; 366 367 result = reg_open_directory(NULL, location, &key); 368 PyErr_WERROR_IS_ERR_RAISE(result); 369 370 return py_talloc_steal(&PyHiveKey, key); 371 } 372 373 static PyObject *py_create_directory(PyObject *self, PyObject *args) 374 { 375 char *location; 376 WERROR result; 377 struct hive_key *key; 378 379 if (!PyArg_ParseTuple(args, "s", &location)) 380 return NULL; 381 382 result = reg_create_directory(NULL, location, &key); 383 PyErr_WERROR_IS_ERR_RAISE(result); 384 385 return py_talloc_steal(&PyHiveKey, key); 357 return pytalloc_steal(&PyRegistry, reg_ctx); 386 358 } 387 359 … … 429 401 s4_event_context_init(NULL), lp_ctx, &key); 430 402 talloc_free(mem_ctx); 431 PyErr_WERROR_ IS_ERR_RAISE(result);432 433 return py _talloc_steal(&PyHiveKey, key);403 PyErr_WERROR_NOT_OK_RAISE(result); 404 405 return pytalloc_steal(&PyHiveKey, key); 434 406 } 435 407 … … 460 432 static PyMethodDef py_registry_methods[] = { 461 433 { "open_samba", (PyCFunction)py_open_samba, METH_VARARGS|METH_KEYWORDS, "open_samba() -> reg" }, 462 { "open_directory", py_open_directory, METH_VARARGS, "open_dir(location) -> key" },463 { "create_directory", py_create_directory, METH_VARARGS, "create_dir(location) -> key" },464 434 { "open_ldb", (PyCFunction)py_open_ldb_file, METH_VARARGS|METH_KEYWORDS, "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key" }, 465 435 { "open_hive", (PyCFunction)py_open_hive, METH_VARARGS|METH_KEYWORDS, "open_hive(location, session_info=None, credentials=None, loadparm_context=None) -> key" }, … … 472 442 { 473 443 PyObject *m; 474 PyTypeObject *talloc_type = PyTalloc_GetObjectType(); 475 476 if (talloc_type == NULL) 444 445 if (pytalloc_BaseObject_PyType_Ready(&PyHiveKey) < 0) 477 446 return; 478 447 479 PyHiveKey.tp_base = talloc_type; 480 PyRegistry.tp_base = talloc_type; 481 PyRegistryKey.tp_base = talloc_type; 482 483 if (PyType_Ready(&PyHiveKey) < 0) 448 if (pytalloc_BaseObject_PyType_Ready(&PyRegistry) < 0) 484 449 return; 485 450 486 if (PyType_Ready(&PyRegistry) < 0) 487 return; 488 489 if (PyType_Ready(&PyRegistryKey) < 0) 451 if (pytalloc_BaseObject_PyType_Ready(&PyRegistryKey) < 0) 490 452 return; 491 453 -
vendor/current/source4/lib/registry/regf.c
r740 r988 164 164 unsigned int i; 165 165 166 *offset = 0; 166 if (offset != NULL) { 167 *offset = 0; 168 } 167 169 168 170 if (size == 0) … … 252 254 ret.length = size - 0x4; 253 255 if (offset) { 254 uint32_t new_rel_offset ;256 uint32_t new_rel_offset = 0; 255 257 *offset = hbin->offset_from_first + rel_offset + 0x20; 256 258 SMB_ASSERT(hbin_by_offset(data, *offset, &new_rel_offset) == hbin); … … 1719 1721 1720 1722 if (key->nk->subkeys_offset != -1) { 1721 char *sk_name;1722 1723 struct hive_key *sk = (struct hive_key *)key; 1723 1724 unsigned int i = key->nk->num_subkeys; 1724 1725 while (i--) { 1726 char *sk_name; 1727 const char *p = NULL; 1728 1725 1729 /* Get subkey information. */ 1726 1730 error = regf_get_subkey_by_index(parent_nk, sk, 0, 1727 (const char **)&sk_name,1731 &p, 1728 1732 NULL, NULL); 1729 1733 if (!W_ERROR_IS_OK(error)) { … … 1731 1735 return error; 1732 1736 } 1737 sk_name = discard_const_p(char, p); 1733 1738 1734 1739 /* Delete subkey. */ … … 1744 1749 1745 1750 if (key->nk->values_offset != -1) { 1746 char *val_name;1747 1751 struct hive_key *sk = (struct hive_key *)key; 1748 1752 DATA_BLOB data; 1749 1753 unsigned int i = key->nk->num_values; 1750 1754 while (i--) { 1755 char *val_name; 1756 const char *p = NULL; 1757 1751 1758 /* Get value information. */ 1752 1759 error = regf_get_value(parent_nk, sk, 0, 1753 (const char **)&val_name,1760 &p, 1754 1761 NULL, &data); 1755 1762 if (!W_ERROR_IS_OK(error)) { … … 1757 1764 return error; 1758 1765 } 1766 val_name = discard_const_p(char, p); 1759 1767 1760 1768 /* Delete value. */ … … 1864 1872 uint32_t i; 1865 1873 uint32_t tmp_vk_offset, vk_offset, old_vk_offset = (uint32_t) -1; 1866 DATA_BLOB values ;1874 DATA_BLOB values = {0}; 1867 1875 1868 1876 ZERO_STRUCT(vk); … … 1891 1899 if (old_vk_offset == -1) { 1892 1900 vk.header = "vk"; 1893 vk.name_length = strlen(name); 1894 if (name != NULL && name[0] != 0) { 1901 if (name != NULL && name[0] != '\0') { 1895 1902 vk.flag = 1; 1896 1903 vk.data_name = name; 1904 vk.name_length = strlen(name); 1897 1905 } else { 1906 vk.flag = 0; 1898 1907 vk.data_name = NULL; 1899 vk. flag= 0;1908 vk.name_length = 0; 1900 1909 } 1901 1910 } else { … … 2212 2221 2213 2222 if (pull->data.data == NULL) { 2214 DEBUG(0, ("Error reading data \n"));2223 DEBUG(0, ("Error reading data from file: %s\n", location)); 2215 2224 talloc_free(regf); 2216 2225 return WERR_GENERAL_FAILURE; … … 2221 2230 2222 2231 if (NT_STATUS_IS_ERR(tdr_pull_regf_hdr(pull, regf_hdr, regf_hdr))) { 2232 DEBUG(0, ("Failed to pull regf header from file: %s\n", location)); 2223 2233 talloc_free(regf); 2224 2234 return WERR_GENERAL_FAILURE; -
vendor/current/source4/lib/registry/registry.h
r740 r988 3 3 Registry interface 4 4 Copyright (C) Gerald Carter 2002. 5 Copyright (C) Jelmer Vernooij 5 Copyright (C) Jelmer Vernooij 2003-2007. 6 6 7 7 This program is free software; you can redistribute it and/or modify … … 380 380 * Open the registry on a remote machine. 381 381 */ 382 WERROR reg_open_remote(struct registry_context **ctx, 382 WERROR reg_open_remote(TALLOC_CTX *mem_ctx, 383 struct registry_context **ctx, 383 384 struct auth_session_info *session_info, 384 385 struct cli_credentials *credentials, -
vendor/current/source4/lib/registry/rpc.c
r740 r988 476 476 }; 477 477 478 _PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx, 478 _PUBLIC_ WERROR reg_open_remote(TALLOC_CTX *mem_ctx, 479 struct registry_context **ctx, 479 480 struct auth_session_info *session_info, 480 481 struct cli_credentials *credentials, … … 486 487 struct rpc_registry_context *rctx; 487 488 488 dcerpc_init( lp_ctx);489 490 rctx = talloc( NULL, struct rpc_registry_context);489 dcerpc_init(); 490 491 rctx = talloc(mem_ctx, struct rpc_registry_context); 491 492 W_ERROR_HAVE_NO_MEMORY(rctx); 492 493 -
vendor/current/source4/lib/registry/tests/diff.c
r740 r988 26 26 #include "librpc/gen_ndr/winreg.h" 27 27 #include "param/param.h" 28 #include "lib/registry/tests/proto.h" 28 29 29 30 struct diff_tcase_data { -
vendor/current/source4/lib/registry/tests/generic.c
r740 r988 25 25 #include "librpc/gen_ndr/winreg.h" 26 26 #include "param/param.h" 27 28 struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx); 29 struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx); 30 struct torture_suite *torture_registry_diff(TALLOC_CTX *mem_ctx); 27 #include "lib/registry/tests/proto.h" 31 28 32 29 static bool test_str_regtype(struct torture_context *ctx) … … 95 92 DATA_BLOB db; 96 93 convert_string_talloc(ctx, CH_UTF8, CH_UTF16, 97 "bla", 3, (void **)&db.data, &db.length , false);94 "bla", 3, (void **)&db.data, &db.length); 98 95 torture_assert_str_equal(ctx, "bla", 99 96 reg_val_data_string(ctx, REG_SZ, db), … … 132 129 "stationary traveller", 133 130 strlen("stationary traveller"), 134 (void **)&data.data, &data.length , false);131 (void **)&data.data, &data.length); 135 132 torture_assert_str_equal(ctx, "camel = REG_SZ : stationary traveller", 136 133 reg_val_description(ctx, "camel", REG_SZ, data), … … 146 143 "west berlin", 147 144 strlen("west berlin"), 148 (void **)&data.data, &data.length , false);145 (void **)&data.data, &data.length); 149 146 torture_assert_str_equal(ctx, "<No Name> = REG_SZ : west berlin", 150 147 reg_val_description(ctx, NULL, REG_SZ, data), -
vendor/current/source4/lib/registry/tests/hive.c
r740 r988 28 28 #include "param/param.h" 29 29 #include "libcli/security/security.h" 30 31 static bool test_del_nonexistant_key(struct torture_context *tctx, 30 #include "lib/registry/tests/proto.h" 31 32 static bool test_del_nonexistent_key(struct torture_context *tctx, 32 33 const void *test_data) 33 34 { … … 346 347 static void tcase_add_tests(struct torture_tcase *tcase) 347 348 { 348 torture_tcase_add_simple_test_const(tcase, "del_nonexist ant_key",349 test_del_nonexist ant_key);349 torture_tcase_add_simple_test_const(tcase, "del_nonexistent_key", 350 test_del_nonexistent_key); 350 351 torture_tcase_add_simple_test_const(tcase, "add_subkey", 351 352 test_add_subkey); … … 375 376 } 376 377 377 static bool hive_setup_dir(struct torture_context *tctx, void **data)378 {379 struct hive_key *key;380 WERROR error;381 char *dirname;382 NTSTATUS status;383 384 status = torture_temp_dir(tctx, "hive-dir", &dirname);385 if (!NT_STATUS_IS_OK(status))386 return false;387 388 rmdir(dirname);389 390 error = reg_create_directory(tctx, dirname, &key);391 if (!W_ERROR_IS_OK(error)) {392 fprintf(stderr, "Unable to initialize dir hive\n");393 return false;394 }395 396 *data = key;397 398 return true;399 }400 401 378 static bool hive_setup_ldb(struct torture_context *tctx, void **data) 402 379 { … … 447 424 } 448 425 449 static bool test_dir_refuses_null_location(struct torture_context *tctx)450 {451 torture_assert_werr_equal(tctx, WERR_INVALID_PARAM,452 reg_open_directory(NULL, NULL, NULL),453 "reg_open_directory accepts NULL location");454 return true;455 }456 457 426 struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx) 458 427 { 459 428 struct torture_tcase *tcase; 460 429 struct torture_suite *suite = torture_suite_create(mem_ctx, "hive"); 461 462 torture_suite_add_simple_test(suite, "dir-refuses-null-location",463 test_dir_refuses_null_location);464 465 tcase = torture_suite_add_tcase(suite, "dir");466 torture_tcase_set_fixture(tcase, hive_setup_dir, NULL);467 tcase_add_tests(tcase);468 430 469 431 tcase = torture_suite_add_tcase(suite, "ldb"); -
vendor/current/source4/lib/registry/tests/registry.c
r740 r988 27 27 #include "libcli/security/security.h" 28 28 #include "system/filesys.h" 29 #include "lib/registry/tests/proto.h" 29 30 30 31 /** … … 255 256 uint32_t num_subkeys, num_values; 256 257 const char *classname; 257 258 if (!create_test_key(tctx, rctx, "Munchen", &root, &subkey)) 258 const char *data = "temp"; 259 260 if (!create_test_key(tctx, rctx, "Muenchen", &root, &subkey)) 259 261 return false; 260 262 … … 267 269 torture_assert_int_equal(tctx, num_subkeys, 0, "num subkeys"); 268 270 torture_assert_int_equal(tctx, num_values, 0, "num values"); 271 272 error = reg_val_set(subkey, "", REG_SZ, 273 data_blob_string_const(data)); 274 torture_assert_werr_ok(tctx, error, "set default value"); 275 276 error = reg_key_get_info(tctx, subkey, &classname, 277 &num_subkeys, &num_values, 278 &last_changed_time, NULL, NULL, NULL); 279 280 torture_assert_werr_ok(tctx, error, "get info key"); 281 torture_assert(tctx, classname == NULL, "classname"); 282 torture_assert_int_equal(tctx, num_subkeys, 0, "num subkeys"); 283 torture_assert_int_equal(tctx, num_values, 1, "num values"); 269 284 270 285 return true; … … 409 424 char value[4]; 410 425 uint32_t type; 426 const char *data_val = "temp"; 427 411 428 SIVAL(value, 0, 42); 412 429 … … 432 449 torture_assert_int_equal(tctx, REG_DWORD, type, "value type"); 433 450 451 error = reg_val_set(subkey, "", REG_SZ, 452 data_blob_talloc(tctx, data_val, 453 strlen(data_val))); 454 torture_assert_werr_ok(tctx, error, "set default value"); 455 456 error = reg_key_get_value_by_name(tctx, subkey, "", &type, 457 &data); 458 torture_assert_werr_ok(tctx, error, "getting default value"); 459 torture_assert_int_equal(tctx, REG_SZ, type, "value type ok"); 460 torture_assert_int_equal(tctx, strlen(data_val), data.length, "value length ok"); 461 torture_assert_str_equal(tctx, data_val, (char *)data.data, "value ok"); 462 434 463 return true; 435 464 } … … 446 475 uint32_t type; 447 476 char value[4]; 477 const char *data_val = "temp"; 478 448 479 SIVAL(value, 0, 42); 449 480 … … 468 499 "getting missing value"); 469 500 501 error = reg_del_value(tctx, subkey, ""); 502 torture_assert_werr_equal(tctx, error, WERR_BADFILE, 503 "unsetting missing default value"); 504 505 error = reg_val_set(subkey, "", REG_SZ, 506 data_blob_talloc(tctx, data_val, 507 strlen(data_val))); 508 torture_assert_werr_ok(tctx, error, "set default value"); 509 510 error = reg_del_value(tctx, subkey, ""); 511 torture_assert_werr_ok (tctx, error, "unsetting default value"); 512 470 513 return true; 471 514 } … … 483 526 const char *name; 484 527 char value[4]; 528 const char *data_val = "temp"; 529 485 530 SIVAL(value, 0, 42); 486 531 … … 506 551 torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, 507 552 "getting missing value"); 553 554 error = reg_val_set(subkey, "", REG_SZ, 555 data_blob_talloc(tctx, data_val, strlen(data_val))); 556 torture_assert_werr_ok(tctx, error, "set default value"); 557 558 error = reg_key_get_value_by_index(tctx, subkey, 0, &name, 559 &type, &data); 560 torture_assert_werr_ok(tctx, error, "getting default value"); 561 torture_assert_int_equal(tctx, REG_SZ, type, "value type ok"); 562 torture_assert_int_equal(tctx, strlen(data_val), data.length, "value length ok"); 563 torture_assert_str_equal(tctx, data_val, (char *)data.data, "value ok"); 508 564 509 565 return true; -
vendor/current/source4/lib/registry/tools/common.c
r414 r988 32 32 WERROR error; 33 33 34 error = reg_open_remote( &h, NULL, creds, lp_ctx, remote, ev_ctx);34 error = reg_open_remote(NULL, &h, NULL, creds, lp_ctx, remote, ev_ctx); 35 35 36 36 if (!W_ERROR_IS_OK(error)) { -
vendor/current/source4/lib/registry/tools/regdiff.c
r740 r988 29 29 enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL }; 30 30 31 static struct registry_context *open_backend(poptContext pc, 31 static struct registry_context *open_backend(TALLOC_CTX *mem_ctx, 32 poptContext pc, 32 33 struct tevent_context *ev_ctx, 33 34 struct loadparm_context *lp_ctx, … … 43 44 return NULL; 44 45 case REG_LOCAL: 45 error = reg_open_samba( NULL, &ctx, ev_ctx, lp_ctx, NULL, cmdline_credentials);46 error = reg_open_samba(mem_ctx, &ctx, ev_ctx, lp_ctx, NULL, cmdline_credentials); 46 47 break; 47 48 case REG_REMOTE: 48 error = reg_open_remote( &ctx, NULL, cmdline_credentials, lp_ctx,49 error = reg_open_remote(mem_ctx, &ctx, NULL, cmdline_credentials, lp_ctx, 49 50 remote_host, ev_ctx); 50 51 break; 51 52 case REG_NULL: 52 error = reg_open_local( NULL, &ctx);53 error = reg_open_local(mem_ctx, &ctx); 53 54 break; 54 55 } … … 119 120 } 120 121 121 ev_ctx = s4_event_context_init( NULL);122 ev_ctx = s4_event_context_init(ctx); 122 123 123 h1 = open_backend( pc, ev_ctx, cmdline_lp_ctx, backend1, remote1);124 h1 = open_backend(ctx, pc, ev_ctx, cmdline_lp_ctx, backend1, remote1); 124 125 if (h1 == NULL) 125 126 return 1; 126 127 127 h2 = open_backend( pc, ev_ctx, cmdline_lp_ctx, backend2, remote2);128 h2 = open_backend(ctx, pc, ev_ctx, cmdline_lp_ctx, backend2, remote2); 128 129 if (h2 == NULL) 129 130 return 1; -
vendor/current/source4/lib/registry/tools/regpatch.c
r740 r988 27 27 #include "events/events.h" 28 28 29 int main(int argc, c har **argv)29 int main(int argc, const char **argv) 30 30 { 31 31 int opt; … … 45 45 }; 46 46 47 pc = poptGetContext(argv[0], argc, (const char **)argv, long_options,0);47 pc = poptGetContext(argv[0], argc, argv, long_options,0); 48 48 49 49 while((opt = poptGetNextOpt(pc)) != -1) { -
vendor/current/source4/lib/registry/tools/regshell.c
r740 r988 38 38 }; 39 39 40 static WERROR get_full_path(struct regshell_context *ctx, c har *path, char **ret_path)41 { 42 c har *dir;40 static WERROR get_full_path(struct regshell_context *ctx, const char *path, char **ret_path) 41 { 42 const char *dir; 43 43 char *tmp; 44 44 char *new_path; … … 50 50 } 51 51 52 dir = strtok( path, "\\");52 dir = strtok(discard_const_p(char, path), "\\"); 53 53 if (dir == NULL) { 54 54 *ret_path = new_path; … … 99 99 */ 100 100 101 static WERROR cmd_info(struct regshell_context *ctx, int argc, c har **argv)101 static WERROR cmd_info(struct regshell_context *ctx, int argc, const char **argv) 102 102 { 103 103 struct security_descriptor *sec_desc = NULL; … … 151 151 } 152 152 153 static WERROR cmd_predef(struct regshell_context *ctx, int argc, c har **argv)153 static WERROR cmd_predef(struct regshell_context *ctx, int argc, const char **argv) 154 154 { 155 155 struct registry_key *ret = NULL; … … 177 177 178 178 static WERROR cmd_pwd(struct regshell_context *ctx, 179 int argc, c har **argv)179 int argc, const char **argv) 180 180 { 181 181 if (ctx->predef) { … … 186 186 } 187 187 188 static WERROR cmd_set(struct regshell_context *ctx, int argc, c har **argv)188 static WERROR cmd_set(struct regshell_context *ctx, int argc, const char **argv) 189 189 { 190 190 struct registry_value val; … … 210 210 } 211 211 212 static WERROR cmd_ck(struct regshell_context *ctx, int argc, c har **argv)212 static WERROR cmd_ck(struct regshell_context *ctx, int argc, const char **argv) 213 213 { 214 214 struct registry_key *nkey = NULL; … … 239 239 } 240 240 241 static WERROR cmd_print(struct regshell_context *ctx, int argc, c har **argv)241 static WERROR cmd_print(struct regshell_context *ctx, int argc, const char **argv) 242 242 { 243 243 uint32_t value_type; … … 263 263 } 264 264 265 static WERROR cmd_ls(struct regshell_context *ctx, int argc, c har **argv)265 static WERROR cmd_ls(struct regshell_context *ctx, int argc, const char **argv) 266 266 { 267 267 unsigned int i; … … 293 293 return WERR_OK; 294 294 } 295 static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, c har **argv)295 static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, const char **argv) 296 296 { 297 297 struct registry_key *tmp; … … 315 315 316 316 static WERROR cmd_rmkey(struct regshell_context *ctx, 317 int argc, c har **argv)317 int argc, const char **argv) 318 318 { 319 319 WERROR error; … … 335 335 } 336 336 337 static WERROR cmd_rmval(struct regshell_context *ctx, int argc, c har **argv)337 static WERROR cmd_rmval(struct regshell_context *ctx, int argc, const char **argv) 338 338 { 339 339 WERROR error; … … 356 356 357 357 _NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx, 358 int argc, c har **argv)358 int argc, const char **argv) 359 359 { 360 360 exit(0); 361 361 } 362 362 363 static WERROR cmd_help(struct regshell_context *ctx, int, c har **);363 static WERROR cmd_help(struct regshell_context *ctx, int, const char **); 364 364 365 365 static struct { … … 367 367 const char *alias; 368 368 const char *help; 369 WERROR (*handle)(struct regshell_context *ctx, int argc, c har **argv);369 WERROR (*handle)(struct regshell_context *ctx, int argc, const char **argv); 370 370 } regshell_cmds[] = { 371 371 {"ck", "cd", "Change current key", cmd_ck }, … … 385 385 386 386 static WERROR cmd_help(struct regshell_context *ctx, 387 int argc, c har **argv)387 int argc, const char **argv) 388 388 { 389 389 unsigned int i; … … 400 400 { 401 401 int argc; 402 c har **argv = NULL;402 const char **argv = NULL; 403 403 int ret, i; 404 404 405 if ((ret = poptParseArgvString(line, &argc, (const char ***)&argv)) != 0) {405 if ((ret = poptParseArgvString(line, &argc, &argv)) != 0) { 406 406 fprintf(stderr, "regshell: %s\n", poptStrerror(ret)); 407 407 return WERR_INVALID_PARAM; … … 429 429 char **matches; 430 430 size_t len, samelen=0; 431 unsignedint i, count=1;431 int i, count=1; 432 432 433 433 matches = malloc_array_p(char *, MAX_COMPLETIONS); … … 509 509 break; 510 510 } else { 511 int n; 512 511 513 printf("Error creating completion list: %s\n", 512 514 win_errstr(status)); 515 516 for (n = j; n >= 0; n--) { 517 SAFE_FREE(matches[n]); 518 } 519 SAFE_FREE(matches); 513 520 talloc_free(mem_ctx); 514 521 return NULL; … … 545 552 } 546 553 547 int main(int argc, c har **argv)554 int main(int argc, const char **argv) 548 555 { 549 556 int opt; … … 564 571 }; 565 572 566 pc = poptGetContext(argv[0], argc, (const char **)argv, long_options,0);573 pc = poptGetContext(argv[0], argc, argv, long_options,0); 567 574 568 575 while((opt = poptGetNextOpt(pc)) != -1) { -
vendor/current/source4/lib/registry/tools/regtree.c
r740 r988 93 93 94 94 mem_ctx = talloc_init("sec_desc"); 95 if ( NT_STATUS_IS_ERR(reg_get_sec_desc(mem_ctx, p, &sec_desc))) {95 if (!W_ERROR_IS_OK(reg_get_sec_desc(mem_ctx, p, &sec_desc))) { 96 96 DEBUG(0, ("Error getting security descriptor\n")); 97 97 } … … 99 99 } 100 100 101 int main(int argc, c har **argv)101 int main(int argc, const char **argv) 102 102 { 103 103 int opt; … … 123 123 }; 124 124 125 pc = poptGetContext(argv[0], argc, (const char **)argv, long_options,0);125 pc = poptGetContext(argv[0], argc, argv, long_options,0); 126 126 127 127 while((opt = poptGetNextOpt(pc)) != -1) { -
vendor/current/source4/lib/registry/util.c
r740 r988 27 27 const DATA_BLOB data) 28 28 { 29 size_t converted_size = 0; 29 30 char *ret = NULL; 30 31 … … 38 39 CH_UTF16, CH_UNIX, 39 40 data.data, data.length, 40 (void **)&ret, NULL, false);41 (void **)&ret, &converted_size); 41 42 break; 42 43 case REG_DWORD: … … 163 164 data_str, strlen(data_str)+1, 164 165 (void **)&data->data, 165 &data->length , false);166 &data->length); 166 167 break; 167 168 case REG_MULTI_SZ: -
vendor/current/source4/lib/registry/wscript_build
r740 r988 12 12 13 13 bld.SAMBA_LIBRARY('registry', 14 source='interface.c util.c samba.c patchfile_dotreg.c patchfile_preg.c patchfile.c regf.c hive.c local.c ldb.c dir.c rpc.c', 15 pc_files='registry.pc', 16 public_deps='samba-util TDR_REGF ldb RPC_NDR_WINREG ldbsamba util_reg', 17 public_headers='registry.h', 18 vnum='0.0.1' 14 source='interface.c util.c samba.c patchfile_dotreg.c patchfile_preg.c patchfile.c regf.c hive.c local.c ldb.c rpc.c', 15 public_deps='dcerpc samba-util TDR_REGF ldb RPC_NDR_WINREG ldbsamba util_reg', 16 private_headers='registry.h', 17 private_library=True 19 18 ) 20 19
Note:
See TracChangeset
for help on using the changeset viewer.