Commit 7db0d1a7 authored by Stefan Metzmacher's avatar Stefan Metzmacher Committed by Karolin Seeger

smbd: implement SMB_FILE_NORMALIZED_NAME_INFORMATION handling

Windows 10 (1803 and higher) support and use
SMB_FILE_NORMALIZED_NAME_INFORMATION calls over the network. As a
fallback (in case the server don't support it) the client traverses all
path components, which is very expensive.

Implementing SMB_FILE_NORMALIZED_NAME_INFORMATION is very cheap for us
as the open already went through unix_convert() and we have the
information the client is asking for.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13919Signed-off-by: 's avatarStefan Metzmacher <metze@samba.org>
Reviewed-by: 's avatarJeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed May  1 18:33:00 UTC 2019 on sn-devel-184

(cherry picked from commit b20fd15e04ce9292f90a7f70f4184e43034b4b9d)
parent ffb6fb90
^samba3.smb2.getinfo.normalized
......@@ -318,6 +318,15 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
break;
}
switch (file_info_level) {
case SMB_FILE_NORMALIZED_NAME_INFORMATION:
if (smb2req->xconn->protocol < PROTOCOL_SMB3_11) {
tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
return tevent_req_post(req, ev);
}
break;
}
if (fsp->fake_file_handle) {
/*
* This is actually for the QUOTA_FAKE_FILE --metze
......
......@@ -5208,6 +5208,63 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
break;
}
case SMB_FILE_NORMALIZED_NAME_INFORMATION:
{
char *nfname = NULL;
if (!fsp->conn->sconn->using_smb2) {
return NT_STATUS_INVALID_LEVEL;
}
nfname = talloc_strdup(mem_ctx, smb_fname->base_name);
if (nfname == NULL) {
return NT_STATUS_NO_MEMORY;
}
if (ISDOT(nfname)) {
nfname[0] = '\0';
}
string_replace(nfname, '/', '\\');
if (smb_fname->stream_name != NULL) {
const char *s = smb_fname->stream_name;
const char *e = NULL;
size_t n;
SMB_ASSERT(s[0] != '\0');
/*
* smb_fname->stream_name is in form
* of ':StrEam:$DATA', but we should only
* append ':StrEam' here.
*/
e = strchr(&s[1], ':');
if (e == NULL) {
n = strlen(s);
} else {
n = PTR_DIFF(e, s);
}
nfname = talloc_strndup_append(nfname, s, n);
if (nfname == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
status = srvstr_push(dstart, flags2,
pdata+4, nfname,
PTR_DIFF(dend, pdata+4),
STR_UNICODE, &len);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_NORMALIZED_NAME_INFORMATION\n"));
data_size = 4 + len;
SIVAL(pdata,0,len);
*fixed_portion = 8;
break;
}
case SMB_FILE_ALLOCATION_INFORMATION:
case SMB_QUERY_FILE_ALLOCATION_INFO:
DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_ALLOCATION_INFORMATION\n"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment