summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-10-04 23:20:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:07:44 -0500
commit2cf665b8fd84fd3201c0bbe52ce71dfca9da1249 (patch)
treee0bd33c5615fe16b91fb0137bd530fe0912b2fc8 /source4/torture
parent6fb6999185456477438ae744bb597cf986fb23f4 (diff)
downloadsamba-2cf665b8fd84fd3201c0bbe52ce71dfca9da1249.tar.gz
samba-2cf665b8fd84fd3201c0bbe52ce71dfca9da1249.tar.bz2
samba-2cf665b8fd84fd3201c0bbe52ce71dfca9da1249.zip
r25509: Extend the WINBIND-STRUCT-LOOKUP_NAME_SID test to also
verify failure of the lookup for an invalid SID and an invalid name. Michael (This used to be commit 69043a7b1ca82f5c9976e605cf6bb9df8afbad18)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/winbind/struct_based.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index 78f9273903..dd7a1850ab 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -937,8 +937,27 @@ static bool lookup_name_sid_list(struct torture_context *torture, char **list)
return true;
}
+static bool name_is_in_list(const char *name, const char **list)
+{
+ uint32_t count;
+
+ for (count = 0; list[count]; count++) {
+ if (strequal(name, list[count])) {
+ return true;
+ }
+ }
+ return false;
+}
+
static bool torture_winbind_struct_lookup_name_sid(struct torture_context *torture)
{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ const char *invalid_sid = "S-0-0-7";
+ char *domain;
+ const char *invalid_user = "noone";
+ char *invalid_name;
+ bool strict = torture_setting_bool(torture, "strict mode", false);
char **users;
char **groups;
uint32_t count;
@@ -949,11 +968,55 @@ static bool torture_winbind_struct_lookup_name_sid(struct torture_context *tortu
ok = get_user_list(torture, &users);
torture_assert(torture, ok, "failed to retrieve list of users");
lookup_name_sid_list(torture, users);
- talloc_free(users);
ok = get_group_list(torture, &groups);
torture_assert(torture, ok, "failed to retrieve list of groups");
lookup_name_sid_list(torture, groups);
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ fstrcpy(req.data.sid, invalid_sid);
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_LOOKUPSID, &req, &rep,
+ NSS_STATUS_NOTFOUND,
+ strict,
+ ok=false,
+ talloc_asprintf(torture,
+ "invalid sid %s was resolved",
+ invalid_sid));
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ /* try to find an invalid name... */
+
+ count = 0;
+ get_winbind_domain(torture, &domain);
+ do {
+ count++;
+ invalid_name = talloc_asprintf(torture, "%s\\%s%u",
+ domain,
+ invalid_user, count);
+ } while(name_is_in_list(invalid_name, (const char **)users) ||
+ name_is_in_list(invalid_name, (const char **)groups));
+
+ fstrcpy(req.data.name.dom_name, domain);
+ fstrcpy(req.data.name.name,
+ talloc_asprintf(torture, "%s%u", invalid_user,
+ count));
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_LOOKUPNAME, &req, &rep,
+ NSS_STATUS_NOTFOUND,
+ strict,
+ ok=false,
+ talloc_asprintf(torture,
+ "invalid name %s was resolved",
+ invalid_name));
+
+ talloc_free(users);
talloc_free(groups);
return true;