SMB fixes: IPC$ ShareMode=Public, capabilities=0, FILE_ID_BOTH_DIRECTORY_INFORMATION Reserved2 removed, NextEntryOffset=0 for last entry, debug logging

This commit is contained in:
Warren
2026-06-23 03:22:39 +08:00
parent bb796ec6b9
commit 8ef1406ed3
8 changed files with 55 additions and 19 deletions

View File

@@ -123,6 +123,11 @@ pub async fn handle(
if buf.is_empty() {
return HandlerResponse::err(ntstatus::STATUS_NO_MORE_FILES);
}
// Set last entry's NextEntryOffset to 0 (no next entry)
if let Some(prev_off) = last_offset_pos {
buf[prev_off..prev_off + 4].copy_from_slice(&0u32.to_le_bytes());
}
let resp = QueryDirectoryResponse {
structure_size: 9,

View File

@@ -21,6 +21,11 @@ const FILE_GENERIC_READ: u32 = 0x0012_0089;
const FILE_GENERIC_EXECUTE: u32 = 0x0012_00A0;
const FILE_ALL_ACCESS: u32 = 0x001F_01FF;
const SMB2_SHAREFLAG_MANUAL_CACHING: u32 = 0x00000000;
const SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM: u32 = 0x00080000;
const SMB2_SHARE_CAP_DFS: u32 = 0x00000001;
pub async fn handle(
server: &Arc<ServerState>,
conn: &Arc<Connection>,
@@ -119,6 +124,24 @@ pub async fn handle(
tracing::info!(share = %share.name, uuid = %uuid, "Time Machine enabled");
}
let share_flags = if share.is_ipc {
0
} else {
SMB2_SHAREFLAG_MANUAL_CACHING | SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM
};
let capabilities = if share.is_ipc {
0
} else {
0 // 普通磁盘 share不是 DFS share
};
let capabilities = if share.is_ipc {
0
} else {
SMB2_SHARE_CAP_DFS // Basic DFS support for Finder
};
let resp = TreeConnectResponse {
structure_size: 16,
share_type: if share.is_ipc {
@@ -127,8 +150,8 @@ pub async fn handle(
SHARE_TYPE_DISK
},
reserved: 0,
share_flags: 0,
capabilities: 0,
share_flags,
capabilities,
maximal_access,
};
let mut buf = Vec::new();