return status;
}
-/***************************************************************
- Wrapper that allows SMB2 to query a path info (ALTNAME level).
- Synchronous only.
-***************************************************************/
-
-NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
- const char *name,
- fstring alt_name)
-{
- NTSTATUS status;
- DATA_BLOB outbuf = data_blob_null;
- uint16_t fnum = 0xffff;
- uint32_t altnamelen = 0;
- TALLOC_CTX *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;
- }
-
- status = get_fnum_from_path(cli,
- name,
- FILE_READ_ATTRIBUTES,
- &fnum);
-
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
- status = cli_smb2_query_info_fnum(
- cli,
- fnum,
- 1, /* in_info_type */
- (SMB_FILE_ALTERNATE_NAME_INFORMATION - 1000), /* in_file_info_class */
- 0xFFFF, /* in_max_output_length */
- NULL, /* in_input_buffer */
- 0, /* in_additional_info */
- 0, /* in_flags */
- frame,
- &outbuf);
-
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
- /* Parse the reply. */
- if (outbuf.length < 4) {
- status = NT_STATUS_INVALID_NETWORK_RESPONSE;
- goto fail;
- }
-
- altnamelen = IVAL(outbuf.data, 0);
- if (altnamelen > outbuf.length - 4) {
- status = NT_STATUS_INVALID_NETWORK_RESPONSE;
- goto fail;
- }
-
- if (altnamelen > 0) {
- size_t ret = 0;
- char *short_name = NULL;
- ret = pull_string_talloc(frame,
- outbuf.data,
- FLAGS2_UNICODE_STRINGS,
- &short_name,
- outbuf.data + 4,
- altnamelen,
- STR_UNICODE);
- if (ret == (size_t)-1) {
- /* Bad conversion. */
- status = NT_STATUS_INVALID_NETWORK_RESPONSE;
- goto fail;
- }
-
- fstrcpy(alt_name, short_name);
- } else {
- alt_name[0] = '\0';
- }
-
- status = NT_STATUS_OK;
-
- fail:
-
- if (fnum != 0xffff) {
- cli_smb2_close_fnum(cli, fnum);
- }
-
- cli->raw_status = status;
-
- TALLOC_FREE(frame);
- return status;
-}
-
struct cli_smb2_qpathinfo_state {
struct tevent_context *ev;
struct cli_state *cli;
const char *name,
SMB_STRUCT_STAT *sbuf,
uint32_t *attributes);
-NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
- const char *name,
- fstring alt_name);
struct tevent_req *cli_smb2_qpathinfo_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli,
};
static void cli_qpathinfo_done(struct tevent_req *subreq);
+static void cli_qpathinfo_done2(struct tevent_req *subreq);
struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
if (req == NULL) {
return NULL;
}
+
+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+ uint16_t smb2_level = 0;
+
+ switch (level) {
+ case SMB_QUERY_FILE_ALT_NAME_INFO:
+ smb2_level = FSCC_FILE_ALTERNATE_NAME_INFORMATION;
+ break;
+ default:
+ tevent_req_nterror(req, NT_STATUS_INVALID_LEVEL);
+ return tevent_req_post(req, ev);
+ }
+
+ subreq = cli_smb2_qpathinfo_send(state,
+ ev,
+ cli,
+ fname,
+ smb2_level,
+ min_rdata,
+ max_rdata);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_qpathinfo_done2, req);
+ return req;
+ }
+
state->min_rdata = min_rdata;
SSVAL(state->setup, 0, TRANSACT2_QPATHINFO);
tevent_req_done(req);
}
+static void cli_qpathinfo_done2(struct tevent_req *subreq)
+{
+ struct tevent_req *req =
+ tevent_req_callback_data(subreq, struct tevent_req);
+ struct cli_qpathinfo_state *state =
+ tevent_req_data(req, struct cli_qpathinfo_state);
+ NTSTATUS status;
+
+ status = cli_smb2_qpathinfo_recv(subreq,
+ state,
+ &state->rdata,
+ &state->num_rdata);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ tevent_req_done(req);
+}
+
NTSTATUS cli_qpathinfo_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
uint8_t **rdata, uint32_t *num_rdata)
{
size_t converted_size = 0;
NTSTATUS status;
- if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
- return cli_smb2_qpathinfo_alt_name(cli,
- fname,
- alt_name);
- }
-
status = cli_qpathinfo(talloc_tos(), cli, fname,
SMB_QUERY_FILE_ALT_NAME_INFO,
4, CLI_BUFFER_SIZE, &rdata, &num_rdata);