summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-08-08 13:54:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:35 -0500
commit21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1 (patch)
treea865f0c7630a42d0c565a73da8b483a18210a0d2 /source3/torture
parent72c605b4fc518b498688ec032004fded0d2250d7 (diff)
downloadsamba-21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1.tar.gz
samba-21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1.tar.bz2
samba-21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1.zip
r17457: Add a test to do some operations on group mapping.
Volker (This used to be commit 68db058fdf508d5b4d38731ece21f5d92feca00c)
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/local-groupmap.c340
-rw-r--r--source3/torture/local-multikey.c211
-rw-r--r--source3/torture/torture.c169
3 files changed, 556 insertions, 164 deletions
diff --git a/source3/torture/local-groupmap.c b/source3/torture/local-groupmap.c
new file mode 100644
index 0000000000..bd6f060e71
--- /dev/null
+++ b/source3/torture/local-groupmap.c
@@ -0,0 +1,340 @@
+/*
+ Unix SMB/CIFS implementation.
+ Run some local tests for group mapping
+ Copyright (C) Volker Lendecke 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+#define CHECK_STATUS(_status, _expected) do { \
+ if (!NT_STATUS_EQUAL(_status, _expected)) { \
+ printf("(%d) Incorrect status %s - should be %s\n", \
+ __LINE__, nt_errstr(status), nt_errstr(_expected)); \
+ goto fail; \
+ }} while (0)
+
+static NTSTATUS create_v2_mapping(struct tdb_context *tdb,
+ const char *sid, gid_t gid,
+ enum SID_NAME_USE type,
+ const char *nt_name,
+ const char *comment)
+{
+ TDB_DATA key, data;
+ NTSTATUS status;
+
+ ZERO_STRUCT(data);
+
+ if (asprintf(&key.dptr, "UNIXGROUP/%s", sid) < 0) {
+ d_fprintf(stderr, "(%s) asprintf failed\n",
+ __location__);
+ return NT_STATUS_NO_MEMORY;
+ }
+ key.dsize = strlen(key.dptr)+1;
+
+ if (!tdb_pack_append(NULL, &data.dptr, &data.dsize, "ddff",
+ (uint32)gid, (uint32)type, nt_name, comment)) {
+ d_fprintf(stderr, "(%s) tdb_pack_append failed\n",
+ __location__);
+ SAFE_FREE(key.dptr);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (tdb_store(tdb, key, data, TDB_INSERT) < 0) {
+ status = map_ntstatus_from_tdb(tdb);
+ d_fprintf(stderr, "(%s) tdb_store failed: %s\n", __location__,
+ nt_errstr(status));
+ SAFE_FREE(key.dptr);
+ TALLOC_FREE(data.dptr);
+ return status;
+ }
+
+ SAFE_FREE(key.dptr);
+ TALLOC_FREE(data.dptr);
+ return NT_STATUS_OK;
+}
+
+#define NUM_ENTRIES (50)
+
+static NTSTATUS create_v2_db(BOOL invalid)
+{
+ struct tdb_context *tdb;
+ NTSTATUS status;
+ int i;
+
+ tdb = tdb_open_log(lock_path("group_mapping.tdb"), 0, TDB_DEFAULT,
+ O_RDWR|O_CREAT, 0600);
+ if (tdb == NULL) {
+ d_fprintf(stderr, "(%s) tdb_open_log failed: %s\n",
+ __location__, strerror(errno));
+ status = map_nt_error_from_unix(errno);
+ goto fail;
+ }
+
+ /* Empty the database */
+ tdb_traverse(tdb, tdb_traverse_delete_fn, NULL);
+
+ if (tdb_store_int32(tdb, "INFO/version", 2) < 0) {
+ status = map_ntstatus_from_tdb(tdb);
+ d_fprintf(stderr, "(%s) tdb_store_uint32 failed: %s\n",
+ __location__, nt_errstr(status));
+ goto fail;
+ }
+
+ for (i=1000; i<1000+NUM_ENTRIES; i++) {
+ char *sid, *name;
+ if (asprintf(&sid, "S-1-5-21-744032650-3806004166-77016029-%d",
+ i) < 0) {
+ d_fprintf(stderr, "(%s) asprintf failed\n",
+ __location__);
+ goto fail;
+ }
+ if (asprintf(&name, "Unix group %d", i) < 0) {
+ d_fprintf(stderr, "(%s) asprintf failed\n",
+ __location__);
+ SAFE_FREE(sid);
+ goto fail;
+ }
+ status = create_v2_mapping(tdb, sid, (gid_t)i,
+ SID_NAME_DOM_GRP, name, name);
+ SAFE_FREE(sid);
+ SAFE_FREE(name);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+ status = create_v2_mapping(tdb, "S-1-5-32-544", 10000,
+ SID_NAME_ALIAS, "Administrators",
+ "Machine Admins");
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = create_v2_mapping(tdb, "S-1-5-32-545", 10001,
+ SID_NAME_ALIAS, "Users", "Machine Users");
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ if (invalid) {
+ /* Map 10001 to two different SIDs */
+ status = create_v2_mapping(tdb, "S-1-5-32-999", 10001,
+ SID_NAME_ALIAS, "Overlapping",
+ "Invalid mapping");
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+
+ status = create_v2_mapping(tdb, "S-1-5-32-546", -1,
+ SID_NAME_ALIAS, "notthere", "To remove");
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = NT_STATUS_OK;
+ fail:
+ if (tdb != NULL) {
+ tdb_close(tdb);
+ }
+ return status;
+}
+
+static BOOL groupmap_diff(const GROUP_MAP *m1, const GROUP_MAP *m2)
+{
+ return ((sid_compare(&m1->sid, &m2->sid) != 0) ||
+ (m1->gid != m2->gid) ||
+ (m1->sid_name_use != m2->sid_name_use) ||
+ (strcmp(m1->nt_name, m2->nt_name) != 0) ||
+ (strcmp(m1->comment, m2->comment) != 0));
+}
+
+#undef GROUPDB_V3
+
+BOOL run_local_groupmap(int dummy)
+{
+ TALLOC_CTX *mem_ctx;
+ BOOL ret = False;
+ NTSTATUS status;
+ GROUP_MAP *maps = NULL;
+ size_t num_maps = 0;
+
+ mem_ctx = talloc_init("run_local_groupmap");
+ if (mem_ctx == NULL) {
+ d_fprintf(stderr, "(%s) talloc_init failed\n",
+ __location__);
+ return False;
+ }
+
+#ifdef GROUPDB_V3
+ status = create_v2_db(True);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ {
+ GROUP_MAP map;
+ if (pdb_getgrgid(&map, 10001)) {
+ d_fprintf(stderr, "(%s) upgrading an invalid group db "
+ "worked\n", __location__);
+ goto fail;
+ }
+ }
+#endif
+
+ status = create_v2_db(False);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ /* This tests upgrading the database, as well as listing */
+
+ if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &maps, &num_maps,
+ False)) {
+ d_fprintf(stderr, "(%s) pdb_enum_group_mapping failed\n",
+ __location__);
+ goto fail;
+ }
+
+ if (num_maps != NUM_ENTRIES+2) {
+ d_fprintf(stderr, "(%s) expected %d entries, got %d\n",
+ __location__, NUM_ENTRIES+2, num_maps);
+ goto fail;
+ }
+
+ /* See if getgrsid, getgrgid and getgrnam find the same entry */
+
+ {
+ DOM_SID sid;
+ GROUP_MAP map, map1;
+ string_to_sid(&sid, "S-1-5-32-545");
+
+ ZERO_STRUCT(map);
+ if (!pdb_getgrsid(&map, &sid)) {
+ d_fprintf(stderr, "(%s) pdb_getgrsid failed\n",
+ __location__);
+ goto fail;
+ }
+
+ ZERO_STRUCT(map1);
+ if (!pdb_getgrgid(&map1, map.gid)) {
+ d_fprintf(stderr, "(%s) pdb_getgrgid failed\n",
+ __location__);
+ goto fail;
+ }
+
+ if (groupmap_diff(&map1, &map)) {
+ d_fprintf(stderr, "(%s) getgrsid/getgrgid disagree\n",
+ __location__);
+ goto fail;
+ }
+
+ ZERO_STRUCT(map1);
+ if (!pdb_getgrnam(&map1, map.nt_name)) {
+ d_fprintf(stderr, "(%s) pdb_getgrnam failed\n",
+ __location__);
+ goto fail;
+ }
+
+ if (groupmap_diff(&map1, &map)) {
+ d_fprintf(stderr, "(%s) getgrsid/getgrnam disagree\n",
+ __location__);
+ goto fail;
+ }
+ }
+
+ /* See if pdb_delete_group_mapping_entry works */
+
+ {
+ DOM_SID sid;
+ GROUP_MAP map, map1;
+ string_to_sid(&sid, "S-1-5-32-545");
+
+ if (!pdb_getgrsid(&map, &sid)) {
+ d_fprintf(stderr, "(%s) did not find S-1-5-32-545\n",
+ __location__);
+ goto fail;
+ }
+
+ status = pdb_delete_group_mapping_entry(sid);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = pdb_delete_group_mapping_entry(sid);
+#ifdef GROUPDB_V3
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+#else
+ CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
+#endif
+
+ if (pdb_getgrsid(&map1, &sid)) {
+ d_fprintf(stderr, "(%s) getgrsid found deleted "
+ "entry\n", __location__);
+ goto fail;
+ }
+
+ if (pdb_getgrgid(&map1, map.gid)) {
+ d_fprintf(stderr, "(%s) getgrgid found deleted "
+ "entry\n", __location__);
+ goto fail;
+ }
+
+ if (pdb_getgrnam(&map1, map.nt_name)) {
+ d_fprintf(stderr, "(%s) getgrnam found deleted "
+ "entry\n", __location__);
+ goto fail;
+ }
+
+ }
+
+ /* See if pdb_update_group_mapping_entry works */
+
+ {
+ DOM_SID sid;
+ gid_t oldgid;
+ GROUP_MAP map, map1;
+ string_to_sid(&sid, "S-1-5-32-544");
+
+ if (!pdb_getgrsid(&map, &sid)) {
+ d_fprintf(stderr, "(%s) did not find S-1-5-32-544\n",
+ __location__);
+ goto fail;
+ }
+
+ oldgid = map.gid;
+ map.gid = 4711;
+
+ status = pdb_update_group_mapping_entry(&map);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ if (pdb_getgrgid(&map1, oldgid)) {
+ d_fprintf(stderr, "(%s) getgrgid found outdated "
+ "entry\n", __location__);
+ goto fail;
+ }
+
+ /* Change to an existing entry, see "create_db_v2" */
+
+ map.gid = 1000;
+ status = pdb_update_group_mapping_entry(&map);
+#ifdef GROUPDB_V3
+ CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
+ if (!pdb_getgrgid(&map1, 4711)) {
+ d_fprintf(stderr, "(%s) update_group changed entry "
+ "upon failure\n", __location__);
+ goto fail;
+ }
+#else
+ CHECK_STATUS(status, NT_STATUS_OK);
+#endif
+ }
+
+ ret = True;
+ fail:
+ if (maps != NULL) {
+ SAFE_FREE(maps);
+ }
+ TALLOC_FREE(mem_ctx);
+ return ret;
+}
+
diff --git a/source3/torture/local-multikey.c b/source3/torture/local-multikey.c
new file mode 100644
index 0000000000..83de2f0b40
--- /dev/null
+++ b/source3/torture/local-multikey.c
@@ -0,0 +1,211 @@
+/*
+ Unix SMB/CIFS implementation.
+ Run some local tests on the local tdb multikey wrapper
+ Copyright (C) Volker Lendecke 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+static char **key_fn(TALLOC_CTX *mem_ctx, TDB_DATA data,
+ void *private_data)
+{
+ fstring key, value;
+ char **result;
+
+ result = TALLOC_ARRAY(mem_ctx, char *, 3);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ if (tdb_unpack(data.dptr, data.dsize, "ff", key, value) < 0) {
+ d_fprintf(stderr, "tdb_unpack failed\n");
+ TALLOC_FREE(result);
+ return NULL;
+ }
+ result[0] = talloc_strdup(result, key);
+ result[1] = talloc_strdup(result, value);
+ result[2] = NULL;
+
+ if ((result[0] == NULL) || (result[1] == NULL)) {
+ d_fprintf(stderr, "talloc_strdup failed\n");
+ TALLOC_FREE(result);
+ return NULL;
+ }
+
+ return result;
+}
+
+static NTSTATUS multikey_add(struct tdb_context *tdb, const char *key,
+ const char *value)
+{
+ NTSTATUS status;
+ TDB_DATA data;
+
+ data.dptr = NULL;
+ data.dsize = 0;
+
+ if (!tdb_pack_append(NULL, &data.dptr, &data.dsize,
+ "ff", key, value)) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = tdb_add_keyed(tdb, key_fn, data, NULL);
+ TALLOC_FREE(data.dptr);
+ return status;
+}
+
+#define CHECK_STATUS(_status, _expected) do { \
+ if (!NT_STATUS_EQUAL(_status, _expected)) { \
+ printf("(%d) Incorrect status %s - should be %s\n", \
+ __LINE__, nt_errstr(status), nt_errstr(_expected)); \
+ ret = False; \
+ goto fail; \
+ }} while (0)
+
+#define NUM_ELEMENTS (50)
+
+BOOL run_local_multikey(int dummy)
+{
+ TALLOC_CTX *mem_ctx;
+ char *prim;
+ const char *tdbname = "multi_key_test.tdb";
+ struct tdb_context *tdb = NULL;
+ NTSTATUS status;
+ BOOL ret = False;
+ TDB_DATA data;
+ int i;
+ fstring key,value;
+
+ unlink(tdbname);
+
+ mem_ctx = talloc_init("run_local_multikey");
+ if (mem_ctx == NULL) {
+ d_fprintf(stderr, "talloc_init failed\n");
+ return False;
+ }
+
+ tdb = tdb_open(tdbname, 0, 0, O_CREAT|O_RDWR, 0644);
+ if (tdb == NULL) {
+ d_fprintf(stderr, "tdb_open failed: %s\n", strerror(errno));
+ goto fail;
+ }
+
+ for (i=0; i<NUM_ELEMENTS; i++) {
+ fstr_sprintf(key, "KEY%d", i);
+ fstr_sprintf(value, "VAL%d", i);
+
+ status = multikey_add(tdb, key, value);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "tdb_add_keyed failed: %s\n",
+ nt_errstr(status));
+ goto fail;
+ }
+ }
+
+ {
+ struct tdb_keyed_iterator *it = tdb_enum_keyed(mem_ctx, tdb);
+ if (it == NULL) {
+ d_printf("tdb_enum_keyed failed\n");
+ goto fail;
+ }
+
+ i = 0;
+
+ while (tdb_next_keyed(it, &data)) {
+ i += 1;
+ if (i > 1000) {
+ d_printf("tdb_next_keyed overrun\n");
+ goto fail;
+ }
+ }
+
+ if (i != NUM_ELEMENTS) {
+ d_printf("counted %d, elements, expected %d\n",
+ i, NUM_ELEMENTS);
+ goto fail;
+ }
+ }
+
+ status = multikey_add(tdb, "KEY35", "FOOO");
+ CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
+ status = multikey_add(tdb, "KEY42", "VAL45");
+ CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
+ status = multikey_add(tdb, "FOO", "VAL45");
+ CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
+
+ for (i=0; i<NUM_ELEMENTS; i++) {
+ fstr_sprintf(key, "KEY%d", i);
+ fstr_sprintf(value, "VAL%d", i);
+
+ status = tdb_find_keyed(mem_ctx, tdb, 0, key, &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = tdb_find_keyed(mem_ctx, tdb, 1, value, &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = tdb_find_keyed(mem_ctx, tdb, 1, key, &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+ status = tdb_find_keyed(mem_ctx, tdb, 0, value, &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+ }
+
+ status = tdb_find_keyed(mem_ctx, tdb, 0, "FOO", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+ status = tdb_find_keyed(mem_ctx, tdb, 1, "BAR", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+
+ status = tdb_find_keyed(mem_ctx, tdb, 0, "KEY0", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(data);
+ if (tdb_pack_append(mem_ctx, &data.dptr, &data.dsize, "ff",
+ "NEWKEY", "NEWVAL") < 0) {
+ d_printf("tdb_pack_alloc failed\n");
+ goto fail;
+ }
+
+ status = tdb_update_keyed(tdb, prim, key_fn, data, NULL);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = tdb_find_keyed(mem_ctx, tdb, 0, "KEY0", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+ status = tdb_find_keyed(mem_ctx, tdb, 1, "VAL0", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+ status = tdb_find_keyed(mem_ctx, tdb, 0, "NEWKEY", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = tdb_find_keyed(mem_ctx, tdb, 1, "NEWVAL", &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = tdb_del_keyed(tdb, key_fn, prim, NULL);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ for (i=1; i<NUM_ELEMENTS; i++) {
+ fstr_sprintf(key, "KEY%d", i);
+ status = tdb_find_keyed(mem_ctx, tdb, 0, key, &data, &prim);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = tdb_del_keyed(tdb, key_fn, prim, NULL);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+
+ ret = True;
+ fail:
+ if (tdb != NULL) {
+ tdb_close(tdb);
+ }
+ unlink(tdbname);
+ TALLOC_FREE(mem_ctx);
+ return ret;
+}
+
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 009eb84787..67d13068bb 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4797,169 +4797,6 @@ static BOOL run_local_substitute(int dummy)
return (diff == 0);
}
-static char **key_fn(TALLOC_CTX *mem_ctx, TDB_DATA data,
- void *private_data)
-{
- fstring key, value;
- char **result;
-
- result = TALLOC_ARRAY(mem_ctx, char *, 3);
- if (result == NULL) {
- return NULL;
- }
-
- if (tdb_unpack(data.dptr, data.dsize, "ff", key, value) < 0) {
- d_fprintf(stderr, "tdb_unpack failed\n");
- TALLOC_FREE(result);
- return NULL;
- }
- result[0] = talloc_strdup(result, key);
- result[1] = talloc_strdup(result, value);
- result[2] = NULL;
-
- if ((result[0] == NULL) || (result[1] == NULL)) {
- d_fprintf(stderr, "talloc_strdup failed\n");
- TALLOC_FREE(result);
- return NULL;
- }
-
- return result;
-}
-
-static NTSTATUS multikey_add(struct tdb_context *tdb, const char *key,
- const char *value)
-{
- NTSTATUS status;
- TDB_DATA data;
-
- data.dptr = NULL;
- data.dsize = 0;
-
- if (!tdb_pack_append(NULL, &data.dptr, &data.dsize,
- "ff", key, value)) {
- return NT_STATUS_NO_MEMORY;
- }
-
- status = tdb_add_keyed(tdb, key_fn, data, NULL);
- TALLOC_FREE(data.dptr);
- return status;
-}
-
-#define CHECK_STATUS(_status, _expected) do { \
- if (!NT_STATUS_EQUAL(_status, _expected)) { \
- printf("(%d) Incorrect status %s - should be %s\n", \
- __LINE__, nt_errstr(status), nt_errstr(_expected)); \
- ret = False; \
- goto fail; \
- }} while (0)
-
-static BOOL run_local_multikey(int dummy)
-{
- TALLOC_CTX *mem_ctx;
- char *prim;
- const char *tdbname = "multi_key_test.tdb";
- struct tdb_context *tdb = NULL;
- NTSTATUS status;
- BOOL ret = False;
- TDB_DATA data;
- int i;
- fstring key,value;
-
- unlink(tdbname);
-
- mem_ctx = talloc_init("run_local_multikey");
- if (mem_ctx == NULL) {
- d_fprintf(stderr, "talloc_init failed\n");
- return False;
- }
-
- tdb = tdb_open(tdbname, 0, 0, O_CREAT|O_RDWR, 0644);
- if (tdb == NULL) {
- d_fprintf(stderr, "tdb_open failed: %s\n", strerror(errno));
- goto fail;
- }
-
- for (i=0; i<200; i++) {
- fstr_sprintf(key, "KEY%d", i);
- fstr_sprintf(value, "VAL%d", i);
-
- status = multikey_add(tdb, key, value);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr, "tdb_add_keyed failed: %s\n",
- nt_errstr(status));
- goto fail;
- }
- }
-
- status = multikey_add(tdb, "KEY35", "FOOO");
- CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
- status = multikey_add(tdb, "KEY42", "VAL45");
- CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
- status = multikey_add(tdb, "FOO", "VAL45");
- CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS);
-
- for (i=0; i<200; i++) {
- fstr_sprintf(key, "KEY%d", i);
- fstr_sprintf(value, "VAL%d", i);
-
- status = tdb_find_keyed(mem_ctx, tdb, 0, key, &data, &prim);
- CHECK_STATUS(status, NT_STATUS_OK);
- status = tdb_find_keyed(mem_ctx, tdb, 1, value, &data, &prim);
- CHECK_STATUS(status, NT_STATUS_OK);
- status = tdb_find_keyed(mem_ctx, tdb, 1, key, &data, &prim);
- CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
- status = tdb_find_keyed(mem_ctx, tdb, 0, value, &data, &prim);
- CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
- }
-
- status = tdb_find_keyed(mem_ctx, tdb, 0, "FOO", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
- status = tdb_find_keyed(mem_ctx, tdb, 1, "BAR", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
-
- status = tdb_find_keyed(mem_ctx, tdb, 0, "KEY0", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_OK);
-
- ZERO_STRUCT(data);
- if (tdb_pack_append(mem_ctx, &data.dptr, &data.dsize, "ff",
- "NEWKEY", "NEWVAL") < 0) {
- d_printf("tdb_pack_alloc failed\n");
- goto fail;
- }
-
- status = tdb_update_keyed(tdb, prim, key_fn, data, NULL);
- CHECK_STATUS(status, NT_STATUS_OK);
-
- status = tdb_find_keyed(mem_ctx, tdb, 0, "KEY0", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
- status = tdb_find_keyed(mem_ctx, tdb, 1, "VAL0", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
- status = tdb_find_keyed(mem_ctx, tdb, 0, "NEWKEY", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_OK);
- status = tdb_find_keyed(mem_ctx, tdb, 1, "NEWVAL", &data, &prim);
- CHECK_STATUS(status, NT_STATUS_OK);
-
- status = tdb_del_keyed(tdb, key_fn, prim, NULL);
- CHECK_STATUS(status, NT_STATUS_OK);
-
- for (i=1; i<200; i++) {
- fstr_sprintf(key, "KEY%d", i);
- status = tdb_find_keyed(mem_ctx, tdb, 0, key, &data, &prim);
- CHECK_STATUS(status, NT_STATUS_OK);
- status = tdb_del_keyed(tdb, key_fn, prim, NULL);
- CHECK_STATUS(status, NT_STATUS_OK);
- }
-
- ret = True;
- fail:
- if (tdb != NULL) {
- tdb_close(tdb);
- }
- unlink(tdbname);
- TALLOC_FREE(mem_ctx);
- return ret;
-}
-
static double create_procs(BOOL (*fn)(int), BOOL *result)
{
int i, status;
@@ -5112,6 +4949,7 @@ static struct {
{ "EATEST", run_eatest, 0},
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-MULTIKEY", run_local_multikey, 0},
+ { "LOCAL-GROUPMAP", run_local_groupmap, 0},
{NULL, NULL, 0}};
@@ -5260,7 +5098,7 @@ static void usage(void)
fstrcpy(workgroup, lp_workgroup());
- while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Ac:ks:b:")) != EOF) {
+ while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Ac:ks:b:S:")) != EOF) {
switch (opt) {
case 'p':
port_to_use = atoi(optarg);
@@ -5268,6 +5106,9 @@ static void usage(void)
case 's':
srandom(atoi(optarg));
break;
+ case 'S':
+ lp_load(optarg,True,False,False,True);
+ break;
case 'W':
fstrcpy(workgroup,optarg);
break;