fs: fix long path handling for ResetPermissions, ClearAttributes and security descriptors
This commit is contained in:
parent
76d56e24d6
commit
62c4a5e9a0
3 changed files with 6 additions and 6 deletions
|
@ -134,7 +134,7 @@ func IsAccessDenied(err error) bool {
|
||||||
// ResetPermissions resets the permissions of the file at the specified path
|
// ResetPermissions resets the permissions of the file at the specified path
|
||||||
func ResetPermissions(path string) error {
|
func ResetPermissions(path string) error {
|
||||||
// Set the default file permissions
|
// Set the default file permissions
|
||||||
if err := os.Chmod(path, 0600); err != nil {
|
if err := os.Chmod(fixpath(path), 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -85,7 +85,7 @@ func ClearSystem(path string) error {
|
||||||
|
|
||||||
// ClearAttribute removes the specified attribute from the file.
|
// ClearAttribute removes the specified attribute from the file.
|
||||||
func ClearAttribute(path string, attribute uint32) error {
|
func ClearAttribute(path string, attribute uint32) error {
|
||||||
ptr, err := windows.UTF16PtrFromString(path)
|
ptr, err := windows.UTF16PtrFromString(fixpath(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,22 +129,22 @@ func SetSecurityDescriptor(filePath string, securityDescriptor *[]byte) error {
|
||||||
|
|
||||||
// getNamedSecurityInfoHigh gets the higher level SecurityDescriptor which requires admin permissions.
|
// getNamedSecurityInfoHigh gets the higher level SecurityDescriptor which requires admin permissions.
|
||||||
func getNamedSecurityInfoHigh(filePath string) (*windows.SECURITY_DESCRIPTOR, error) {
|
func getNamedSecurityInfoHigh(filePath string) (*windows.SECURITY_DESCRIPTOR, error) {
|
||||||
return windows.GetNamedSecurityInfo(filePath, windows.SE_FILE_OBJECT, highSecurityFlags)
|
return windows.GetNamedSecurityInfo(fixpath(filePath), windows.SE_FILE_OBJECT, highSecurityFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getNamedSecurityInfoLow gets the lower level SecurityDescriptor which requires no admin permissions.
|
// getNamedSecurityInfoLow gets the lower level SecurityDescriptor which requires no admin permissions.
|
||||||
func getNamedSecurityInfoLow(filePath string) (*windows.SECURITY_DESCRIPTOR, error) {
|
func getNamedSecurityInfoLow(filePath string) (*windows.SECURITY_DESCRIPTOR, error) {
|
||||||
return windows.GetNamedSecurityInfo(filePath, windows.SE_FILE_OBJECT, lowBackupSecurityFlags)
|
return windows.GetNamedSecurityInfo(fixpath(filePath), windows.SE_FILE_OBJECT, lowBackupSecurityFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setNamedSecurityInfoHigh sets the higher level SecurityDescriptor which requires admin permissions.
|
// setNamedSecurityInfoHigh sets the higher level SecurityDescriptor which requires admin permissions.
|
||||||
func setNamedSecurityInfoHigh(filePath string, owner *windows.SID, group *windows.SID, dacl *windows.ACL, sacl *windows.ACL) error {
|
func setNamedSecurityInfoHigh(filePath string, owner *windows.SID, group *windows.SID, dacl *windows.ACL, sacl *windows.ACL) error {
|
||||||
return windows.SetNamedSecurityInfo(filePath, windows.SE_FILE_OBJECT, highSecurityFlags, owner, group, dacl, sacl)
|
return windows.SetNamedSecurityInfo(fixpath(filePath), windows.SE_FILE_OBJECT, highSecurityFlags, owner, group, dacl, sacl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setNamedSecurityInfoLow sets the lower level SecurityDescriptor which requires no admin permissions.
|
// setNamedSecurityInfoLow sets the lower level SecurityDescriptor which requires no admin permissions.
|
||||||
func setNamedSecurityInfoLow(filePath string, dacl *windows.ACL) error {
|
func setNamedSecurityInfoLow(filePath string, dacl *windows.ACL) error {
|
||||||
return windows.SetNamedSecurityInfo(filePath, windows.SE_FILE_OBJECT, lowRestoreSecurityFlags, nil, nil, dacl, nil)
|
return windows.SetNamedSecurityInfo(fixpath(filePath), windows.SE_FILE_OBJECT, lowRestoreSecurityFlags, nil, nil, dacl, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// enableBackupPrivilege enables privilege for backing up security descriptors
|
// enableBackupPrivilege enables privilege for backing up security descriptors
|
||||||
|
|
Loading…
Reference in a new issue