#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
#include "trans2.h"
+#include "../libcli/smb/smbXcli_base.h"
/****************************************************************************
Calculate a safe next_entry_offset.
const char *p,
const char *pdata_end,
struct file_info *finfo,
- uint32 *p_resume_key,
+ uint32_t *p_resume_key,
DATA_BLOB *p_last_name_raw)
{
int len;
return pdata_end - base;
}
finfo->ctime_ts = convert_time_t_to_timespec(
- make_unix_date2(p+4, cli_state_server_time_zone(cli)));
+ make_unix_date2(p+4, smb1cli_conn_server_time_zone(cli->conn)));
finfo->atime_ts = convert_time_t_to_timespec(
- make_unix_date2(p+8, cli_state_server_time_zone(cli)));
+ make_unix_date2(p+8, smb1cli_conn_server_time_zone(cli->conn)));
finfo->mtime_ts = convert_time_t_to_timespec(
- make_unix_date2(p+12, cli_state_server_time_zone(cli)));
+ make_unix_date2(p+12, smb1cli_conn_server_time_zone(cli->conn)));
finfo->size = IVAL(p,16);
finfo->mode = CVAL(p,24);
len = CVAL(p, 26);
p += 27;
- p += align_string(base_ptr, p, 0);
+ if (recv_flags2 & FLAGS2_UNICODE_STRINGS) {
+ p += ucs2_align(base_ptr, p, STR_UNICODE);
+ }
/* We can safely use len here (which is required by OS/2)
* and the NAS-BASIC server instead of +2 or +1 as the
return pdata_end - base;
}
finfo->ctime_ts = convert_time_t_to_timespec(
- make_unix_date2(p+4, cli_state_server_time_zone(cli)));
+ make_unix_date2(p+4, smb1cli_conn_server_time_zone(cli->conn)));
finfo->atime_ts = convert_time_t_to_timespec(
- make_unix_date2(p+8, cli_state_server_time_zone(cli)));
+ make_unix_date2(p+8, smb1cli_conn_server_time_zone(cli->conn)));
finfo->mtime_ts = convert_time_t_to_timespec(
- make_unix_date2(p+12, cli_state_server_time_zone(cli)));
+ make_unix_date2(p+12, smb1cli_conn_server_time_zone(cli->conn)));
finfo->size = IVAL(p,16);
finfo->mode = CVAL(p,24);
len = CVAL(p, 30);
namelen = IVAL(p,0);
p += 4;
p += 4; /* EA size */
- slen = SVAL(p, 0);
+ slen = CVAL(p, 0);
if (slen > 24) {
/* Bad short name length. */
return pdata_end - base;
finfo->mode = CVAL(p,21);
/* this date is converted to GMT by make_unix_date */
- finfo->ctime_ts.tv_sec = make_unix_date(p+22, cli_state_server_time_zone(cli));
+ finfo->ctime_ts.tv_sec = make_unix_date(p+22, smb1cli_conn_server_time_zone(cli->conn));
finfo->ctime_ts.tv_nsec = 0;
finfo->mtime_ts.tv_sec = finfo->atime_ts.tv_sec = finfo->ctime_ts.tv_sec;
finfo->mtime_ts.tv_nsec = finfo->atime_ts.tv_nsec = 0;
return tevent_req_post(req, ev);
}
bytes[0] = 4;
- bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), mask,
+ bytes = smb_bytes_push_str(bytes, smbXcli_conn_use_unicode(cli->conn), mask,
strlen(mask)+1, NULL);
bytes = smb_bytes_push_bytes(bytes, 5, (const uint8_t *)&zero, 2);
return tevent_req_post(req, ev);
}
- subreq = cli_smb_send(state, state->ev, state->cli, SMBsearch,
- 0, 2, state->vwv, talloc_get_size(bytes), bytes);
+ subreq = cli_smb_send(state, state->ev, state->cli, SMBsearch, 0, 0,
+ 2, state->vwv, talloc_get_size(bytes), bytes);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
return;
}
bytes[0] = 4;
- bytes = smb_bytes_push_str(bytes, cli_ucs2(state->cli), "",
+ bytes = smb_bytes_push_str(bytes, smbXcli_conn_use_unicode(state->cli->conn), "",
1, NULL);
bytes = smb_bytes_push_bytes(bytes, 5, state->search_status,
sizeof(state->search_status));
if (tevent_req_nomem(bytes, req)) {
return;
}
- subreq = cli_smb_send(state, state->ev, state->cli, cmd, 0,
+ subreq = cli_smb_send(state, state->ev, state->cli, cmd, 0, 0,
2, state->vwv, talloc_get_size(bytes), bytes);
if (tevent_req_nomem(subreq, req)) {
return;
}
NTSTATUS cli_list_old(struct cli_state *cli, const char *mask,
- uint16 attribute,
+ uint16_t attribute,
NTSTATUS (*fn)(const char *, struct file_info *,
const char *, void *), void *state)
{
TALLOC_CTX *frame = talloc_stackframe();
- struct event_context *ev;
+ struct tevent_context *ev;
struct tevent_req *req;
NTSTATUS status = NT_STATUS_NO_MEMORY;
struct file_info *finfo;
size_t i, num_finfo;
- if (cli_has_async_calls(cli)) {
+ if (smbXcli_conn_has_async_calls(cli->conn)) {
/*
* Can't use sync call while an async call is in flight
*/
status = NT_STATUS_INVALID_PARAMETER;
goto fail;
}
- ev = event_context_init(frame);
+ ev = samba_tevent_context_init(frame);
if (ev == NULL) {
goto fail;
}
if (req == NULL) {
goto fail;
}
- if (!tevent_req_poll(req, ev)) {
- status = map_nt_error_from_unix(errno);
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
status = cli_list_old_recv(req, frame, &finfo);
struct tevent_req *req, *subreq;
struct cli_list_trans_state *state;
size_t param_len;
+ uint16_t additional_flags2 = 0;
req = tevent_req_create(mem_ctx, &state,
struct cli_list_trans_state);
SSVAL(state->param, 6, state->info_level);
SIVAL(state->param, 8, 0);
- state->param = trans2_bytes_push_str(state->param, cli_ucs2(cli),
+ state->param = trans2_bytes_push_str(state->param, smbXcli_conn_use_unicode(cli->conn),
state->mask, strlen(state->mask)+1,
NULL);
if (tevent_req_nomem(state->param, req)) {
return tevent_req_post(req, ev);
}
+
+ if (clistr_is_previous_version_path(state->mask, NULL, NULL, NULL)) {
+ additional_flags2 = FLAGS2_REPARSE_PATH;
+ }
+
param_len = talloc_get_size(state->param);
- subreq = cli_trans_send(state, state->ev, state->cli,
+ subreq = cli_trans_send(state, state->ev, state->cli, additional_flags2,
SMBtrans2, NULL, -1, 0, 0,
state->setup, 1, 0,
state->param, param_len, 10,
DATA_BLOB last_name_raw;
struct file_info *finfo = NULL;
size_t param_len;
+ uint16_t additional_flags2 = 0;
min_param = (state->first ? 6 : 4);
data_blob_free(&last_name_raw);
} else {
state->param = trans2_bytes_push_str(state->param,
- cli_ucs2(state->cli),
+ smbXcli_conn_use_unicode(state->cli->conn),
state->mask,
strlen(state->mask)+1,
NULL);
}
param_len = talloc_get_size(state->param);
- subreq = cli_trans_send(state, state->ev, state->cli,
+ if (clistr_is_previous_version_path(state->mask, NULL, NULL, NULL)) {
+ additional_flags2 = FLAGS2_REPARSE_PATH;
+ }
+
+ subreq = cli_trans_send(state, state->ev, state->cli, additional_flags2,
SMBtrans2, NULL, -1, 0, 0,
state->setup, 1, 0,
state->param, param_len, 10,
void *private_data)
{
TALLOC_CTX *frame = talloc_stackframe();
- struct event_context *ev;
+ struct tevent_context *ev;
struct tevent_req *req;
int i, num_finfo;
struct file_info *finfo = NULL;
NTSTATUS status = NT_STATUS_NO_MEMORY;
- if (cli_has_async_calls(cli)) {
+ if (smbXcli_conn_has_async_calls(cli->conn)) {
/*
* Can't use sync call while an async call is in flight
*/
status = NT_STATUS_INVALID_PARAMETER;
goto fail;
}
- ev = event_context_init(frame);
+ ev = samba_tevent_context_init(frame);
if (ev == NULL) {
goto fail;
}
return NT_STATUS_OK;
}
-NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16 attribute,
+NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16_t attribute,
NTSTATUS (*fn)(const char *, struct file_info *, const char *,
void *), void *state)
{
- TALLOC_CTX *frame = talloc_stackframe();
- struct event_context *ev;
+ TALLOC_CTX *frame = NULL;
+ struct tevent_context *ev;
struct tevent_req *req;
NTSTATUS status = NT_STATUS_NO_MEMORY;
struct file_info *finfo;
size_t i, num_finfo;
uint16_t info_level;
- if (cli_has_async_calls(cli)) {
+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+ return cli_smb2_list(cli, mask, attribute, fn, state);
+ }
+
+ frame = talloc_stackframe();
+
+ if (smbXcli_conn_has_async_calls(cli->conn)) {
/*
* Can't use sync call while an async call is in flight
*/
status = NT_STATUS_INVALID_PARAMETER;
goto fail;
}
- ev = event_context_init(frame);
+ ev = samba_tevent_context_init(frame);
if (ev == NULL) {
goto fail;
}
- info_level = (cli_state_capabilities(cli) & CAP_NT_SMBS)
+ info_level = (smb1cli_conn_capabilities(cli->conn) & CAP_NT_SMBS)
? SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_INFO_STANDARD;
req = cli_list_send(frame, ev, cli, mask, attribute, info_level);
if (req == NULL) {
goto fail;
}
- if (!tevent_req_poll(req, ev)) {
- status = map_nt_error_from_unix(errno);
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}