Check drivesize hidden shares - #460
Draft
inqrphl wants to merge 6 commits into
Draft
Conversation
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
force-pushed
the
check-drivesize-hidden-shares
branch
from
August 31, 2026 15:11
ce9eef9 to
429ce4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
the command-line arguments to the check share-user and share-password , ideally specifying the share path alongside both.
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