Skip to content

Check drivesize hidden shares - #460

Draft
inqrphl wants to merge 6 commits into
mainfrom
check-drivesize-hidden-shares
Draft

Check drivesize hidden shares#460
inqrphl wants to merge 6 commits into
mainfrom
check-drivesize-hidden-shares

Conversation

@inqrphl

@inqrphl inqrphl commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Add support for using hidden shares and authenticating to password protected shares, hidden shares are most likely password protected.

The authentication can be done using

  1. the command-line arguments to the check share-user and share-password , ideally specifying the share path alongside both.

  2. new credential system where credentials are saved in category , username , password etc. and loaded at the start or at the beginning

credentials can be read from a config file. windows credentials are added to the session using credWriteW API function

snclient uses windows APIs wNetGetConnectionW , wNetAddConnection2W , wNetCancelConnection2W to add/delete network shares. They just establish a connection, and do not assign a letter to the share.

any added shares are removed when check ends.

do not merge, still needs cleaning up

inqrphl and others added 6 commits August 31, 2026 17:11
these are generally improvements/fixes when share is not mounted to a drive letter, and instead left as an UNC path as is. If it has a drive letter, it is generally used instead.

skip trying to get DeviceFlags and Media Type if path looks like an UNC Path. If paths are UNC paths, but mounted to a drive letter, the drive letter is used instead.

set 'type' attrbibute to 'remote' if an UNC path is used, e.g for discovering a hidden share. Skip calling GetDriveType in these cases

improve localized remote path calculation, trims the seperators more cleanly, works when remote path has multiple seperators at the end

add 'connected' and 'hidden' arguments , windows only and are set if the network drive is connected, used in addPersistentNetworkDrives. Hidden is used if the given UNC path looks to be a hidden drive. This is used if the user specifies multiple paths, but only wants to filter to or out hidden shares.

add tests for the cleanupPathString, isNetworkSharePath , isHiddenSharePath, shareRoot and matchNetworkShare helper functions

general improvements

add timeout to disk.Partitions by using disk.PartitionsWithContext

add new argument: addPersistentNetworkDrives , this tries discovering the persistent network drives when drive=all or drive=all-shares is specified.

This is opt-in so it will only work when its toggled on

If a persistent drive is disconnected/unmounted, the default filter filters them out anyway.

move some functions to take (l *CheckDrivesize) receivers -> helps to isolate these helper functions to checkDrivesize

fix the example output of check_drivesize in windows.

add BoolTo01String function in convert.go -> this might be unnecessary.
credentials: adds parsing of credentials from the config files. a credential is generic, currently it has the fields type, target, username, password and strategy. strategy is the load strategy used, if its loaded at the stard or loaded when its demanded.

use const CredentialTypeWindowsShare = "windows-share" to add windows shares. currently only this type of credentials are used. add helper functions applyCredentialsOnStart , findOnDemandCredential , qualifyUsername, shareTargetFromUNCPath, normalizeCredentialTargetFromUNCPath and move isNetworkSharePath to credentials.go

credential_windows.go adds functions relating to network share credentials using advapi32.dll

addShareCredential uses a saved config credential. uses the CredWriteW, deleteShareCredential uses credDeleteW, hasShareCredential uses credReadW

check_drivesize: use these functions and load on-demand credentials if a network share with credentials are used. additionally, add a share-user and share-password argument. these are used with the currently specified shares as an override
…onnection2W wrappers and organize functions into credentials(_windows).go and network_shares(_windows).go files

with these two functions, a share can be directly connected and is immediately active. it does not have to be mounted to a letter, if we call it with lpLocalName as nil

this is useful since the check can immediately deliver results. the drawback however, since the check browses and SMB path, the SMB redirector caches the credential.

even with an on-demand loading strategy where credentials are deleted immediately, the SMB redirector cache is not cleared. The clearing seems to take 10 seconds.

once the credentials are in SMB redirector cache, browsing the share caches it again. seems like a credential can stay cached indefinitely
@inqrphl
inqrphl force-pushed the check-drivesize-hidden-shares branch from ce9eef9 to 429ce4d Compare August 31, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant