Repository navigation
smbserver: report the configured share type over SMB2 - #2355
qianeric-backup wants to merge 1 commit into
Conversation
Shares served over SMB2 all came back as `Disk`. `addShare` stores the type
as a string from the config section, and the SMB1 handlers convert it:
entry['Type'] = int(shares[i]['share type'])
while the two SMB2 handlers assigned it straight into the NDR field:
answer['InfoStruct']['ShareInfo1']['shi1_type'] = share['share type']
shareInfo['shi1_type'] = self._shares[i]['share type']
so a printer or an IPC share was announced as a disk tree:
Sharename Type
IPC$ Disk
DISK Disk
PRINTER Disk
Convert in both SMB2 handlers, matching what the SMB1 ones already do.
Verified with smbclient against a server exposing disk, printer and IPC
shares:
before after
IPC$ type=0 -> Disk IPC$ type=3 -> IPC
DISK type=0 -> Disk DISK type=0 -> Disk
PRINTER type=0 -> Disk PRINTER type=1 -> Printer
test_smbserver_list_shares_types covers this for every SMB dialect the
suite runs. It fails on the four SMB2 subclasses before the change and
passes after; the SMB1 subclass passed either way, which matches where the
conversion was already present.
Fixes fortra#2271
|
this one looks like duplicate of #2280 |
|
You're right, this is a duplicate of #2280 -- same two lines, same @gabrielg5's change is the correct minimal fix and I'd rather not split the review across two PRs. For what it's worth, I did verify the behaviour end-to-end against a server exposing three share types, which may save whoever reviews #2280 some time: Also worth noting while you're in there: the SMB1 handlers already coerce with |
What this fixes
Shares served over SMB2 all came back as
Disk, whatever type they were configured with.addSharestores the type as a string coming from the config section, and the SMB1 handlers convertit:
but the two SMB2 handlers assigned it straight into the NDR field:
so a printer or an IPC share was announced as a disk tree. Thanks to @rwakulszowa for pointing at
the two lines.
Fixes #2271.
Verification
smbclientagainst a server exposing a disk share, ashareType="1"printer and anshareType="3"IPC share:Test
test_smbserver_list_shares_typeslists shares from a server with all three types and asserts thereported types. It runs under every dialect the suite covers, and the before/after is unambiguous:
The five that failed are exactly the SMB2 subclasses (
SimpleSMBServer2FuncTests,SimpleSMBServer2FuncTestsClientFallBack,SimpleSMBServer21FuncTests,SimpleSMBServer311FuncTests); the SMB1 subclass passed before the change too, which matches thefact that its handlers already had the conversion. Full file:
89 passed, 8 skipped.Scope
Two lines changed, both in the SMB2 share enumeration/query handlers. No behaviour change for SMB1,
and no change to how the type is stored or parsed.