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
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
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.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "libcli/auth/libcli_auth.h"
#include "torture/rpc/rpc.h"
#include "libcli/security/security.h"
+#include "param/param.h"
struct test_join {
struct dcerpc_pipe *p;
when finished
*/
-struct test_join *torture_create_testuser(const char *username,
+struct test_join *torture_create_testuser(struct torture_context *torture,
+ const char *username,
const char *domain,
uint16_t acct_type,
const char **random_password)
int policy_min_pw_len = 0;
struct test_join *join;
char *random_pw;
- const char *dc_binding = lp_parm_string(-1, "torture", "dc_binding");
+ const char *dc_binding = torture_setting_string(torture, "dc_binding", NULL);
join = talloc(NULL, struct test_join);
if (join == NULL) {
status = dcerpc_pipe_connect(join,
&join->p,
dc_binding,
- &dcerpc_table_samr,
- cmdline_credentials, NULL);
+ &ndr_table_samr,
+ cmdline_credentials, NULL, torture->lp_ctx);
} else {
- status = torture_rpc_connection(join,
+ status = torture_rpc_connection(torture,
&join->p,
- &dcerpc_table_samr);
+ &ndr_table_samr);
}
if (!NT_STATUS_IS_OK(status)) {
return NULL;
printf("Setting account password '%s'\n", random_pw);
+ ZERO_STRUCT(u);
s.in.user_handle = &join->user_handle;
s.in.info = &u;
s.in.level = 24;
s.in.info = &u;
s.in.level = 21;
- u.info21.acct_flags = acct_type;
+ u.info21.acct_flags = acct_type | ACB_PWNOEXP;
u.info21.fields_present = SAMR_FIELD_ACCT_FLAGS | SAMR_FIELD_DESCRIPTION | SAMR_FIELD_COMMENT | SAMR_FIELD_FULL_NAME;
u.info21.comment.string = talloc_asprintf(join,
u.info21.description.string = talloc_asprintf(join,
"Samba4 torture account created by host %s: %s",
- lp_netbios_name(), timestring(join, time(NULL)));
+ lp_netbios_name(torture->lp_ctx),
+ timestring(join, time(NULL)));
printf("Resetting ACB flags, force pw change time\n");
}
-_PUBLIC_ struct test_join *torture_join_domain(const char *machine_name,
+_PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
+ const char *machine_name,
uint32_t acct_flags,
struct cli_credentials **machine_credentials)
{
struct samr_SetUserInfo s;
union samr_UserInfo u;
- tj = talloc(NULL, struct test_join);
+ tj = talloc(tctx, struct test_join);
if (!tj) return NULL;
libnet_r = talloc(tj, struct libnet_JoinDomain);
return NULL;
}
- libnet_ctx = libnet_context_init(NULL);
+ libnet_ctx = libnet_context_init(tctx->ev, tctx->lp_ctx);
if (!libnet_ctx) {
talloc_free(tj);
return NULL;
tj->libnet_r = libnet_r;
libnet_ctx->cred = cmdline_credentials;
- libnet_r->in.binding = lp_parm_string(-1, "torture", "binding");
+ libnet_r->in.binding = torture_setting_string(tctx, "binding", NULL);
if (!libnet_r->in.binding) {
- libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", lp_parm_string(-1, "torture", "host"));
+ libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", torture_setting_string(tctx, "host", NULL));
}
libnet_r->in.level = LIBNET_JOINDOMAIN_SPECIFIED;
libnet_r->in.netbios_name = machine_name;
}
libnet_r->in.acct_type = acct_flags;
- libnet_r->in.recreate_account = True;
+ libnet_r->in.recreate_account = true;
status = libnet_JoinDomain(libnet_ctx, libnet_r, libnet_r);
if (!NT_STATUS_IS_OK(status)) {
u.info21.description.string = talloc_asprintf(tj,
"Samba4 torture account created by host %s: %s",
- lp_netbios_name(), timestring(tj, time(NULL)));
+ lp_netbios_name(tctx->lp_ctx), timestring(tj, time(NULL)));
status = dcerpc_samr_SetUserInfo(tj->p, tj, &s);
if (!NT_STATUS_IS_OK(status)) {
}
*machine_credentials = cli_credentials_init(tj);
- cli_credentials_set_conf(*machine_credentials);
+ cli_credentials_set_conf(*machine_credentials, tctx->lp_ctx);
cli_credentials_set_workstation(*machine_credentials, machine_name, CRED_SPECIFIED);
cli_credentials_set_domain(*machine_credentials, libnet_r->out.domain_name, CRED_SPECIFIED);
if (libnet_r->out.realm) {
return &join->user_handle;
}
-NTSTATUS torture_leave_ads_domain(TALLOC_CTX *mem_ctx, struct libnet_JoinDomain *libnet_r)
+static NTSTATUS torture_leave_ads_domain(TALLOC_CTX *mem_ctx, struct libnet_JoinDomain *libnet_r)
{
int rtn;
TALLOC_CTX *tmp_ctx;
return join->dom_dns_name;
}
+const char *torture_join_server_dn_str(struct test_join *join)
+{
+ if (join->libnet_r) {
+ return join->libnet_r->out.server_dn_str;
+ }
+ return NULL;
+}
+
+#if 0 /* Left as the documentation of the join process, but see new implementation in libnet_become_dc.c */
struct test_join_ads_dc {
struct test_join *join;
};
/* W2K3: see libnet/libnet_become_dc.c */
return join;
}
-
-void torture_leave_domain_ads_dc(struct test_join_ads_dc *join)
-{
-/* W2K3: see libnet/libnet_unbecome_dc.c */
-
- if (join->join) {
- torture_leave_domain(join->join);
- }
- talloc_free(join);
-}
+#endif