Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Chown for windows #1269

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion pkg/copy/copy_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,40 @@ package copy

import (
"os"

"golang.org/x/sys/windows"
)

func IsUID(info os.FileInfo, uid uint32) bool {
return true
}

// Lchown implementation for windows
// inspired by: https://gist.github.com/micahyoung/4163bbe0195a18850706e7f34cef3c01
func Lchown(info os.FileInfo, sourcePath, destPath string) error {
return nil

secInfo, err := windows.GetNamedSecurityInfo(
sourcePath,
windows.SE_FILE_OBJECT,
windows.OWNER_SECURITY_INFORMATION)

if err != nil {
return err
}

owner, _, err := secInfo.Owner()
if err != nil {
return err
}

// write a owner SIDs to the file's security descriptor
return windows.SetNamedSecurityInfo(
destPath,
windows.SE_FILE_OBJECT,
windows.OWNER_SECURITY_INFORMATION,
owner,
nil,
nil,
nil,
)
}
Loading