#include "includes.h"
#include "libsmb/libsmb.h"
#include "../libcli/auth/spnego.h"
-#include "../libcli/auth/ntlmssp.h"
+#include "../auth/ntlmssp/ntlmssp.h"
#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
-#include "smb_crypt.h"
+#include "../libcli/smb/smb_seal.h"
#include "trans2.h"
+#include "ntlmssp_wrap.h"
+#include "auth/gensec/gensec.h"
/****************************************************************************
Get UNIX extensions version info.
return status;
}
-NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
- uint32 *pserial_number, time_t *pdate)
+NTSTATUS cli_get_fs_volume_info(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ char **_volume_name,
+ uint32_t *pserial_number,
+ time_t *pdate)
{
NTSTATUS status;
- uint16 setup[1];
+ uint16_t recv_flags2;
+ uint16_t setup[1];
uint8_t param[2];
uint8_t *rdata;
uint32_t rdata_count;
unsigned int nlen;
+ char *volume_name = NULL;
SSVAL(setup, 0, TRANSACT2_QFSINFO);
SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO);
setup, 1, 0,
param, 2, 0,
NULL, 0, 560,
- NULL,
+ &recv_flags2,
NULL, 0, NULL,
NULL, 0, NULL,
- &rdata, 10, &rdata_count);
+ &rdata, 18, &rdata_count);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
*pserial_number = IVAL(rdata,8);
}
nlen = IVAL(rdata,12);
- clistr_pull(cli->inbuf, volume_name, rdata + 18, sizeof(fstring),
- nlen, STR_UNICODE);
+ if (nlen > (rdata_count - 18)) {
+ TALLOC_FREE(rdata);
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ clistr_pull_talloc(mem_ctx,
+ (const char *)rdata,
+ recv_flags2,
+ &volume_name,
+ rdata + 18,
+ nlen, STR_UNICODE);
+ if (volume_name == NULL) {
+ status = map_nt_error_from_unix(errno);
+ TALLOC_FREE(rdata);
+ return status;
+ }
/* todo: but not yet needed
* return the other stuff
*/
+ *_volume_name = volume_name;
TALLOC_FREE(rdata);
return NT_STATUS_OK;
}
uint16 setup[1];
uint8_t param[2];
uint8_t *rdata = NULL;
+ uint32_t rdata_count;
NTSTATUS status;
SSVAL(setup, 0, TRANSACT2_QFSINFO);
NULL,
NULL, 0, NULL, /* rsetup */
NULL, 0, NULL, /* rparam */
- &rdata, 56, NULL);
+ &rdata, 56, &rdata_count);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
DATA_BLOB blob_out = data_blob_null;
DATA_BLOB param_out = data_blob_null;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ struct auth_ntlmssp_state *auth_ntlmssp_state;
struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_NTLM);
if (!es) {
return NT_STATUS_NO_MEMORY;
}
- status = ntlmssp_client_start(NULL,
- lp_netbios_name(),
- lp_workgroup(),
- lp_client_ntlmv2_auth(),
- &es->s.ntlmssp_state);
+ status = auth_ntlmssp_client_prepare(NULL,
+ &auth_ntlmssp_state);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
- ntlmssp_want_feature(es->s.ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
- es->s.ntlmssp_state->neg_flags |= (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL);
+ gensec_want_feature(auth_ntlmssp_state->gensec_security, GENSEC_FEATURE_SESSION_KEY);
+ gensec_want_feature(auth_ntlmssp_state->gensec_security, GENSEC_FEATURE_SEAL);
- if (!NT_STATUS_IS_OK(status = ntlmssp_set_username(es->s.ntlmssp_state, user))) {
+ if (!NT_STATUS_IS_OK(status = auth_ntlmssp_set_username(auth_ntlmssp_state, user))) {
goto fail;
}
- if (!NT_STATUS_IS_OK(status = ntlmssp_set_domain(es->s.ntlmssp_state, domain))) {
+ if (!NT_STATUS_IS_OK(status = auth_ntlmssp_set_domain(auth_ntlmssp_state, domain))) {
goto fail;
}
- if (!NT_STATUS_IS_OK(status = ntlmssp_set_password(es->s.ntlmssp_state, pass))) {
+ if (!NT_STATUS_IS_OK(status = auth_ntlmssp_set_password(auth_ntlmssp_state, pass))) {
+ goto fail;
+ }
+
+ if (!NT_STATUS_IS_OK(status = auth_ntlmssp_client_start(auth_ntlmssp_state))) {
goto fail;
}
do {
- status = ntlmssp_update(es->s.ntlmssp_state, blob_in, &blob_out);
+ status = gensec_update(auth_ntlmssp_state->gensec_security, auth_ntlmssp_state,
+ NULL, blob_in, &blob_out);
data_blob_free(&blob_in);
data_blob_free(¶m_out);
if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED) || NT_STATUS_IS_OK(status)) {
if (cli->trans_enc_state) {
common_free_encryption_state(&cli->trans_enc_state);
}
+ /* We only need the gensec_security part from here.
+ * es is a malloc()ed pointer, so we cannot make
+ * gensec_security a talloc child */
+ es->s.gensec_security = talloc_move(NULL,
+ &auth_ntlmssp_state->gensec_security);
cli->trans_enc_state = es;
cli->trans_enc_state->enc_on = True;
es = NULL;
}
fail:
-
+ TALLOC_FREE(auth_ntlmssp_state);
common_free_encryption_state(&es);
return status;
}
return NT_STATUS_NO_MEMORY;
}
- name_to_fqdn(fqdn, cli->desthost);
+ name_to_fqdn(fqdn, cli_state_remote_name(cli));
strlower_m(fqdn);
servicename = "cifs";