-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsecurity_descriptor.go
71 lines (57 loc) · 1.27 KB
/
security_descriptor.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
63
64
65
66
67
68
69
70
71
package dtyp
import (
"context"
"github.com/oiweiwei/go-msrpc/ndr"
)
func (o *SecurityDescriptor) Parse(b []byte) error {
r := ndr.NDR20(b, ndr.Opaque)
r.ReadData(&o.Revision)
r.ReadData(&o.SBZ1)
r.ReadData(&o.Control)
if r.Err() != nil {
return r.Err()
}
if o.Control&SelfRelative == 0 {
return ndr.NDR20(b, ndr.Opaque).Unmarshal(context.Background(), o)
}
r.ReadData(&o.OffsetOwner)
r.ReadData(&o.OffsetGroup)
r.ReadData(&o.OffsetSACL)
r.ReadData(&o.OffsetDACL)
if r.Err() != nil {
return r.Err()
}
if o.OffsetOwner != 0 {
if o.Owner == nil {
o.Owner = &SID{}
}
if err := r.WithBytes(b[o.OffsetOwner:]).Unmarshal(context.Background(), o.Owner); err != nil {
return err
}
}
if o.OffsetGroup != 0 {
if o.Group == nil {
o.Group = &SID{}
}
if err := r.WithBytes(b[o.OffsetGroup:]).Unmarshal(context.Background(), o.Group); err != nil {
return err
}
}
if o.OffsetSACL != 0 {
if o.SACL == nil {
o.SACL = &ACL{}
}
if err := r.WithBytes(b[o.OffsetSACL:]).Unmarshal(context.Background(), o.SACL); err != nil {
return err
}
}
if o.OffsetDACL != 0 {
if o.DACL == nil {
o.DACL = &ACL{}
}
if err := r.WithBytes(b[o.OffsetDACL:]).Unmarshal(context.Background(), o.DACL); err != nil {
return err
}
}
return nil
}