fork of chmod for windows (from https://github.com/hectane/go-acl)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.9 KiB

//+build windows
package acl
import (
"git.sequentialread.com/forest/go-acl/api"
"golang.org/x/sys/windows"
"unsafe"
)
// Create an ExplicitAccess instance granting permissions to the provided SID.
func GrantSid(accessPermissions uint32, sid *windows.SID) api.ExplicitAccess {
return api.ExplicitAccess{
AccessPermissions: accessPermissions,
AccessMode: api.GRANT_ACCESS,
Inheritance: api.SUB_CONTAINERS_AND_OBJECTS_INHERIT,
Trustee: api.Trustee{
TrusteeForm: api.TRUSTEE_IS_SID,
Name: (*uint16)(unsafe.Pointer(sid)),
},
}
}
// Create an ExplicitAccess instance granting permissions to the provided name.
func GrantName(accessPermissions uint32, name string) api.ExplicitAccess {
return api.ExplicitAccess{
AccessPermissions: accessPermissions,
AccessMode: api.GRANT_ACCESS,
Inheritance: api.SUB_CONTAINERS_AND_OBJECTS_INHERIT,
Trustee: api.Trustee{
TrusteeForm: api.TRUSTEE_IS_NAME,
Name: windows.StringToUTF16Ptr(name),
},
}
}
// Create an ExplicitAccess instance denying permissions to the provided SID.
func DenySid(accessPermissions uint32, sid *windows.SID) api.ExplicitAccess {
return api.ExplicitAccess{
AccessPermissions: accessPermissions,
AccessMode: api.DENY_ACCESS,
Inheritance: api.SUB_CONTAINERS_AND_OBJECTS_INHERIT,
Trustee: api.Trustee{
TrusteeForm: api.TRUSTEE_IS_SID,
Name: (*uint16)(unsafe.Pointer(sid)),
},
}
}
// Create an ExplicitAccess instance denying permissions to the provided name.
func DenyName(accessPermissions uint32, name string) api.ExplicitAccess {
return api.ExplicitAccess{
AccessPermissions: accessPermissions,
AccessMode: api.DENY_ACCESS,
Inheritance: api.SUB_CONTAINERS_AND_OBJECTS_INHERIT,
Trustee: api.Trustee{
TrusteeForm: api.TRUSTEE_IS_NAME,
Name: windows.StringToUTF16Ptr(name),
},
}
}