summaryrefslogtreecommitdiffstats
path: root/lib/nss_wrapper
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-02-18 23:23:28 +0100
committerGünther Deschner <gd@samba.org>2010-02-18 23:25:16 +0100
commit2eb83f29648c7647cff4ac6eb38830ae35fcbcb5 (patch)
treef4c07e026947c72a68b707eb1b335ae71b254c65 /lib/nss_wrapper
parent9b9c9fd1759eb1f76cb54d0b6aec600c3c3a8f8f (diff)
downloadsamba-2eb83f29648c7647cff4ac6eb38830ae35fcbcb5.tar.gz
samba-2eb83f29648c7647cff4ac6eb38830ae35fcbcb5.tar.xz
samba-2eb83f29648c7647cff4ac6eb38830ae35fcbcb5.zip
s4-smbtorture: add LOCAL-NSS-WRAPPER-DUPLICATES test.
Guenther
Diffstat (limited to 'lib/nss_wrapper')
-rw-r--r--lib/nss_wrapper/testsuite.c93
1 files changed, 92 insertions, 1 deletions
diff --git a/lib/nss_wrapper/testsuite.c b/lib/nss_wrapper/testsuite.c
index 3ecf48cfcdd..d6b48393182 100644
--- a/lib/nss_wrapper/testsuite.c
+++ b/lib/nss_wrapper/testsuite.c
@@ -3,7 +3,7 @@
local testing of the nss wrapper
- Copyright (C) Guenther Deschner 2009
+ Copyright (C) Guenther Deschner 2009-2010
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
@@ -849,6 +849,96 @@ static bool test_nwrap_reentrant_enumeration_crosschecks(struct torture_context
return true;
}
+static bool test_nwrap_passwd_duplicates(struct torture_context *tctx)
+{
+ int i, d;
+ struct passwd *pwd;
+ size_t num_pwd;
+ int duplicates = 0;
+
+ torture_assert(tctx, test_nwrap_enum_passwd(tctx, &pwd, &num_pwd),
+ "failed to enumerate passwd");
+
+ for (i=0; i < num_pwd; i++) {
+ const char *current_name = pwd[i].pw_name;
+ for (d=0; d < num_pwd; d++) {
+ const char *dup_name = pwd[d].pw_name;
+ if (d == i) {
+ continue;
+ }
+ if (!strequal(current_name, dup_name)) {
+ continue;
+ }
+
+ torture_warning(tctx, "found duplicate names:");
+ print_passwd(&pwd[d]);
+ print_passwd(&pwd[i]);
+ duplicates++;
+ }
+ }
+
+ if (duplicates) {
+ torture_fail(tctx, talloc_asprintf(tctx, "found %d duplicate names", duplicates));
+ }
+
+ return true;
+}
+
+static bool test_nwrap_group_duplicates(struct torture_context *tctx)
+{
+ int i, d;
+ struct group *grp;
+ size_t num_grp;
+ int duplicates = 0;
+
+ torture_assert(tctx, test_nwrap_enum_group(tctx, &grp, &num_grp),
+ "failed to enumerate group");
+
+ for (i=0; i < num_grp; i++) {
+ const char *current_name = grp[i].gr_name;
+ for (d=0; d < num_grp; d++) {
+ const char *dup_name = grp[d].gr_name;
+ if (d == i) {
+ continue;
+ }
+ if (!strequal(current_name, dup_name)) {
+ continue;
+ }
+
+ torture_warning(tctx, "found duplicate names:");
+ print_group(&grp[d]);
+ print_group(&grp[i]);
+ duplicates++;
+ }
+ }
+
+ if (duplicates) {
+ torture_fail(tctx, talloc_asprintf(tctx, "found %d duplicate names", duplicates));
+ }
+
+ return true;
+}
+
+
+static bool test_nwrap_duplicates(struct torture_context *tctx)
+{
+ const char *old_pwd = getenv("NSS_WRAPPER_PASSWD");
+ const char *old_group = getenv("NSS_WRAPPER_GROUP");
+
+ if (!old_pwd || !old_group) {
+ torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n");
+ torture_skip(tctx, "nothing to test\n");
+ }
+
+ torture_assert(tctx, test_nwrap_passwd_duplicates(tctx),
+ "failed to test users");
+ torture_assert(tctx, test_nwrap_group_duplicates(tctx),
+ "failed to test groups");
+
+ return true;
+}
+
+
struct torture_suite *torture_local_nss_wrapper(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "NSS-WRAPPER");
@@ -857,6 +947,7 @@ struct torture_suite *torture_local_nss_wrapper(TALLOC_CTX *mem_ctx)
torture_suite_add_simple_test(suite, "reentrant enumeration", test_nwrap_reentrant_enumeration);
torture_suite_add_simple_test(suite, "reentrant enumeration crosschecks", test_nwrap_reentrant_enumeration_crosschecks);
torture_suite_add_simple_test(suite, "membership", test_nwrap_membership);
+ torture_suite_add_simple_test(suite, "duplicates", test_nwrap_duplicates);
return suite;
}