-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathutil.go
62 lines (55 loc) · 1.84 KB
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//+build windows
package acl
import (
"github.com/hectane/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),
},
}
}