Commit Graph

29 Commits

Author SHA1 Message Date
Warren
e7863a3034 Fix macOS SMB mount: AAPL caps, credit grant, file_index, QueryDirectory padding
- AAPL: Restore UNIX_BASED+NFS_ACE server_caps, RESOLVE_ID+FULL_SYNC volume_caps (Samba baseline)
- Credit: Grant min 1 credit in dispatch response for smbclient compatibility
- file_index: Assign 1-based index per entry in list_dir (both VFS and local backends)
- smb_match(): Add wildcard pattern filter (*/?) for macOS single-entry QueryDirectory probes
- FILE_ID_BOTH_DIR_INFORMATION: Add 2-byte Reserved2 padding between ShortName and FileId
- macOS Sequoia 15.5 mount_smbfs now succeeds (tested: ls, cat, read)
2026-06-23 09:44:01 +08:00
Warren
8ef1406ed3 SMB fixes: IPC$ ShareMode=Public, capabilities=0, FILE_ID_BOTH_DIRECTORY_INFORMATION Reserved2 removed, NextEntryOffset=0 for last entry, debug logging 2026-06-23 03:22:39 +08:00
Warren
bb796ec6b9 Fix smb-server xattr: add root_path field for absolute path storage 2026-06-22 16:25:33 +08:00
Warren
9dd2eefeea Fix smb-server xattr: dereference Arc<Dir> before as_std_path() 2026-06-22 15:41:03 +08:00
Warren
0c4459ae66 Fix smb-server xattr: use PathBuf for absolute paths 2026-06-22 15:39:37 +08:00
Warren
5b0086f6f0 Implement Time Machine xattr support (Phase 4.1 complete) 2026-06-22 15:30:44 +08:00
Warren
3029327d5e Implement SMB AFP_Resource Stream via AppleDouble files (Phase 3 complete) 2026-06-22 15:27:28 +08:00
Warren
1c8c47d5fa Implement SMB AFP_AfpInfo read/write via xattr (Phase 2.8 complete)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
2026-06-22 15:16:59 +08:00
Warren
866d0536c8 Add SMB AAPL Extensions Phase 1-6 + VFS xattr support
Phase 1: AAPL Create Context negotiation
Phase 2: AFP_AfpInfo Stream structure (Finder info + creation time)
Phase 2.5: SMB Named Stream Backend (NamedStreamPath)
Phase 2.6: Backend Named Stream Support in handlers
Phase 2.7: VFS Extended Attributes (get/set/remove/list_xattr)
Phase 4: Time Machine share config (time_machine field)
Phase 5: Server/Volume Capabilities
Phase 6: macOS Unicode mapping (private range ↔ ASCII)

Tests: 174 smb-server tests pass, 52 VFS tests pass
2026-06-22 14:21:53 +08:00
Warren
e9eca1b492 Add DFS Referral Support (Phase 5)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
2026-06-22 05:30:16 +08:00
Warren
e267b43424 Add Compound Request tests (Phase 4)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
2026-06-22 05:13:02 +08:00
Warren
382ea2e28b Phase 1.3: SMB3 packet encryption handling complete
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Add handle_encrypted_frame() to dispatch.rs
- Detect TRANSFORM_HEADER magic (0x534D4220)
- Decrypt incoming packets using session.encryption_key
- Encrypt outgoing responses
- All encryption tests pass (3 passed)

Phase 1 SMB3 encryption complete: ~380 lines total
2026-06-22 03:18:22 +08:00
Warren
98239c09d4 Phase 1.2: SMB3 encryption negotiation + session state
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled
- Add encryption_supported and encryption_cipher to Connection state
- Add encryption_key and encryption_enabled to Session state
- Add EncryptionCapabilities context to NegotiateResponse (SMB 3.1.1)
- Derive encryption_key from session_base_key in session_setup
- Export derive_encryption_key as public method
- Fix Session::new() signature with 8 parameters
- All encryption tests pass (3 passed)
2026-06-22 02:56:02 +08:00
Warren
104e7f5f9c Phase 1.1: SMB3 encryption module (AES-CTR + HMAC)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Add encryption.rs with Smb3Encryption struct
- Implement AES-128-CTR + HMAC-SHA256 (simplified approach)
- Add TransformHeader struct for SMB2 TRANSFORM_HEADER
- 3 unit tests pass (encrypt/decrypt roundtrip + signature verification)
- Total: ~180 lines of code
2026-06-22 02:20:59 +08:00
Warren
614275f77a Add SMB Client Restrictions (Phase 1-3): access control for SMB clients
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Features:
- IpSpec: IP address specification (Single/Cidr/Range/Any)
- TimeSpec: Time-based restrictions (HourRange/DayOfWeek/DayHour)
- ClientRule: Allow/Deny rules with IP/user/time/share
- ClientAcl: Priority-based rule matching
- ClientRestrictionManager: Global/Share/User ACLs

Security:
- Restrict SMB client access by IP address
- Time-based access control (business hours only)
- User-specific and share-specific ACLs
- CIDR notation support (192.168.1.0/24)

Files:
- vendor/smb-server/src/client_restrictions.rs (443 lines)
- vendor/smb-server/src/lib.rs (+1 line)

Tests: 7 passed (smb-server), 317 passed (markbase-core)
2026-06-21 12:51:37 +08:00
Warren
a28b7f0929 Add SMB Share Snapshots (Phase 1-4): FSCTL_SRV_SNAPSHOT_* handlers
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Features:
- SnapshotManager: Share snapshot management
- SnapshotEntry/SnapshotState: Snapshot metadata structures
- FSCTL_SRV_SNAPSHOT_CREATE/READ/WRITE/DELETE handlers
- GMT token format support (@GMT-YYYY.MM.DD-HH.MM.SS)
- 7 unit tests for all operations

Files:
- vendor/smb-server/src/snapshot.rs (245 lines)
- vendor/smb-server/src/handlers/ioctl.rs (+88 lines)
- vendor/smb-server/src/proto/messages/ioctl.rs (+8 lines enum)
- vendor/smb-server/src/server.rs (+2 lines)
- vendor/smb-server/src/ntstatus.rs (+1 line)
- vendor/smb-server/src/lib.rs (+1 line)

Tests: 7 passed (smb-server), 309 passed (markbase-core)
2026-06-21 12:38:15 +08:00
Warren
5238a84972 Implement SMB Durable Handles (Phase 1): Persistent FileId + reconnect + expiration + cleanup
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
2026-06-21 05:11:39 +08:00
Warren
c3e21560b6 Implement SMB 3.x Lease support Phase 5
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- WRITE handler trigger lease break (READ leases conflict with WRITE)
- READ handler trigger lease break (HANDLE leases may conflict)
- Send LeaseBreakNotification via notification channel

All 229 tests pass.
2026-06-21 01:24:59 +08:00
Warren
4620475ba8 Implement SMB 3.x Lease support Phase 4
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- CLOSE handler unregister lease_key from LeaseManager
- Extract lease_key from Open struct before close

All 229 tests pass.
2026-06-21 01:24:02 +08:00
Warren
344d13435e Implement SMB 3.x Lease support Phase 3
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled
- CREATE handler parse RqLs create context
- Extract LeaseKey (16 bytes) + LeaseState (4 bytes)
- Check can_grant() before registration
- Register with LeaseManager
- Set Open.lease_key/lease_state fields

All 229 tests pass.
2026-06-21 01:23:32 +08:00
Warren
21a9c3c6c4 Implement SMB 3.x Lease support Phase 1-2
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 1: Open struct lease fields
- lease_key: Option<[u8; 16]> - LeaseKey GUID
- lease_state: Option<u32> - READ/HANDLE/WRITE flags
- lease_flags: Option<u32> - BREAKING etc.

Phase 2: LeaseManager
- LeaseEntry with lease_key/state/flags
- register/unregister/can_grant methods
- break_lease returns LeaseBreakNotification
- LeaseBreakNotification struct (MS-SMB2 §2.2.26)

ServerState: lease_manager field added

All 229 tests pass.
2026-06-21 01:20:18 +08:00
Warren
3cf503d05f Implement Oplock Break Acknowledgement handler (MS-SMB2 §2.2.24)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Parse client's OPLOCK_BREAK_ACK
- Update Open.oplock_level in Open struct
- Update OplockManager entry via update_oplock_level()
- Return confirmation response

All 229 tests pass.
2026-06-21 01:15:21 +08:00
Warren
063a697e83 Add READ handler oplock break (Phase 5.5)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Trigger oplock break before read if conflicting opens exist
- Use granted_access from Open struct
- Send notifications via notification_tx channel
- Fix WRITE handler granted_access source (from Tree)

All 229 tests pass.
2026-06-21 01:13:35 +08:00
Warren
2dd50e4cb6 Implement SMB Oplocks Phase 3+5
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 3: NotificationQueue
- Add notification_tx to Connection struct
- Modify writer.rs to use tokio::select! for response + notification
- Add write_to_bytes() to OplockBreakNotification
- Support server→client async messages

Phase 5: WRITE Handler oplock break
- Get path/share_access before write
- Trigger OplockManager.break_oplock()
- Send OPLOCK_BREAK_NOTIFICATION to affected clients
- Encode and send via notification channel

All 229 tests pass.
2026-06-21 00:35:48 +08:00
Warren
276308af12 Implement SMB Byte-range Lock (Phase 7)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
- Add LockManager to oplock.rs:
  - LockRange struct for tracking byte-range locks
  - acquire() - check conflicts before granting lock
  - release() - remove specific lock by offset/length
  - clear() - clear all locks when file closed
  - ranges_overlap() - helper for conflict detection

- Add LockManager to ServerState

- Update handlers/lock.rs:
  - Parse LockRequest and LockElement
  - Process each lock element (acquire/release)
  - Support FLAG_EXCLUSIVE_LOCK, FLAG_SHARED_LOCK, FLAG_UNLOCK
  - Return STATUS_LOCK_NOT_GRANTED on conflict

- Update handlers/close.rs:
  - Clear all locks when file closed

- Add STATUS_LOCK_NOT_GRANTED to ntstatus.rs

All 229 tests pass.
2026-06-21 00:25:55 +08:00
Warren
54ce0d6916 Implement SMB Oplocks Phase 4+6
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 4: CREATE Handler dynamic oplock granting
- Use OplockManager.can_grant() to determine oplock level
- Register OplockEntry if oplock granted
- Support ShareAccess compatibility checking
- Grant Level II if exclusive/batch oplock exists

Phase 6: CLOSE Handler oplock cleanup
- Unregister from OplockManager when file closed
- Only unregister if oplock_level > 0

All 229 tests pass.
2026-06-21 00:19:51 +08:00
Warren
27707bbe0e Implement SMB Oplocks Phase 1-2
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
Phase 1: Data structures
- Add oplock_level and share_access fields to Open struct
- Update Open::new() signature with new parameters
- Update handlers/create.rs to pass oplock params

Phase 2: OplockManager
- Create oplock.rs with OplockManager struct
- OplockEntry for tracking per-client oplock state
- can_grant() - check ShareAccess compatibility
- register() / unregister() - lifecycle management
- break_oplock() - generate OPLOCK_BREAK_NOTIFICATION
- Add OplockManager to ServerState
- Add Hash trait to SmbPath for HashMap key

All 229 tests pass.
2026-06-21 00:17:24 +08:00
Warren
24029501d9 Add placeholder smb-server integration test files
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
2026-06-20 21:07:27 +08:00
Warren
7eb528d35f SMB Server Phase 2: VFS backend build fix + integration test
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled
- Add VfsFile: Send supertrait for Mutex compatibility
- Fix SmbServerCommand: struct → Subcommand enum with Start variant
- Fix tracing_subscriber::init() → try_init() to avoid panic when
  logger already initialized
- Fix CLI subcommand name: smb-server → smb-start (flatten naming)
- Add #[command(name = "smb-start")] for CLI disambiguation
- Fix unused variable warnings (smb_fs.rs, smb_server_backend.rs)
- Remove unused VfsFile imports (webdav.rs, scp_handler.rs)
- Integration test: Docker smbclient verified (list, upload, read)
2026-06-20 19:42:29 +08:00