Conversation
…_TIMEWARP_TOKEN The SMB2 layer already carried create contexts in both directions -- CreateRequest.CreateContexts and CreateResponse.CreateContexts are parsed and serialized -- but the client had no way to send or read them, so a caller could not open a previous version of a file. A shadow copy is addressed with the SMB2_CREATE_TIMEWARP_TOKEN create context. The @GMT- path prefix is not a server-side convention: smbclient and the Windows redirector translate such a path into a TimeWarp token, which is why a raw SMB2 client that sends the token in the path gets STATUS_OBJECT_PATH_NOT_FOUND from Samba while smbclient reads the same file. - SMB2FileStore.CreateFile gains an overload taking the create contexts to send and returning those the server answered with. The existing overload delegates to it, so behaviour is unchanged for current callers. - CreateContextName holds the context names from [MS-SMB2] 2.2.13.2. - CreateContextHelper builds and reads SMB2_CREATE_TIMEWARP_TOKEN and looks a context up by name. Verified against Samba with shadow_copy2 and two snapshots: opening report.txt with a TimeWarp token for the older snapshot reads that snapshot's content, while opening it without one reads the live file. Those integration tests are inconclusive unless ServerAddress is set, since the in-process SMBServer does not serve shadow copies.
|
Thanks Shaun, |
I can certainly remove the |
The current approach of using a public method on |
Thanks, you make a good point, there would need to be a "protected virtual" CreateFileStore method in SMB2Client for that to work. |
What this does
Lets a client send SMB2 create contexts with
CreateFileand read the ones the server answerswith, and adds the pieces needed to open a previous version (shadow copy) of a file.
Closes #371.
Background
CreateRequest.CreateContextsandCreateResponse.CreateContextswere already implemented; the client API simply had no way to reach them. A shadow copy is addressed with theSMB2_CREATE_TIMEWARP_TOKENcreate context.Compatibility
The existing
CreateFileoverload is unchanged and now delegates to the new one passingnullcontexts, so behavior for current callers is identical. Nothing is added toISMBFileStoresince create-contexts are SMB2-specific, and that interface is also implemented by SMB1 and server-side stores. A caller that needs contexts usesSMB2FileStoredirectly.