*/
#include "includes.h"
-#include "pstring.h"
#include "torture/torture.h"
-#include "torture/winbind/proto.h"
#include "nsswitch/winbind_client.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/netlogon.h"
#include "param/param.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
#define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \
NSS_STATUS __got, __expected = (expected); \
DO_STRUCT_REQ_REP(WINBINDD_INFO, NULL, &rep);
separator = torture_setting_string(torture,
- "winbindd separator",
+ "winbindd_separator",
lp_winbind_separator(torture->lp_ctx));
+
torture_assert_int_equal(torture,
rep.data.info.winbind_separator,
*separator,
static bool torture_winbind_struct_priv_pipe_dir(struct torture_context *torture)
{
struct winbindd_response rep;
- const char *default_dir;
- const char *expected_dir;
const char *got_dir;
ZERO_STRUCT(rep);
torture_assert(torture, got_dir, "NULL WINBINDD_PRIV_PIPE_DIR\n");
- default_dir = lock_path(torture, torture->lp_ctx,
- WINBINDD_PRIV_SOCKET_SUBDIR);
- expected_dir = torture_setting_string(torture,
- "winbindd private pipe dir",
- default_dir);
-
- torture_assert_str_equal(torture, got_dir, expected_dir,
- "WINBINDD_PRIV_PIPE_DIR doesn't match");
-
SAFE_FREE(rep.extra_data.data);
return true;
}
DO_STRUCT_REQ_REP(WINBINDD_NETBIOS_NAME, NULL, &rep);
expected = torture_setting_string(torture,
- "winbindd netbios name",
+ "winbindd_netbios_name",
lp_netbios_name(torture->lp_ctx));
expected = strupper_talloc(torture, expected);
-
+
torture_assert_str_equal(torture,
rep.data.netbios_name, expected,
"winbindd's netbios name doesn't match");
torture_comment(torture, "Running WINBINDD_DOMAIN_NAME (struct based)\n");
expected = torture_setting_string(torture,
- "winbindd netbios domain",
+ "winbindd_netbios_domain",
lp_workgroup(torture->lp_ctx));
get_winbind_domain(torture, &domain);
torture_assert_str_equal(torture,
rep.data.auth.error_string,
- nt_errstr(NT_STATUS_OK),
+ get_friendly_nt_error_msg(NT_STATUS_OK),
"WINBINDD_CHECK_MACHACC ok: error_string");
torture_assert_int_equal(torture,
struct winbindd_response rep;
struct torture_trust_domain *d = NULL;
uint32_t dcount = 0;
- fstring line;
+ char line[256];
const char *extra_data;
ZERO_STRUCT(req);
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
extra_data = (char *)rep.extra_data.data;
+ if (!extra_data) {
+ return true;
+ }
+
torture_assert(torture, extra_data, "NULL trust list");
- while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
+ while (next_token(&extra_data, line, "\n", sizeof(line))) {
char *p, *lp;
d = talloc_realloc(torture, d,
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
list1 = (char *)rep.extra_data.data;
- torture_assert(torture, list1, "NULL trust list");
torture_comment(torture, "%s\n", list1);
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
list2 = (char *)rep.extra_data.data;
- torture_assert(torture, list2, "NULL trust list");
/*
* The list_all_domains parameter should be ignored
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
if (i == 0) {
struct dom_sid *builtin_sid;
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
struct dom_sid *sid;
{
bool ok;
bool strict = torture_setting_bool(torture, "strict mode", false);
+ const char *domain_name = torture_setting_string(torture,
+ "winbindd_netbios_domain",
+ lp_workgroup(torture->lp_ctx));
struct torture_trust_domain *listd = NULL;
- uint32_t i;
+ uint32_t i, count = 0;
torture_comment(torture, "Running WINBINDD_GETDCNAME (struct based)\n");
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
+ /* getdcname is not expected to work on "BUILTIN" or our own
+ * domain */
+ if (strequal(listd[i].netbios_name, "BUILTIN") ||
+ strequal(listd[i].netbios_name, domain_name)) {
+ continue;
+ }
+
ZERO_STRUCT(req);
ZERO_STRUCT(rep);
/* TODO: check rep.data.dc_name; */
torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n",
req.domain_name, rep.data.dc_name);
+ count++;
}
+ if (strict) {
+ torture_assert(torture, count > 0,
+ "WiNBINDD_GETDCNAME was not tested");
+ }
return true;
}
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
struct winbindd_response rep;
char **u = NULL;
uint32_t count;
- fstring name;
+ char name[256];
const char *extra_data;
ZERO_STRUCT(req);
torture_assert(torture, extra_data, "NULL extra data");
for(count = 0;
- next_token(&extra_data, name, ",", sizeof(fstring));
+ next_token(&extra_data, name, ",", sizeof(name));
count++)
{
u = talloc_realloc(torture, u, char *, count + 2);
torture_comment(torture, "Running WINBINDD_LIST_USERS (struct based)\n");
ok = get_user_list(torture, &users);
- torture_assert(torture, ok, "failed to get group list");
+ torture_assert(torture, ok, "failed to get user list");
for (count = 0; users[count]; count++) { }
return true;
}
-static bool get_group_list(struct torture_context *torture, char ***groups)
+static bool get_group_list(struct torture_context *torture,
+ unsigned int *num_entries,
+ char ***groups)
{
struct winbindd_request req;
struct winbindd_response rep;
char **g = NULL;
uint32_t count;
- fstring name;
+ char name[256];
const char *extra_data;
ZERO_STRUCT(req);
ZERO_STRUCT(rep);
DO_STRUCT_REQ_REP(WINBINDD_LIST_GROUPS, &req, &rep);
-
extra_data = (char *)rep.extra_data.data;
+
+ *num_entries = rep.data.num_entries;
+
+ if (*num_entries == 0) {
+ torture_assert(torture, extra_data == NULL,
+ "extra data is null for >0 reported entries\n");
+ *groups = NULL;
+ return true;
+ }
+
torture_assert(torture, extra_data, "NULL extra data");
for(count = 0;
- next_token(&extra_data, name, ",", sizeof(fstring));
+ next_token(&extra_data, name, ",", sizeof(name));
count++)
{
g = talloc_realloc(torture, g, char *, count + 2);
SAFE_FREE(rep.extra_data.data);
+ torture_assert_int_equal(torture, *num_entries, count,
+ "Wrong number of group entries reported.");
+
*groups = g;
return true;
}
torture_comment(torture, "Running WINBINDD_LIST_GROUPS (struct based)\n");
- ok = get_group_list(torture, &groups);
+ ok = get_group_list(torture, &count, &groups);
torture_assert(torture, ok, "failed to get group list");
- for (count = 0; groups[count]; count++) { }
-
torture_comment(torture, "got %d groups\n", count);
return true;
struct winbindd_request req;
struct winbindd_response rep;
const char *extra_data;
- fstring line;
+ char line[256];
uint32_t count = 0;
struct torture_domain_sequence *s = NULL;
extra_data = (char *)rep.extra_data.data;
torture_assert(torture, extra_data, "NULL sequence list");
- while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
+ while (next_token(&extra_data, line, "\n", sizeof(line))) {
char *p, *lp;
uint32_t seq;
ZERO_STRUCT(req);
ZERO_STRUCT(rep);
req.data.num_entries = 1;
- DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep);
+ if (torture_setting_bool(torture, "samba3", false)) {
+ bool __noop = false;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_GETPWENT, &req, &rep,
+ NSS_STATUS_SUCCESS, false, __noop=true,
+ NULL);
+ } else {
+ DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep);
+ }
pwent = (struct winbindd_pw *)rep.extra_data.data;
- torture_assert(torture, (pwent != NULL), "NULL pwent");
- torture_comment(torture, "name: %s, uid: %d, gid: %d, shell: %s\n",
- pwent->pw_name, pwent->pw_uid, pwent->pw_gid,
- pwent->pw_shell);
+ if (!torture_setting_bool(torture, "samba3", false)) {
+ torture_assert(torture, (pwent != NULL), "NULL pwent");
+ }
+ if (pwent) {
+ torture_comment(torture, "name: %s, uid: %d, gid: %d, shell: %s\n",
+ pwent->pw_name, pwent->pw_uid, pwent->pw_gid,
+ pwent->pw_shell);
+ }
return true;
}
struct winbindd_response rep;
char *sid;
char *name;
+ const char *domain_name = torture_setting_string(torture,
+ "winbindd_netbios_domain",
+ lp_workgroup(torture->lp_ctx));
ZERO_STRUCT(req);
ZERO_STRUCT(rep);
DO_STRUCT_REQ_REP(WINBINDD_LOOKUPSID, &req, &rep);
- name = talloc_asprintf(torture, "%s%c%s",
- rep.data.name.dom_name,
- winbind_separator(torture),
- rep.data.name.name);
+ if (strequal(rep.data.name.dom_name, domain_name)) {
+ name = talloc_asprintf(torture, "%s",
+ rep.data.name.name);
+ } else {
+ name = talloc_asprintf(torture, "%s%c%s",
+ rep.data.name.dom_name,
+ winbind_separator(torture),
+ rep.data.name.name);
+ }
torture_assert_casestr_equal(torture, list[count], name,
"LOOKUP_SID after LOOKUP_NAME != id");
{
uint32_t count;
- for (count = 0; list[count]; count++) {
+ for (count = 0; list && list[count]; count++) {
if (strequal(name, list[count])) {
return true;
}
bool strict = torture_setting_bool(torture, "strict mode", false);
char **users;
char **groups;
- uint32_t count;
+ uint32_t count, num_groups;
bool ok;
torture_comment(torture, "Running WINBINDD_LOOKUP_NAME_SID (struct based)\n");
torture_assert(torture, ok, "failed to retrieve list of users");
lookup_name_sid_list(torture, users);
- ok = get_group_list(torture, &groups);
+ ok = get_group_list(torture, &num_groups, &groups);
torture_assert(torture, ok, "failed to retrieve list of groups");
- lookup_name_sid_list(torture, groups);
+ if (num_groups > 0) {
+ lookup_name_sid_list(torture, groups);
+ }
ZERO_STRUCT(req);
ZERO_STRUCT(rep);