Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source4/lib/registry
Files:
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/lib/registry/hive.c

    r740 r988  
    3636        char peek[20];
    3737
    38         /* Check for directory */
    39         if (directory_exist(location)) {
    40                 return reg_open_directory(parent_ctx, location, root);
    41         }
    42 
    4338        fd = open(location, O_RDWR);
    4439        if (fd == -1) {
     
    4944
    5045        num = read(fd, peek, 20);
     46        close(fd);
    5147        if (num == -1) {
    5248                return WERR_BADFILE;
     
    5450
    5551        if (!strncmp(peek, "regf", 4)) {
    56                 close(fd);
    5752                return reg_open_regf_file(parent_ctx, location, root);
    5853        } else if (!strncmp(peek, "TDB file", 8)) {
    59                 close(fd);
    6054                return reg_open_ldb_file(parent_ctx, location, session_info,
    6155                                         credentials, ev_ctx, lp_ctx, root);
  • vendor/current/source4/lib/registry/ldb.c

    r740 r988  
    6666                        convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16,
    6767                                              val->data, val->length,
    68                                               (void **)&data->data, &data->length, false);
     68                                              (void **)&data->data, &data->length);
    6969                } else {
    7070                        data->data = NULL;
     
    160160                        ret2 = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8,
    161161                                                     (void *)data.data, data.length,
    162                                                      (void **)&val->data, &val->length,
    163                                                      false);
     162                                                     (void **)&val->data, &val->length);
    164163                        if (ret2) {
    165164                                ret = ldb_msg_add_value(msg, "data", val, NULL);
     
    410409        int ret;
    411410
    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);
    413413
    414414        if (ret != LDB_SUCCESS) {
     
    505505        W_ERROR_HAVE_NO_MEMORY(ldb_path);
    506506
    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);
    508509
    509510        if (ret != LDB_SUCCESS) {
     
    646647                msg->dn = ldb_dn_copy(msg, kd->dn);
    647648                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                }
    650658
    651659                ret = ldb_modify(kd->ldb, msg);
     
    653661                talloc_free(msg);
    654662
    655                 if (ret != LDB_SUCCESS) {
     663                if (ret == LDB_ERR_NO_SUCH_ATTRIBUTE) {
     664                        return WERR_BADFILE;
     665                } else if (ret != LDB_SUCCESS) {
    656666                        DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb)));
    657667                        return WERR_FOOBAR;
  • vendor/current/source4/lib/registry/local.c

    r740 r988  
    8181        int el;
    8282
    83         if (path == NULL) {
     83        if (path == NULL || path[0] == '\0') {
    8484                return WERR_INVALID_PARAM;
    8585        }
     
    104104        }
    105105
    106         while (curbegin != NULL && *curbegin) {
     106        do {
    107107                if (curend != NULL)
    108108                        *curend = '\0';
     
    125125                curbegin = curend + 1;
    126126                curend = strchr(curbegin, '\\');
    127         }
     127        } while (curbegin[0] != '\0');
    128128        talloc_free(orig);
    129129
     
    185185        int el;
    186186
    187         if (path == NULL) {
     187        if (path == NULL || path[0] == '\0') {
    188188                return WERR_INVALID_PARAM;
    189189        }
     
    208208        }
    209209
    210         while (curbegin != NULL && *curbegin) {
     210        do {
    211211                if (curend != NULL)
    212212                        *curend = '\0';
     
    234234                curbegin = curend + 1;
    235235                curend = strchr(curbegin, '\\');
    236         }
     236        } while (curbegin[0] != '\0');
    237237        talloc_free(orig);
    238238
  • vendor/current/source4/lib/registry/man/regdiff.1.xml

    r740 r988  
    66        <refentrytitle>regdiff</refentrytitle>
    77        <manvolnum>1</manvolnum>
     8        <refmiscinfo class="source">Samba</refmiscinfo>
     9        <refmiscinfo class="manual">System Administration tools</refmiscinfo>
     10        <refmiscinfo class="version">4.0</refmiscinfo>
    811</refmeta>
    912
     
    1922                <arg choice="opt">--help</arg>
    2023                <arg choice="opt">--backend=BACKEND</arg>
    21                 <arg choice="opt">--backend=BACKEND</arg>
    2224                <arg choice="opt">--credentials=CREDENTIALS</arg>
    23                 <arg choice="opt">--credentials=CREDENTIALS</arg>
    24                 <arg choice="opt">location</arg>
    2525                <arg choice="opt">location</arg>
    2626        </cmdsynopsis>
  • vendor/current/source4/lib/registry/man/regpatch.1.xml

    r740 r988  
    66        <refentrytitle>regpatch</refentrytitle>
    77        <manvolnum>1</manvolnum>
     8        <refmiscinfo class="source">Samba</refmiscinfo>
     9        <refmiscinfo class="manual">System Administration tools</refmiscinfo>
     10        <refmiscinfo class="version">4.0</refmiscinfo>
    811</refmeta>
    912
  • vendor/current/source4/lib/registry/man/regshell.1.xml

    r740 r988  
    66        <refentrytitle>regshell</refentrytitle>
    77        <manvolnum>1</manvolnum>
     8        <refmiscinfo class="source">Samba</refmiscinfo>
     9        <refmiscinfo class="manual">System Administration tools</refmiscinfo>
     10        <refmiscinfo class="version">4.0</refmiscinfo>
    811</refmeta>
    912
  • vendor/current/source4/lib/registry/man/regtree.1.xml

    r740 r988  
    66        <refentrytitle>regtree</refentrytitle>
    77        <manvolnum>1</manvolnum>
     8        <refmiscinfo class="source">Samba</refmiscinfo>
     9        <refmiscinfo class="manual">System Administration tools</refmiscinfo>
     10        <refmiscinfo class="version">4.0</refmiscinfo>
    811</refmeta>
    912
  • vendor/current/source4/lib/registry/patchfile_dotreg.c

    r740 r988  
    7171                                   const DATA_BLOB data)
    7272{
     73        size_t converted_size = 0;
    7374        char *ret = NULL;
    7475
     
    8081                case REG_SZ:
    8182                        convert_string_talloc(mem_ctx,
    82                                                           CH_UTF16, CH_UNIX, data.data, data.length,
    83                                                           (void **)&ret, NULL, false);
     83                                              CH_UTF16, CH_UNIX, data.data, data.length,
     84                                              (void **)&ret, &converted_size);
    8485                        break;
    8586                case REG_DWORD:
     
    235236        bool result;
    236237        char *type_str = NULL;
    237         char *data_str;
    238         char *value;
     238        char *data_str = NULL;
     239        char *value = NULL;
    239240        bool continue_next_line = 0;
    240241
  • vendor/current/source4/lib/registry/patchfile_preg.c

    r740 r988  
    188188        }
    189189
    190         strncpy(preg_header.hdr, "PReg", 4);
     190        memcpy(preg_header.hdr, "PReg", sizeof(preg_header.hdr));
    191191        SIVAL(&preg_header.version, 0, 1);
    192192        write(data->fd, (uint8_t *)&preg_header, sizeof(preg_header));
  • vendor/current/source4/lib/registry/pyregistry.c

    r740 r988  
    2323#include "libcli/util/pyerrors.h"
    2424#include "lib/registry/registry.h"
    25 #include "lib/talloc/pytalloc.h"
     25#include <pytalloc.h>
    2626#include "lib/events/events.h"
    2727#include "auth/credentials/pycredentials.h"
     
    3232extern PyTypeObject PyHiveKey;
    3333
    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))
     34void 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))
    3739
    3840
     
    4850
    4951        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);
    5355}
    5456
     
    6365
    6466        result = reg_key_del_abs(ctx, path);
    65         PyErr_WERROR_IS_ERR_RAISE(result);
     67        PyErr_WERROR_NOT_OK_RAISE(result);
    6668
    6769        Py_RETURN_NONE;
     
    7981
    8082        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);
    8486}
    8587
     
    9395
    9496        result = reg_diff_apply(ctx, filename);
    95         PyErr_WERROR_IS_ERR_RAISE(result);
     97        PyErr_WERROR_NOT_OK_RAISE(result);
    9698
    9799        Py_RETURN_NONE;
     
    126128
    127129        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);
    129131
    130132        Py_RETURN_NONE;
     
    136138        struct registry_context *ctx;
    137139        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);
    140142}
    141143
     
    159161        .tp_methods = registry_methods,
    160162        .tp_new = registry_new,
    161         .tp_basicsize = sizeof(py_talloc_Object),
    162163        .tp_flags = Py_TPFLAGS_DEFAULT,
    163164};
     
    174175        result = hive_key_del(NULL, key, name);
    175176
    176         PyErr_WERROR_IS_ERR_RAISE(result);
     177        PyErr_WERROR_NOT_OK_RAISE(result);
    177178
    178179        Py_RETURN_NONE;
     
    185186
    186187        result = hive_key_flush(key);
    187         PyErr_WERROR_IS_ERR_RAISE(result);
     188        PyErr_WERROR_NOT_OK_RAISE(result);
    188189
    189190        Py_RETURN_NONE;
     
    201202        result = hive_key_del_value(NULL, key, name);
    202203
    203         PyErr_WERROR_IS_ERR_RAISE(result);
     204        PyErr_WERROR_NOT_OK_RAISE(result);
    204205
    205206        Py_RETURN_NONE;
     
    211212        uint32_t type;
    212213        DATA_BLOB value;
     214        Py_ssize_t value_length = 0;
    213215        WERROR result;
    214216        struct hive_key *key = PyHiveKey_AsHiveKey(self);
    215217
    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;
    218222
    219223        if (value.data != NULL)
     
    222226                result = hive_key_del_value(NULL, key, name);
    223227
    224         PyErr_WERROR_IS_ERR_RAISE(result);
     228        PyErr_WERROR_NOT_OK_RAISE(result);
    225229
    226230        Py_RETURN_NONE;
     
    284288
    285289        result = reg_open_hive(NULL, location, session_info, credentials,
    286                                tevent_context_init(NULL),
     290                               samba_tevent_context_init(NULL),
    287291                               lp_ctx, &hive_key);
    288292        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);
    292296}
    293297
     
    296300        .tp_methods = hive_key_methods,
    297301        .tp_new = hive_new,
    298         .tp_basicsize = sizeof(py_talloc_Object),
    299302        .tp_flags = Py_TPFLAGS_DEFAULT,
    300303};
     
    302305PyTypeObject PyRegistryKey = {
    303306        .tp_name = "RegistryKey",
    304         .tp_basicsize = sizeof(py_talloc_Object),
    305307        .tp_flags = Py_TPFLAGS_DEFAULT,
    306308};
     
    353355        }
    354356
    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);
    386358}
    387359
     
    429401                                   s4_event_context_init(NULL), lp_ctx, &key);
    430402        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);
    434406}
    435407
     
    460432static PyMethodDef py_registry_methods[] = {
    461433        { "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" },
    464434        { "open_ldb", (PyCFunction)py_open_ldb_file, METH_VARARGS|METH_KEYWORDS, "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key" },
    465435        { "open_hive", (PyCFunction)py_open_hive, METH_VARARGS|METH_KEYWORDS, "open_hive(location, session_info=None, credentials=None, loadparm_context=None) -> key" },
     
    472442{
    473443        PyObject *m;
    474         PyTypeObject *talloc_type = PyTalloc_GetObjectType();
    475 
    476         if (talloc_type == NULL)
     444
     445        if (pytalloc_BaseObject_PyType_Ready(&PyHiveKey) < 0)
    477446                return;
    478447
    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)
    484449                return;
    485450
    486         if (PyType_Ready(&PyRegistry) < 0)
    487                 return;
    488 
    489         if (PyType_Ready(&PyRegistryKey) < 0)
     451        if (pytalloc_BaseObject_PyType_Ready(&PyRegistryKey) < 0)
    490452                return;
    491453
  • vendor/current/source4/lib/registry/regf.c

    r740 r988  
    164164        unsigned int i;
    165165
    166         *offset = 0;
     166        if (offset != NULL) {
     167                *offset = 0;
     168        }
    167169
    168170        if (size == 0)
     
    252254        ret.length = size - 0x4;
    253255        if (offset) {
    254                 uint32_t new_rel_offset;
     256                uint32_t new_rel_offset = 0;
    255257                *offset = hbin->offset_from_first + rel_offset + 0x20;
    256258                SMB_ASSERT(hbin_by_offset(data, *offset, &new_rel_offset) == hbin);
     
    17191721
    17201722        if (key->nk->subkeys_offset != -1) {
    1721                 char *sk_name;
    17221723                struct hive_key *sk = (struct hive_key *)key;
    17231724                unsigned int i = key->nk->num_subkeys;
    17241725                while (i--) {
     1726                        char *sk_name;
     1727                        const char *p = NULL;
     1728
    17251729                        /* Get subkey information. */
    17261730                        error = regf_get_subkey_by_index(parent_nk, sk, 0,
    1727                                                          (const char **)&sk_name,
     1731                                                         &p,
    17281732                                                         NULL, NULL);
    17291733                        if (!W_ERROR_IS_OK(error)) {
     
    17311735                                return error;
    17321736                        }
     1737                        sk_name = discard_const_p(char, p);
    17331738
    17341739                        /* Delete subkey. */
     
    17441749
    17451750        if (key->nk->values_offset != -1) {
    1746                 char *val_name;
    17471751                struct hive_key *sk = (struct hive_key *)key;
    17481752                DATA_BLOB data;
    17491753                unsigned int i = key->nk->num_values;
    17501754                while (i--) {
     1755                        char *val_name;
     1756                        const char *p = NULL;
     1757
    17511758                        /* Get value information. */
    17521759                        error = regf_get_value(parent_nk, sk, 0,
    1753                                                (const char **)&val_name,
     1760                                               &p,
    17541761                                               NULL, &data);
    17551762                        if (!W_ERROR_IS_OK(error)) {
     
    17571764                                return error;
    17581765                        }
     1766                        val_name = discard_const_p(char, p);
    17591767
    17601768                        /* Delete value. */
     
    18641872        uint32_t i;
    18651873        uint32_t tmp_vk_offset, vk_offset, old_vk_offset = (uint32_t) -1;
    1866         DATA_BLOB values;
     1874        DATA_BLOB values = {0};
    18671875
    18681876        ZERO_STRUCT(vk);
     
    18911899        if (old_vk_offset == -1) {
    18921900                vk.header = "vk";
    1893                 vk.name_length = strlen(name);
    1894                 if (name != NULL && name[0] != 0) {
     1901                if (name != NULL && name[0] != '\0') {
    18951902                        vk.flag = 1;
    18961903                        vk.data_name = name;
     1904                        vk.name_length = strlen(name);
    18971905                } else {
     1906                        vk.flag = 0;
    18981907                        vk.data_name = NULL;
    1899                         vk.flag = 0;
     1908                        vk.name_length = 0;
    19001909                }
    19011910        } else {
     
    22122221
    22132222        if (pull->data.data == NULL) {
    2214                 DEBUG(0, ("Error reading data\n"));
     2223                DEBUG(0, ("Error reading data from file: %s\n", location));
    22152224                talloc_free(regf);
    22162225                return WERR_GENERAL_FAILURE;
     
    22212230
    22222231        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));
    22232233                talloc_free(regf);
    22242234                return WERR_GENERAL_FAILURE;
  • vendor/current/source4/lib/registry/registry.h

    r740 r988  
    33   Registry interface
    44   Copyright (C) Gerald Carter                        2002.
    5    Copyright (C) Jelmer Vernooij                                          2003-2007.
     5   Copyright (C) Jelmer Vernooij                        2003-2007.
    66
    77   This program is free software; you can redistribute it and/or modify
     
    380380 * Open the registry on a remote machine.
    381381 */
    382 WERROR reg_open_remote(struct registry_context **ctx,
     382WERROR reg_open_remote(TALLOC_CTX *mem_ctx,
     383                       struct registry_context **ctx,
    383384                       struct auth_session_info *session_info,
    384385                       struct cli_credentials *credentials,
  • vendor/current/source4/lib/registry/rpc.c

    r740 r988  
    476476};
    477477
    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,
    479480                                struct auth_session_info *session_info,
    480481                                struct cli_credentials *credentials,
     
    486487        struct rpc_registry_context *rctx;
    487488
    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);
    491492        W_ERROR_HAVE_NO_MEMORY(rctx);
    492493
  • vendor/current/source4/lib/registry/tests/diff.c

    r740 r988  
    2626#include "librpc/gen_ndr/winreg.h"
    2727#include "param/param.h"
     28#include "lib/registry/tests/proto.h"
    2829
    2930struct diff_tcase_data {
  • vendor/current/source4/lib/registry/tests/generic.c

    r740 r988  
    2525#include "librpc/gen_ndr/winreg.h"
    2626#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"
    3128
    3229static bool test_str_regtype(struct torture_context *ctx)
     
    9592        DATA_BLOB db;
    9693        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);
    9895        torture_assert_str_equal(ctx, "bla",
    9996                                 reg_val_data_string(ctx, REG_SZ, db),
     
    132129                                            "stationary traveller",
    133130                                            strlen("stationary traveller"),
    134                                             (void **)&data.data, &data.length, false);
     131                                            (void **)&data.data, &data.length);
    135132        torture_assert_str_equal(ctx, "camel = REG_SZ : stationary traveller",
    136133                                 reg_val_description(ctx, "camel", REG_SZ, data),
     
    146143                                            "west berlin",
    147144                                            strlen("west berlin"),
    148                                             (void **)&data.data, &data.length, false);
     145                                            (void **)&data.data, &data.length);
    149146        torture_assert_str_equal(ctx, "<No Name> = REG_SZ : west berlin",
    150147                                 reg_val_description(ctx, NULL, REG_SZ, data),
  • vendor/current/source4/lib/registry/tests/hive.c

    r740 r988  
    2828#include "param/param.h"
    2929#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
     32static bool test_del_nonexistent_key(struct torture_context *tctx,
    3233                                     const void *test_data)
    3334{
     
    346347static void tcase_add_tests(struct torture_tcase *tcase)
    347348{
    348         torture_tcase_add_simple_test_const(tcase, "del_nonexistant_key",
    349                                                 test_del_nonexistant_key);
     349        torture_tcase_add_simple_test_const(tcase, "del_nonexistent_key",
     350                                                test_del_nonexistent_key);
    350351        torture_tcase_add_simple_test_const(tcase, "add_subkey",
    351352                                                test_add_subkey);
     
    375376}
    376377
    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 
    401378static bool hive_setup_ldb(struct torture_context *tctx, void **data)
    402379{
     
    447424}
    448425
    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 
    457426struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx)
    458427{
    459428        struct torture_tcase *tcase;
    460429        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);
    468430
    469431        tcase = torture_suite_add_tcase(suite, "ldb");
  • vendor/current/source4/lib/registry/tests/registry.c

    r740 r988  
    2727#include "libcli/security/security.h"
    2828#include "system/filesys.h"
     29#include "lib/registry/tests/proto.h"
    2930
    3031/**
     
    255256        uint32_t num_subkeys, num_values;
    256257        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))
    259261                return false;
    260262
     
    267269        torture_assert_int_equal(tctx, num_subkeys, 0, "num subkeys");
    268270        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");
    269284
    270285        return true;
     
    409424        char value[4];
    410425        uint32_t type;
     426        const char *data_val = "temp";
     427
    411428        SIVAL(value, 0, 42);
    412429
     
    432449        torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
    433450
     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
    434463        return true;
    435464}
     
    446475        uint32_t type;
    447476        char value[4];
     477        const char *data_val = "temp";
     478
    448479        SIVAL(value, 0, 42);
    449480
     
    468499                                  "getting missing value");
    469500
     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
    470513        return true;
    471514}
     
    483526        const char *name;
    484527        char value[4];
     528        const char *data_val = "temp";
     529
    485530        SIVAL(value, 0, 42);
    486531
     
    506551        torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS,
    507552                                  "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");
    508564
    509565        return true;
  • vendor/current/source4/lib/registry/tools/common.c

    r414 r988  
    3232        WERROR error;
    3333
    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);
    3535
    3636        if (!W_ERROR_IS_OK(error)) {
  • vendor/current/source4/lib/registry/tools/regdiff.c

    r740 r988  
    2929enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL };
    3030
    31 static struct registry_context *open_backend(poptContext pc,
     31static struct registry_context *open_backend(TALLOC_CTX *mem_ctx,
     32                                             poptContext pc,
    3233                                             struct tevent_context *ev_ctx,
    3334                                             struct loadparm_context *lp_ctx,
     
    4344                return NULL;
    4445        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);
    4647                break;
    4748        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,
    4950                                        remote_host, ev_ctx);
    5051                break;
    5152        case REG_NULL:
    52                 error = reg_open_local(NULL, &ctx);
     53                error = reg_open_local(mem_ctx, &ctx);
    5354                break;
    5455        }
     
    119120        }
    120121
    121         ev_ctx = s4_event_context_init(NULL);
     122        ev_ctx = s4_event_context_init(ctx);
    122123
    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);
    124125        if (h1 == NULL)
    125126                return 1;
    126127
    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);
    128129        if (h2 == NULL)
    129130                return 1;
  • vendor/current/source4/lib/registry/tools/regpatch.c

    r740 r988  
    2727#include "events/events.h"
    2828
    29 int main(int argc, char **argv)
     29int main(int argc, const char **argv)
    3030{
    3131        int opt;
     
    4545        };
    4646
    47         pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
     47        pc = poptGetContext(argv[0], argc, argv, long_options,0);
    4848
    4949        while((opt = poptGetNextOpt(pc)) != -1) {
  • vendor/current/source4/lib/registry/tools/regshell.c

    r740 r988  
    3838};
    3939
    40 static WERROR get_full_path(struct regshell_context *ctx, char *path, char **ret_path)
    41 {
    42         char *dir;
     40static WERROR get_full_path(struct regshell_context *ctx, const char *path, char **ret_path)
     41{
     42        const char *dir;
    4343        char *tmp;
    4444        char *new_path;
     
    5050        }               
    5151
    52         dir = strtok(path, "\\");
     52        dir = strtok(discard_const_p(char, path), "\\");
    5353        if (dir == NULL) {
    5454                *ret_path = new_path;
     
    9999 */
    100100
    101 static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv)
     101static WERROR cmd_info(struct regshell_context *ctx, int argc, const char **argv)
    102102{
    103103        struct security_descriptor *sec_desc = NULL;
     
    151151}
    152152
    153 static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv)
     153static WERROR cmd_predef(struct regshell_context *ctx, int argc, const char **argv)
    154154{
    155155        struct registry_key *ret = NULL;
     
    177177
    178178static WERROR cmd_pwd(struct regshell_context *ctx,
    179                       int argc, char **argv)
     179                      int argc, const char **argv)
    180180{
    181181        if (ctx->predef) {
     
    186186}
    187187
    188 static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv)
     188static WERROR cmd_set(struct regshell_context *ctx, int argc, const char **argv)
    189189{
    190190        struct registry_value val;
     
    210210}
    211211
    212 static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv)
     212static WERROR cmd_ck(struct regshell_context *ctx, int argc, const char **argv)
    213213{
    214214        struct registry_key *nkey = NULL;
     
    239239}
    240240
    241 static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv)
     241static WERROR cmd_print(struct regshell_context *ctx, int argc, const char **argv)
    242242{
    243243        uint32_t value_type;
     
    263263}
    264264
    265 static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
     265static WERROR cmd_ls(struct regshell_context *ctx, int argc, const char **argv)
    266266{
    267267        unsigned int i;
     
    293293        return WERR_OK;
    294294}
    295 static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv)
     295static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, const char **argv)
    296296{
    297297        struct registry_key *tmp;
     
    315315
    316316static WERROR cmd_rmkey(struct regshell_context *ctx,
    317                         int argc, char **argv)
     317                        int argc, const char **argv)
    318318{
    319319        WERROR error;
     
    335335}
    336336
    337 static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv)
     337static WERROR cmd_rmval(struct regshell_context *ctx, int argc, const char **argv)
    338338{
    339339        WERROR error;
     
    356356
    357357_NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx,
    358                                   int argc, char **argv)
     358                                  int argc, const char **argv)
    359359{
    360360        exit(0);
    361361}
    362362
    363 static WERROR cmd_help(struct regshell_context *ctx, int, char **);
     363static WERROR cmd_help(struct regshell_context *ctx, int, const char **);
    364364
    365365static struct {
     
    367367        const char *alias;
    368368        const char *help;
    369         WERROR (*handle)(struct regshell_context *ctx, int argc, char **argv);
     369        WERROR (*handle)(struct regshell_context *ctx, int argc, const char **argv);
    370370} regshell_cmds[] = {
    371371        {"ck", "cd", "Change current key", cmd_ck },
     
    385385
    386386static WERROR cmd_help(struct regshell_context *ctx,
    387                        int argc, char **argv)
     387                       int argc, const char **argv)
    388388{
    389389        unsigned int i;
     
    400400{
    401401        int argc;
    402         char **argv = NULL;
     402        const char **argv = NULL;
    403403        int ret, i;
    404404
    405         if ((ret = poptParseArgvString(line, &argc, (const char ***) &argv)) != 0) {
     405        if ((ret = poptParseArgvString(line, &argc, &argv)) != 0) {
    406406                fprintf(stderr, "regshell: %s\n", poptStrerror(ret));
    407407                return WERR_INVALID_PARAM;
     
    429429        char **matches;
    430430        size_t len, samelen=0;
    431         unsigned int i, count=1;
     431        int i, count=1;
    432432
    433433        matches = malloc_array_p(char *, MAX_COMPLETIONS);
     
    509509                        break;
    510510                } else {
     511                        int n;
     512
    511513                        printf("Error creating completion list: %s\n",
    512514                                win_errstr(status));
     515
     516                        for (n = j; n >= 0; n--) {
     517                                SAFE_FREE(matches[n]);
     518                        }
     519                        SAFE_FREE(matches);
    513520                        talloc_free(mem_ctx);
    514521                        return NULL;
     
    545552}
    546553
    547 int main(int argc, char **argv)
     554int main(int argc, const char **argv)
    548555{
    549556        int opt;
     
    564571        };
    565572
    566         pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
     573        pc = poptGetContext(argv[0], argc, argv, long_options,0);
    567574
    568575        while((opt = poptGetNextOpt(pc)) != -1) {
  • vendor/current/source4/lib/registry/tools/regtree.c

    r740 r988  
    9393
    9494        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))) {
    9696                DEBUG(0, ("Error getting security descriptor\n"));
    9797        }
     
    9999}
    100100
    101 int main(int argc, char **argv)
     101int main(int argc, const char **argv)
    102102{
    103103        int opt;
     
    123123        };
    124124
    125         pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
     125        pc = poptGetContext(argv[0], argc, argv, long_options,0);
    126126
    127127        while((opt = poptGetNextOpt(pc)) != -1) {
  • vendor/current/source4/lib/registry/util.c

    r740 r988  
    2727                                   const DATA_BLOB data)
    2828{
     29        size_t converted_size = 0;
    2930        char *ret = NULL;
    3031
     
    3839                                              CH_UTF16, CH_UNIX,
    3940                                              data.data, data.length,
    40                                               (void **)&ret, NULL, false);
     41                                              (void **)&ret, &converted_size);
    4142                        break;
    4243                case REG_DWORD:
     
    163164                                                     data_str, strlen(data_str)+1,
    164165                                                     (void **)&data->data,
    165                                                      &data->length, false);
     166                                                     &data->length);
    166167                        break;
    167168                case REG_MULTI_SZ:
  • vendor/current/source4/lib/registry/wscript_build

    r740 r988  
    1212
    1313bld.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
    1918        )
    2019
Note: See TracChangeset for help on using the changeset viewer.