summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorChristof Schmitt <cs@samba.org>2018-03-30 14:28:46 -0700
committerKarolin Seeger <kseeger@samba.org>2018-04-11 11:52:25 +0200
commitf901e8cc594526e50a18cf58edef48ca5b74bb29 (patch)
tree77fb647e90f22fcef66e1e715579ce7a5d8880ae /nsswitch
parentd2799ab5e45ad184bcb26fa8d0770711fe1907e8 (diff)
downloadsamba-f901e8cc594526e50a18cf58edef48ca5b74bb29.tar.gz
nsswitch: Fix wbcListUsers test
With an AD DC, wbcListUsers returns the users in the DOMAIN SEPARATOR USERNAME format. The test then calls wbcLookupName with the domain name and the previous string (including domain and separator) as username. Fix this by passing the correct username and adding some additional checks. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13312 Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> (cherry picked from commit 3c146be404affc894c0c702bbfbfcc4fb9ed902b)
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/libwbclient/tests/wbclient.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index e80afc4bd78..8c532bbaa75 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -296,6 +296,7 @@ static bool test_wbc_users(struct torture_context *tctx)
char *name = NULL;
char *sid_string = NULL;
wbcErr ret = false;
+ char separator;
torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
"%s", "wbcInterfaceDetails failed");
@@ -306,6 +307,7 @@ static bool test_wbc_users(struct torture_context *tctx)
ret,
fail,
"Failed to allocate domain_name");
+ separator = details->winbind_separator;
wbcFreeMemory(details);
details = NULL;
@@ -323,9 +325,38 @@ static bool test_wbc_users(struct torture_context *tctx)
struct wbcDomainSid sid;
enum wbcSidType name_type;
uint32_t num_sids;
+ const char *user;
+ char *c;
+
+ c = strchr(users[i], separator);
+
+ if (c == NULL) {
+ /*
+ * NT4 DC
+ * user name does not contain DOMAIN SEPARATOR prefix.
+ */
+
+ user = users[i];
+ } else {
+ /*
+ * AD DC
+ * user name starts with DOMAIN SEPARATOR prefix.
+ */
+ const char *dom;
+
+ *c = '\0';
+ dom = users[i];
+ user = c + 1;
+
+ torture_assert_str_equal_goto(tctx, dom, domain_name,
+ ret, fail, "Domain part "
+ "of user name does not "
+ "match domain name.\n");
+ }
torture_assert_wbc_ok_goto_fail(tctx,
- wbcLookupName(domain_name, users[i], &sid, &name_type),
+ wbcLookupName(domain_name, user,
+ &sid, &name_type),
"wbcLookupName of %s failed",
users[i]);
torture_assert_int_equal_goto(tctx,