mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Implement alt name query for smb2
Implements smb2_qpathinfo_alt_name() and RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 097df343ce21c8340aee7f42f233fe74b92b47e2)
This commit is contained in:
parent
67e589c111
commit
18db8bd9c4
@ -464,7 +464,8 @@ enum smb_fileinfo_level {
|
||||
RAW_FILEINFO_NORMALIZED_NAME_INFORMATION= SMB_QFILEINFO_NORMALIZED_NAME_INFORMATION,
|
||||
/* SMB2 specific levels */
|
||||
RAW_FILEINFO_SMB2_ALL_EAS = 0x0f01,
|
||||
RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201
|
||||
RAW_FILEINFO_SMB2_ALL_INFORMATION = 0x1201,
|
||||
RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION = 0x1501
|
||||
};
|
||||
|
||||
/* union used in qfileinfo() and qpathinfo() backend calls */
|
||||
@ -646,6 +647,7 @@ union smb_fileinfo {
|
||||
/* RAW_FILEINFO_NAME_INFO and RAW_FILEINFO_NAME_INFORMATION interfaces */
|
||||
/* RAW_FILEINFO_ALT_NAME_INFO and RAW_FILEINFO_ALT_NAME_INFORMATION interfaces */
|
||||
/* RAW_FILEINFO_NORMALIZED_NAME_INFORMATION interface */
|
||||
/* RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION interface */
|
||||
struct {
|
||||
enum smb_fileinfo_level level;
|
||||
struct {
|
||||
|
@ -158,6 +158,7 @@ NTSTATUS smb_raw_fileinfo_passthru_parse(const DATA_BLOB *blob, TALLOC_CTX *mem_
|
||||
return NT_STATUS_OK;
|
||||
|
||||
case RAW_FILEINFO_ALT_NAME_INFORMATION:
|
||||
case RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION:
|
||||
FINFO_CHECK_MIN_SIZE(4);
|
||||
smbcli_blob_pull_string(NULL, mem_ctx, blob,
|
||||
&parms->alt_name_info.out.fname, 0, 4, STR_UNICODE);
|
||||
@ -470,6 +471,10 @@ static NTSTATUS smb_raw_info_backend(struct smbcli_session *session,
|
||||
return smb_raw_fileinfo_passthru_parse(blob, mem_ctx,
|
||||
RAW_FILEINFO_SMB2_ALL_EAS, parms);
|
||||
|
||||
case RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION:
|
||||
return smb_raw_fileinfo_passthru_parse(blob, mem_ctx,
|
||||
RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION, parms);
|
||||
|
||||
}
|
||||
|
||||
return NT_STATUS_INVALID_LEVEL;
|
||||
|
@ -285,3 +285,56 @@ bool smb2_util_handle_empty(const struct smb2_handle h)
|
||||
|
||||
return smb2_util_handle_equal(h, empty);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
|
||||
****************************************************************************/
|
||||
NTSTATUS smb2_qpathinfo_alt_name(TALLOC_CTX *ctx, struct smb2_tree *tree,
|
||||
const char *fname, const char **alt_name)
|
||||
{
|
||||
union smb_fileinfo parms;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
NTSTATUS status;
|
||||
struct smb2_create create_io = {0};
|
||||
|
||||
mem_ctx = talloc_new(ctx);
|
||||
if (!mem_ctx) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
create_io.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
|
||||
create_io.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
|
||||
create_io.in.create_disposition = FILE_OPEN;
|
||||
create_io.in.fname = fname;
|
||||
status = smb2_create(tree, mem_ctx, &create_io);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
talloc_free(mem_ctx);
|
||||
return status;
|
||||
}
|
||||
|
||||
parms.alt_name_info.level = RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION;
|
||||
parms.alt_name_info.in.file.handle = create_io.out.file.handle;
|
||||
|
||||
status = smb2_getinfo_file(tree, mem_ctx, &parms);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
talloc_free(mem_ctx);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = smb2_util_close(tree, create_io.out.file.handle);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
talloc_free(mem_ctx);
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!parms.alt_name_info.out.fname.s) {
|
||||
*alt_name = talloc_strdup(ctx, "");
|
||||
} else {
|
||||
*alt_name = talloc_strdup(ctx,
|
||||
parms.alt_name_info.out.fname.s);
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
@ -862,6 +862,7 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
|
||||
|
||||
case RAW_FILEINFO_ALT_NAME_INFO:
|
||||
case RAW_FILEINFO_ALT_NAME_INFORMATION:
|
||||
case RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION:
|
||||
info->alt_name_info.out.fname.s = talloc_strdup(mem_ctx, info2->generic.out.alt_fname.s);
|
||||
NT_STATUS_HAVE_NO_MEMORY(info->alt_name_info.out.fname.s);
|
||||
info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length;
|
||||
|
@ -254,6 +254,7 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs,
|
||||
|
||||
case RAW_FILEINFO_ALT_NAME_INFO:
|
||||
case RAW_FILEINFO_ALT_NAME_INFORMATION:
|
||||
case RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION:
|
||||
info->name_info.out.fname.s = pvfs_short_name(pvfs, name, name);
|
||||
return NT_STATUS_OK;
|
||||
|
||||
|
@ -1640,6 +1640,7 @@ static bool cmp_fileinfo(int instance,
|
||||
|
||||
case RAW_FILEINFO_ALT_NAME_INFO:
|
||||
case RAW_FILEINFO_ALT_NAME_INFORMATION:
|
||||
case RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION:
|
||||
CHECK_WSTR_EQUAL(alt_name_info.out.fname);
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user