#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
#include "libcli/rap/rap.h"
#include "torture/torture.h"
#include "torture/util.h"
#include "libcli/composite/composite.h"
#include "libcli/smb_composite/smb_composite.h"
#include "libcli/auth/libcli_auth.h"
-#include "lib/crypto/crypto.h"
+#include "../lib/crypto/crypto.h"
#include "auth/ntlmssp/ntlmssp.h"
-#include "libcli/security/proto.h"
+#include "libcli/security/security.h"
#include "param/param.h"
#include "lib/registry/registry.h"
#include "libcli/resolve/resolve.h"
struct cli_credentials *anon_creds;
struct smb_composite_sesssetup setup;
struct smbcli_options options;
+ struct smbcli_session_options session_options;
mem_ctx = talloc_init("torture_bind_authcontext");
}
lp_smbcli_options(torture->lp_ctx, &options);
+ lp_smbcli_session_options(torture->lp_ctx, &session_options);
status = smbcli_full_connection(mem_ctx, &cli,
torture_setting_string(torture, "host", NULL),
lp_smb_ports(torture->lp_ctx),
- "IPC$", NULL, cmdline_credentials,
+ "IPC$", NULL,
+ lp_socket_options(torture->lp_ctx),
+ cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options, &session_options,
+ lp_iconv_convenience(torture->lp_ctx),
+ lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
goto done;
}
- session2 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options);
if (session2 == NULL) {
d_printf("smbcli_session_init failed\n");
goto done;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.workgroup = "";
setup.in.credentials = anon_creds;
+ setup.in.gensec_settings = lp_gensec_settings(torture, torture->lp_ctx);
status = smb_composite_sesssetup(session2, &setup);
if (!NT_STATUS_IS_OK(status)) {
struct lsa_ObjectAttribute objectattr;
struct lsa_OpenPolicy2 openpolicy;
struct lsa_QueryInfoPolicy query;
+ union lsa_PolicyInformation *info = NULL;
struct policy_handle handle;
struct lsa_Close close_handle;
}
status = dcerpc_bind_auth(lsa_pipe, &ndr_table_lsarpc,
- credentials, lp_ctx, auth_type, auth_level,
+ credentials, lp_gensec_settings(lp_ctx, lp_ctx), auth_type, auth_level,
NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("dcerpc_bind_auth failed: %s\n", nt_errstr(status));
query.in.handle = &handle;
query.in.level = LSA_POLICY_INFO_DOMAIN;
+ query.out.info = &info;
status = dcerpc_lsa_QueryInfoPolicy(lsa_pipe, mem_ctx, &query);
if (!NT_STATUS_IS_OK(status)) {
bool ret = false;
struct smbcli_state *cli;
struct smbcli_options options;
+ struct smbcli_session_options session_options;
mem_ctx = talloc_init("torture_bind_authcontext");
}
lp_smbcli_options(torture->lp_ctx, &options);
+ lp_smbcli_session_options(torture->lp_ctx, &session_options);
status = smbcli_full_connection(mem_ctx, &cli,
torture_setting_string(torture, "host", NULL),
lp_smb_ports(torture->lp_ctx),
- "IPC$", NULL, cmdline_credentials,
+ "IPC$", NULL,
+ lp_socket_options(torture->lp_ctx),
+ cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options, &session_options,
+ lp_iconv_convenience(torture->lp_ctx),
+ lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
char **domain,
struct dcerpc_pipe **result_pipe,
struct policy_handle **result_handle,
- struct dom_sid **sid)
+ struct dom_sid **sid_p)
{
struct dcerpc_pipe *samr_pipe;
NTSTATUS status;
struct samr_Connect2 conn;
struct samr_EnumDomains enumdom;
uint32_t resume_handle = 0;
+ uint32_t num_entries = 0;
+ struct samr_SamArray *sam = NULL;
struct samr_LookupDomain l;
+ struct dom_sid2 *sid = NULL;
int dom_idx;
struct lsa_String domain_name;
struct lsa_String user_name;
if (admin_creds != NULL) {
status = dcerpc_bind_auth(samr_pipe, &ndr_table_samr,
- admin_creds, lp_ctx, auth_type, auth_level,
+ admin_creds, lp_gensec_settings(lp_ctx, lp_ctx), auth_type, auth_level,
NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("dcerpc_bind_auth failed: %s\n",
enumdom.in.resume_handle = &resume_handle;
enumdom.in.buf_size = (uint32_t)-1;
enumdom.out.resume_handle = &resume_handle;
+ enumdom.out.num_entries = &num_entries;
+ enumdom.out.sam = &sam;
status = dcerpc_samr_EnumDomains(samr_pipe, mem_ctx, &enumdom);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
- if (enumdom.out.num_entries != 2) {
+ if (*enumdom.out.num_entries != 2) {
d_printf("samr_EnumDomains returned %d entries, expected 2\n",
- enumdom.out.num_entries);
+ *enumdom.out.num_entries);
status = NT_STATUS_UNSUCCESSFUL;
goto fail;
}
- dom_idx = strequal(enumdom.out.sam->entries[0].name.string,
+ dom_idx = strequal(sam->entries[0].name.string,
"builtin") ? 1:0;
l.in.connect_handle = &conn_handle;
- domain_name.string = enumdom.out.sam->entries[0].name.string;
+ domain_name.string = sam->entries[dom_idx].name.string;
*domain = talloc_strdup(mem_ctx, domain_name.string);
l.in.domain_name = &domain_name;
+ l.out.sid = &sid;
status = dcerpc_samr_LookupDomain(samr_pipe, mem_ctx, &l);
if (!NT_STATUS_IS_OK(status)) {
o.in.connect_handle = &conn_handle;
o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- o.in.sid = l.out.sid;
+ o.in.sid = *l.out.sid;
o.out.domain_handle = &domain_handle;
status = dcerpc_samr_OpenDomain(samr_pipe, mem_ctx, &o);
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
struct samr_LookupNames ln;
struct samr_OpenUser ou;
+ struct samr_Ids rids, types;
ln.in.domain_handle = &domain_handle;
ln.in.num_names = 1;
ln.in.names = &user_name;
+ ln.out.rids = &rids;
+ ln.out.types = &types;
status = dcerpc_samr_LookupNames(samr_pipe, mem_ctx, &ln);
if (!NT_STATUS_IS_OK(status)) {
ou.in.domain_handle = &domain_handle;
ou.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- user_rid = ou.in.rid = ln.out.rids.ids[0];
+ user_rid = ou.in.rid = ln.out.rids->ids[0];
ou.out.user_handle = user_handle;
status = dcerpc_samr_OpenUser(samr_pipe, mem_ctx, &ou);
*result_pipe = samr_pipe;
*result_handle = user_handle;
- if (sid != NULL) {
- *sid = dom_sid_add_rid(mem_ctx, l.out.sid, user_rid);
+ if (sid_p != NULL) {
+ *sid_p = dom_sid_add_rid(mem_ctx, *l.out.sid, user_rid);
}
return NT_STATUS_OK;
struct samr_SetUserInfo sui;
struct samr_QueryUserInfo qui;
union samr_UserInfo u_info;
+ union samr_UserInfo *info;
DATA_BLOB session_key;
arcfour_crypt_blob(u_info.info23.password.data, 516,
&session_key);
u_info.info23.info.password_expired = 0;
- u_info.info23.info.fields_present = SAMR_FIELD_PASSWORD |
- SAMR_FIELD_PASSWORD2 |
+ u_info.info23.info.fields_present = SAMR_FIELD_NT_PASSWORD_PRESENT |
+ SAMR_FIELD_LM_PASSWORD_PRESENT |
SAMR_FIELD_EXPIRED_FLAG;
sui2.in.user_handle = wks_handle;
sui2.in.info = &u_info;
qui.in.user_handle = wks_handle;
qui.in.level = 21;
+ qui.out.info = &info;
status = dcerpc_samr_QueryUserInfo(samr_pipe, tmp_ctx, &qui);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- qui.out.info->info21.allow_password_change = 0;
- qui.out.info->info21.force_password_change = 0;
- qui.out.info->info21.account_name.string = NULL;
- qui.out.info->info21.rid = 0;
- qui.out.info->info21.acct_expiry = 0;
- qui.out.info->info21.fields_present = 0x81827fa; /* copy usrmgr.exe */
+ info->info21.allow_password_change = 0;
+ info->info21.force_password_change = 0;
+ info->info21.account_name.string = NULL;
+ info->info21.rid = 0;
+ info->info21.acct_expiry = 0;
+ info->info21.fields_present = 0x81827fa; /* copy usrmgr.exe */
- u_info.info21 = qui.out.info->info21;
+ u_info.info21 = info->info21;
sui.in.user_handle = wks_handle;
sui.in.info = &u_info;
sui.in.level = 21;
{
struct samr_QueryUserInfo q;
+ union samr_UserInfo *info;
q.in.user_handle = wks_handle;
q.in.level = 21;
+ q.out.info = &info;
status = dcerpc_samr_QueryUserInfo(samr_pipe, mem_ctx, &q);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- last_password_change = q.out.info->info21.last_password_change;
+ last_password_change = info->info21.last_password_change;
}
cli_credentials_set_domain(wks_creds, dom_name, CRED_SPECIFIED);
cli_credentials_get_workstation(wks_creds));
i21->acct_flags = ACB_WSTRUST;
i21->fields_present = SAMR_FIELD_FULL_NAME |
- SAMR_FIELD_ACCT_FLAGS | SAMR_FIELD_PASSWORD;
+ SAMR_FIELD_ACCT_FLAGS | SAMR_FIELD_NT_PASSWORD_PRESENT;
+ /* this would break the test result expectations
+ i21->fields_present |= SAMR_FIELD_EXPIRED_FLAG;
+ i21->password_expired = 1;
+ */
encode_pw_buffer(u_info.info25.password.data,
cli_credentials_get_password(wks_creds),
encode_pw_buffer(u_info.info24.password.data,
cli_credentials_get_password(wks_creds),
STR_UNICODE);
- u_info.info24.pw_len =
- strlen_m(cli_credentials_get_password(wks_creds))*2;
+ /* just to make this test pass */
+ u_info.info24.password_expired = 1;
status = dcerpc_fetch_session_key(samr_pipe, &session_key);
if (!NT_STATUS_IS_OK(status)) {
{
struct samr_QueryUserInfo q;
+ union samr_UserInfo *info;
q.in.user_handle = wks_handle;
q.in.level = 21;
+ q.out.info = &info;
status = dcerpc_samr_QueryUserInfo(samr_pipe, mem_ctx, &q);
if (!NT_STATUS_IS_OK(status)) {
if (use_level25) {
if (last_password_change
- == q.out.info->info21.last_password_change) {
+ == info->info21.last_password_change) {
d_printf("(%s) last_password_change unchanged "
"during join, level25 must change "
"it\n", __location__);
}
else {
if (last_password_change
- != q.out.info->info21.last_password_change) {
+ != info->info21.last_password_change) {
d_printf("(%s) last_password_change changed "
"during join, level24 doesn't "
"change it\n", __location__);
struct netr_Credential netr_srv_creds;
uint32_t negotiate_flags;
struct netr_ServerAuthenticate2 a;
- struct creds_CredentialState *creds_state;
+ struct netlogon_creds_CredentialState *creds_state;
struct netr_Credential netr_cred;
struct samr_Password mach_pw;
generate_random_buffer(netr_cli_creds.data,
sizeof(netr_cli_creds.data));
r.in.credentials = &netr_cli_creds;
- r.out.credentials = &netr_srv_creds;
+ r.out.return_credentials = &netr_srv_creds;
status = dcerpc_netr_ServerReqChallenge(net_pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
negotiate_flags = NETLOGON_NEG_AUTH2_FLAGS;
E_md4hash(cli_credentials_get_password(wks_cred), mach_pw.hash);
- creds_state = talloc(mem_ctx, struct creds_CredentialState);
- creds_client_init(creds_state, r.in.credentials,
- r.out.credentials, &mach_pw,
- &netr_cred, negotiate_flags);
-
a.in.server_name = talloc_asprintf(
mem_ctx, "\\\\%s", dcerpc_server_name(net_pipe));
a.in.account_name = talloc_asprintf(
a.in.negotiate_flags = &negotiate_flags;
a.out.negotiate_flags = &negotiate_flags;
a.in.credentials = &netr_cred;
- a.out.credentials = &netr_cred;
+ a.out.return_credentials = &netr_cred;
+
+ creds_state = netlogon_creds_client_init(mem_ctx,
+ a.in.account_name,
+ a.in.computer_name,
+ r.in.credentials,
+ r.out.return_credentials, &mach_pw,
+ &netr_cred, negotiate_flags);
status = dcerpc_netr_ServerAuthenticate2(net_pipe, mem_ctx, &a);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- if (!creds_client_check(creds_state, a.out.credentials)) {
+ if (!netlogon_creds_client_check(creds_state, a.out.return_credentials)) {
d_printf("creds_client_check failed\n");
goto done;
}
#if 1
net_pipe->conn->flags |= (DCERPC_SIGN | DCERPC_SEAL);
status = dcerpc_bind_auth(net_pipe, &ndr_table_netlogon,
- wks_creds, lp_ctx, DCERPC_AUTH_TYPE_SCHANNEL,
+ wks_creds, lp_gensec_settings(lp_ctx, lp_ctx), DCERPC_AUTH_TYPE_SCHANNEL,
DCERPC_AUTH_LEVEL_PRIVACY,
NULL);
#else
for (i=2; i<4; i++) {
int flags;
DATA_BLOB chal, nt_resp, lm_resp, names_blob, session_key;
- struct creds_CredentialState *creds_state;
+ struct netlogon_creds_CredentialState *creds_state;
struct netr_Authenticator netr_auth, netr_auth2;
struct netr_NetworkInfo ninfo;
struct netr_PasswordInfo pinfo;
struct netr_LogonSamLogon r;
+ union netr_LogonLevel logon;
+ union netr_Validation validation;
+ uint8_t authoritative;
+ struct netr_Authenticator return_authenticator;
flags = CLI_CRED_LANMAN_AUTH | CLI_CRED_NTLM_AUTH |
CLI_CRED_NTLMv2_AUTH;
generate_random_buffer(chal.data, chal.length);
names_blob = NTLMv2_generate_names_blob(
- mem_ctx, lp_iconv_convenience(lp_ctx),
+ mem_ctx,
cli_credentials_get_workstation(user_creds),
cli_credentials_get_domain(user_creds));
status = cli_credentials_get_ntlm_response(
}
creds_state = cli_credentials_get_netlogon_creds(wks_creds);
- creds_client_authenticator(creds_state, &netr_auth);
+ netlogon_creds_client_authenticator(creds_state, &netr_auth);
ninfo.identity_info.account_name.string =
cli_credentials_get_username(user_creds);
ninfo.lm.length = lm_resp.length;
ninfo.lm.data = lm_resp.data;
+ logon.network = &ninfo;
+
r.in.server_name = talloc_asprintf(
mem_ctx, "\\\\%s", dcerpc_server_name(net_pipe));
ZERO_STRUCT(netr_auth2);
r.in.return_authenticator = &netr_auth2;
r.in.logon_level = 2;
r.in.validation_level = i;
- r.in.logon.network = &ninfo;
- r.out.return_authenticator = NULL;
+ r.in.logon = &logon;
+ r.out.validation = &validation;
+ r.out.authoritative = &authoritative;
+ r.out.return_authenticator = &return_authenticator;
status = dcerpc_netr_LogonSamLogon(net_pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
}
if ((r.out.return_authenticator == NULL) ||
- (!creds_client_check(creds_state,
+ (!netlogon_creds_client_check(creds_state,
&r.out.return_authenticator->cred))) {
d_printf("Credentials check failed!\n");
goto done;
}
- creds_client_authenticator(creds_state, &netr_auth);
+ netlogon_creds_client_authenticator(creds_state, &netr_auth);
pinfo.identity_info = ninfo.identity_info;
ZERO_STRUCT(pinfo.lmpassword.hash);
sizeof(pinfo.ntpassword.hash),
&session_key);
+ logon.password = &pinfo;
+
r.in.logon_level = 1;
- r.in.logon.password = &pinfo;
- r.out.return_authenticator = NULL;
+ r.in.logon = &logon;
+ r.out.return_authenticator = &return_authenticator;
status = dcerpc_netr_LogonSamLogon(net_pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
}
if ((r.out.return_authenticator == NULL) ||
- (!creds_client_check(creds_state,
+ (!netlogon_creds_client_check(creds_state,
&r.out.return_authenticator->cred))) {
d_printf("Credentials check failed!\n");
goto done;
{
struct netr_ServerPasswordSet s;
char *password = generate_random_str(wks_creds, 8);
- struct creds_CredentialState *creds_state;
+ struct netlogon_creds_CredentialState *creds_state;
+ struct netr_Authenticator credential, return_authenticator;
+ struct samr_Password new_password;
s.in.server_name = talloc_asprintf(
mem_ctx, "\\\\%s", dcerpc_server_name(net_pipe));
s.in.account_name = talloc_asprintf(
mem_ctx, "%s$", s.in.computer_name);
s.in.secure_channel_type = SEC_CHAN_WKSTA;
- E_md4hash(password, s.in.new_password.hash);
+ s.in.credential = &credential;
+ s.in.new_password = &new_password;
+ s.out.return_authenticator = &return_authenticator;
+
+ E_md4hash(password, new_password.hash);
creds_state = cli_credentials_get_netlogon_creds(wks_creds);
- creds_des_encrypt(creds_state, &s.in.new_password);
- creds_client_authenticator(creds_state, &s.in.credential);
+ netlogon_creds_des_encrypt(creds_state, &new_password);
+ netlogon_creds_client_authenticator(creds_state, &credential);
status = dcerpc_netr_ServerPasswordSet(net_pipe, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- if (!creds_client_check(creds_state,
- &s.out.return_authenticator.cred)) {
+ if (!netlogon_creds_client_check(creds_state,
+ &s.out.return_authenticator->cred)) {
printf("Credential chaining failed\n");
}
const char *wks_name;
int i;
struct smbcli_options options;
+ struct smbcli_session_options session_options;
wks_name = torture_setting_string(torture, "wksname", NULL);
if (wks_name == NULL) {
- wks_name = get_myname();
+ wks_name = get_myname(torture);
}
mem_ctx = talloc_init("torture_netlogon_samba3");
}
lp_smbcli_options(torture->lp_ctx, &options);
+ lp_smbcli_session_options(torture->lp_ctx, &session_options);
status = smbcli_full_connection(mem_ctx, &cli,
torture_setting_string(torture, "host", NULL),
lp_smb_ports(torture->lp_ctx),
- "IPC$", NULL, anon_creds,
+ "IPC$", NULL,
+ lp_socket_options(torture->lp_ctx),
+ anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options, &session_options,
+ lp_iconv_convenience(torture->lp_ctx),
+ lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
struct smbcli_state *cli;
struct cli_credentials *wks_creds;
struct smbcli_options options;
+ struct smbcli_session_options session_options;
lp_smbcli_options(tctx->lp_ctx, &options);
+ lp_smbcli_session_options(tctx->lp_ctx, &session_options);
status = smbcli_full_connection(tctx, &cli,
torture_setting_string(tctx, "host", NULL),
lp_smb_ports(tctx->lp_ctx),
- "IPC$", NULL, smb_creds,
- lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ "IPC$", NULL, lp_socket_options(tctx->lp_ctx),
+ smb_creds, lp_resolve_context(tctx->lp_ctx),
+ tctx->ev, &options, &session_options,
+ lp_iconv_convenience(tctx->lp_ctx),
+ lp_gensec_settings(tctx, tctx->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
struct cli_credentials *anon_creds;
const char *wks_name;
- wks_name = torture_setting_string(torture, "wksname", get_myname());
+ wks_name = torture_setting_string(torture, "wksname", get_myname(torture));
if (!(anon_creds = cli_credentials_init_anon(torture))) {
d_printf("create_anon_creds failed\n");
struct policy_handle handle;
struct lsa_LookupNames l;
struct lsa_TransSidArray sids;
+ struct lsa_RefDomainList *domains = NULL;
struct lsa_String lsa_name;
uint32_t count = 0;
struct dom_sid *result;
l.in.count = &count;
l.out.count = &count;
l.out.sids = &sids;
+ l.out.domains = &domains;
status = dcerpc_lsa_LookupNames(p, tmp_ctx, &l);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
}
- result = dom_sid_add_rid(mem_ctx, l.out.domains->domains[0].sid,
+ result = dom_sid_add_rid(mem_ctx, domains->domains[0].sid,
l.out.sids->sids[0].rid);
c.in.handle = &handle;
struct dcerpc_pipe *lsa;
struct lsa_GetUserName r;
NTSTATUS status;
- struct lsa_StringPointer authority_name_p;
+ struct lsa_String *authority_name_p = NULL;
+ struct lsa_String *account_name_p = NULL;
struct dom_sid *result;
status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\lsarpc",
}
r.in.system_name = "\\";
- r.in.account_name = NULL;
- authority_name_p.string = NULL;
+ r.in.account_name = &account_name_p;
r.in.authority_name = &authority_name_p;
+ r.out.account_name = &account_name_p;
status = dcerpc_lsa_GetUserName(lsa, mem_ctx, &r);
+ authority_name_p = *r.out.authority_name;
+
if (!NT_STATUS_IS_OK(status)) {
printf("(%s) GetUserName failed - %s\n",
__location__, nt_errstr(status));
return NULL;
}
- result = name2sid(mem_ctx, lsa, r.out.account_name->string,
- r.out.authority_name->string->string);
+ result = name2sid(mem_ctx, lsa, account_name_p->string,
+ authority_name_p->string);
talloc_free(lsa);
return result;
struct cli_credentials *user_creds;
char *domain_name;
struct smbcli_options options;
+ struct smbcli_session_options session_options;
if (!(mem_ctx = talloc_new(torture))) {
return false;
}
lp_smbcli_options(torture->lp_ctx, &options);
+ lp_smbcli_session_options(torture->lp_ctx, &session_options);
status = smbcli_full_connection(
mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
lp_smb_ports(torture->lp_ctx),
- "IPC$", NULL, cmdline_credentials,
+ "IPC$", NULL, lp_socket_options(torture->lp_ctx), cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options, &session_options,
+ lp_iconv_convenience(torture->lp_ctx),
+ lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
status = smbcli_full_connection(
mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
- lp_smb_ports(torture->lp_ctx),
- "IPC$", NULL, anon_creds,
+ lp_smb_ports(torture->lp_ctx), "IPC$", NULL,
+ lp_socket_options(torture->lp_ctx), anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options, &session_options,
+ lp_iconv_convenience(torture->lp_ctx),
+ lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) anon smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
struct smb_composite_sesssetup setup;
struct smbcli_tree *tree;
- session2 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options);
if (session2 == NULL) {
d_printf("(%s) smbcli_session_init failed\n",
__location__);
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.workgroup = "";
setup.in.credentials = user_creds;
+ setup.in.gensec_settings = lp_gensec_settings(torture, torture->lp_ctx);
status = smb_composite_sesssetup(session2, &setup);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) whoami on user connection failed\n",
__location__);
ret = false;
- goto delete;
+ goto del;
}
talloc_free(tree);
ret = false;
}
- delete:
+ del:
if (!delete_user(cli, torture->lp_ctx,
cmdline_credentials,
cli_credentials_get_username(user_creds))) {
{
NTSTATUS status;
struct srvsvc_NetShareGetInfo r;
+ union srvsvc_NetShareInfo info;
uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007, 1501 };
int i;
bool ret = true;
r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s",
dcerpc_server_name(p));
r.in.share_name = sharename;
+ r.out.info = &info;
for (i=0;i<ARRAY_SIZE(levels);i++) {
r.in.level = levels[i];
- ZERO_STRUCT(r.out);
-
printf("testing NetShareGetInfo level %u on share '%s'\n",
r.in.level, r.in.share_name);
{
NTSTATUS status;
struct srvsvc_NetShareEnum r;
+ struct srvsvc_NetShareInfoCtr info_ctr;
struct srvsvc_NetShareCtr0 c0;
+ struct srvsvc_NetShareCtr1 c1;
+ struct srvsvc_NetShareCtr2 c2;
+ struct srvsvc_NetShareCtr501 c501;
+ struct srvsvc_NetShareCtr502 c502;
+ struct srvsvc_NetShareCtr1004 c1004;
+ struct srvsvc_NetShareCtr1005 c1005;
+ struct srvsvc_NetShareCtr1006 c1006;
+ struct srvsvc_NetShareCtr1007 c1007;
+ uint32_t totalentries = 0;
uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007 };
int i;
bool ret = true;
+ ZERO_STRUCT(info_ctr);
+
r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
- r.in.ctr.ctr0 = &c0;
- r.in.ctr.ctr0->count = 0;
- r.in.ctr.ctr0->array = NULL;
+ r.in.info_ctr = &info_ctr;
r.in.max_buffer = (uint32_t)-1;
r.in.resume_handle = NULL;
+ r.out.totalentries = &totalentries;
+ r.out.info_ctr = &info_ctr;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- r.in.level = levels[i];
-
- ZERO_STRUCT(r.out);
+ info_ctr.level = levels[i];
+
+ switch (info_ctr.level) {
+ case 0:
+ ZERO_STRUCT(c0);
+ info_ctr.ctr.ctr0 = &c0;
+ break;
+ case 1:
+ ZERO_STRUCT(c1);
+ info_ctr.ctr.ctr1 = &c1;
+ break;
+ case 2:
+ ZERO_STRUCT(c2);
+ info_ctr.ctr.ctr2 = &c2;
+ break;
+ case 501:
+ ZERO_STRUCT(c501);
+ info_ctr.ctr.ctr501 = &c501;
+ break;
+ case 502:
+ ZERO_STRUCT(c502);
+ info_ctr.ctr.ctr502 = &c502;
+ break;
+ case 1004:
+ ZERO_STRUCT(c1004);
+ info_ctr.ctr.ctr1004 = &c1004;
+ break;
+ case 1005:
+ ZERO_STRUCT(c1005);
+ info_ctr.ctr.ctr1005 = &c1005;
+ break;
+ case 1006:
+ ZERO_STRUCT(c1006);
+ info_ctr.ctr.ctr1006 = &c1006;
+ break;
+ case 1007:
+ ZERO_STRUCT(c1007);
+ info_ctr.ctr.ctr1007 = &c1007;
+ break;
+ }
- printf("testing NetShareEnum level %u\n", r.in.level);
+ printf("testing NetShareEnum level %u\n", info_ctr.level);
status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("NetShareEnum level %u failed - %s\n",
- r.in.level, nt_errstr(status));
+ info_ctr.level, nt_errstr(status));
ret = false;
continue;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("NetShareEnum level %u failed - %s\n",
- r.in.level, win_errstr(r.out.result));
+ info_ctr.level, win_errstr(r.out.result));
continue;
}
- if (r.in.level == 0) {
- struct srvsvc_NetShareCtr0 *ctr = r.out.ctr.ctr0;
+ if (info_ctr.level == 0) {
+ struct srvsvc_NetShareCtr0 *ctr = r.out.info_ctr->ctr.ctr0;
if (ctr->count > 0) {
*one_sharename = ctr->array[0].name;
}
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
talloc_free(mem_ctx);
return false;
}
struct netr_Credential netr_srv_creds;
uint32_t negotiate_flags;
struct netr_ServerAuthenticate2 a;
- struct creds_CredentialState *creds_state;
+ struct netlogon_creds_CredentialState *creds_state;
struct netr_Credential netr_cred;
struct samr_Password mach_pw;
struct smbcli_state *cli;
if (!(torture_open_connection_share(
mem_ctx, &cli,
torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
goto done;
}
generate_random_buffer(netr_cli_creds.data,
sizeof(netr_cli_creds.data));
r.in.credentials = &netr_cli_creds;
- r.out.credentials = &netr_srv_creds;
+ r.out.return_credentials = &netr_srv_creds;
status = dcerpc_netr_ServerReqChallenge(net_pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
negotiate_flags = NETLOGON_NEG_AUTH2_FLAGS;
E_md4hash("foobar", mach_pw.hash);
- creds_state = talloc(mem_ctx, struct creds_CredentialState);
- creds_client_init(creds_state, r.in.credentials,
- r.out.credentials, &mach_pw,
- &netr_cred, negotiate_flags);
-
a.in.server_name = talloc_asprintf(
mem_ctx, "\\\\%s", dcerpc_server_name(net_pipe));
a.in.account_name = talloc_asprintf(
a.in.negotiate_flags = &negotiate_flags;
a.out.negotiate_flags = &negotiate_flags;
a.in.credentials = &netr_cred;
- a.out.credentials = &netr_cred;
+ a.out.return_credentials = &netr_cred;
+
+ creds_state = netlogon_creds_client_init(mem_ctx,
+ a.in.account_name,
+ a.in.computer_name,
+ r.in.credentials,
+ r.out.return_credentials, &mach_pw,
+ &netr_cred, negotiate_flags);
+
status = dcerpc_netr_ServerAuthenticate2(net_pipe, mem_ctx, &a);
struct dcerpc_pipe *p;
NTSTATUS status;
struct srvsvc_NetShareGetInfo r;
+ union srvsvc_NetShareInfo info;
struct security_descriptor *result;
if (!(tmp_ctx = talloc_new(mem_ctx))) {
dcerpc_server_name(p));
r.in.share_name = sharename;
r.in.level = 502;
+ r.out.info = &info;
status = dcerpc_srvsvc_NetShareGetInfo(p, tmp_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
}
- result = talloc_steal(mem_ctx, r.out.info.info502->sd);
+ result = talloc_steal(mem_ctx, info.info502->sd_buf.sd);
talloc_free(tmp_ctx);
return result;
}
NTSTATUS status;
struct sec_desc_buf i;
struct srvsvc_NetShareSetInfo r;
+ union srvsvc_NetShareInfo info;
uint32_t error = 0;
if (!(tmp_ctx = talloc_new(mem_ctx))) {
r.in.share_name = sharename;
r.in.level = 1501;
i.sd = sd;
- r.in.info.info1501 = &i;
+ info.info1501 = &i;
+ r.in.info = &info;
r.in.parm_error = &error;
status = dcerpc_srvsvc_NetShareSetInfo(p, tmp_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("srvsvc_NetShareGetInfo failed: %s\n",
+ d_printf("srvsvc_NetShareSetInfo failed: %s\n",
nt_errstr(status));
}
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
for (i=0; i<ARRAY_SIZE(levels); i++) {
struct lsa_QueryInfoPolicy r;
+ union lsa_PolicyInformation *info = NULL;
r.in.handle = &lsa_handle;
r.in.level = levels[i];
+ r.out.info = &info;
status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) dcerpc_lsa_QueryInfoPolicy %d "
return false;
}
if (levels[i] == 5) {
- domain_sid = r.out.info->account_domain.sid;
+ domain_sid = info->account_domain.sid;
}
}
}
memcpy(servername, r.out.info.info0.name, 16);
servername[16] = '\0';
- if (pull_ascii_talloc(mem_ctx, iconv_convenience,
- name, servername) < 0) {
+ if (!pull_ascii_talloc(mem_ctx, name, servername, NULL)) {
return NT_STATUS_NO_MEMORY;
}
NTSTATUS status;
struct dcerpc_pipe *p;
struct srvsvc_NetShareEnum r;
+ struct srvsvc_NetShareInfoCtr info_ctr;
struct srvsvc_NetShareCtr1 c1_in;
struct srvsvc_NetShareCtr1 *c1;
+ uint32_t totalentries = 0;
int i;
mem_ctx = talloc_new(ctx);
return status;
}
+ ZERO_STRUCT(c1_in);
+ info_ctr.level = 1;
+ info_ctr.ctr.ctr1 = &c1_in;
+
r.in.server_unc = talloc_asprintf(
mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.level = 1;
- ZERO_STRUCT(c1_in);
- r.in.ctr.ctr1 = &c1_in;
+ r.in.info_ctr = &info_ctr;
r.in.max_buffer = (uint32_t)-1;
r.in.resume_handle = NULL;
+ r.out.totalentries = &totalentries;
+ r.out.info_ctr = &info_ctr;
status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetShareEnum level %u failed - %s\n",
- r.in.level, nt_errstr(status));
+ info_ctr.level, nt_errstr(status));
talloc_free(mem_ctx);
return status;
}
*printers = NULL;
*num_printers = 0;
- c1 = r.out.ctr.ctr1;
+ c1 = r.out.info_ctr->ctr.ctr1;
for (i=0; i<c1->count; i++) {
if (c1->array[i].type != STYPE_PRINTQ) {
continue;
struct spoolss_EnumPrinters r;
NTSTATUS status;
DATA_BLOB blob;
+ uint32_t needed;
+ uint32_t count;
+ union spoolss_PrinterInfo *info;
r.in.flags = PRINTER_ENUM_LOCAL;
r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", servername);
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
+ r.out.count = &count;
+ r.out.info = &info;
status = dcerpc_spoolss_EnumPrinters(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
- blob = data_blob_talloc_zero(mem_ctx, r.out.needed);
+ blob = data_blob_talloc_zero(mem_ctx, needed);
if (blob.data == NULL) {
d_printf("(%s) data_blob_talloc failed\n", __location__);
return false;
}
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrinters(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
return false;
}
- *num_printers = r.out.count;
+ *num_printers = count;
return true;
}
struct spoolss_GetPrinter r;
DATA_BLOB blob;
NTSTATUS status;
+ uint32_t needed;
mem_ctx = talloc_new(ctx);
if (mem_ctx == NULL) {
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
status = dcerpc_spoolss_GetPrinter(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
r.in.handle = handle;
r.in.level = level;
- blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(mem_ctx, NULL, needed);
if (blob.data == NULL) {
talloc_free(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
memset(blob.data, 0, blob.length);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetPrinter(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
while (1) {
struct winreg_EnumValue r;
- struct winreg_StringBuf name;
+ struct winreg_ValNameBuf name;
enum winreg_Type type = 0;
uint8_t buf8[1024];
NTSTATUS status;
TALLOC_CTX *mem_ctx, int depth)
{
struct winreg_EnumKey r;
- struct winreg_StringBuf class, name;
+ struct winreg_StringBuf kclass, name;
NTSTATUS status;
NTTIME t = 0;
return NT_STATUS_OK;
}
- class.name = "";
- class.size = 1024;
+ kclass.name = "";
+ kclass.size = 1024;
r.in.handle = handle;
r.in.enum_index = 0;
r.in.name = &name;
- r.in.keyclass = &class;
+ r.in.keyclass = &kclass;
r.out.name = &name;
r.in.last_changed_time = &t;
struct loadparm_context *lp_ctx,
struct smbcli_state *cli,
const char *share,
- struct srvsvc_NetShareInfo502 **info)
+ struct srvsvc_NetShareInfo502 **info502)
{
struct smbcli_tree *ipc;
struct dcerpc_pipe *p;
struct srvsvc_NetShareGetInfo r;
+ union srvsvc_NetShareInfo info;
NTSTATUS status;
if (!(p = dcerpc_pipe_init(cli,
dcerpc_server_name(p));
r.in.share_name = share;
r.in.level = 502;
+ r.out.info = &info;
status = dcerpc_srvsvc_NetShareGetInfo(p, p, &r);
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- d_printf("(%s) OpenHKLM failed: %s, %s\n", __location__,
+ d_printf("(%s) srvsvc_NetShareGetInfo failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(r.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(r.out.result) : status;
goto fail;
}
- *info = talloc_move(mem_ctx, &r.out.info.info502);
+ *info502 = talloc_move(mem_ctx, &info.info502);
return NT_STATUS_OK;
- fail:
+fail:
talloc_free(p);
return status;
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
d_printf("(%s) OpenHKLM failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(r.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(r.out.result) : status;
goto fail;
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(c.out.result)) {
d_printf("(%s) OpenKey failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(c.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(c.out.result) : status;
goto fail;
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(cl.out.result)) {
d_printf("(%s) OpenKey failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(cl.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(cl.out.result) : status;
goto fail;
}
- fail:
+fail:
talloc_free(mem_ctx);
return status;
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(d.out.result)) {
d_printf("(%s) OpenKey failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(d.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(d.out.result) : status;
goto fail;
}
- fail:
+fail:
talloc_free(mem_ctx);
return status;
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(o.out.result)) {
d_printf("(%s) OpenKey failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(o.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(o.out.result) : status;
goto done;
}
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(s.out.result)) {
d_printf("(%s) SetValue failed: %s, %s\n", __location__,
nt_errstr(status), win_errstr(s.out.result));
+ status = NT_STATUS_IS_OK(status) ? werror_to_ntstatus(s.out.result) : status;
goto done;
}
- done:
+done:
talloc_free(hklm);
return status;
}