authorization

package
v0.0.0-...-4688182 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2021 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

package authorization implements win32 authorization functions that don't seem to exist in other libraries see https://msdn.microsoft.com/en-us/library/windows/desktop/aa375742(v=vs.85).aspx

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAccessRule

func AddAccessRule(handle syscall.Handle, objectType ObjectType, replace, inherit bool, entries ...ExplicitAccess) error

AddAccessRule modifies the access list for the given object This function and some struct/const above borrowed with thanks from https://github.com/hectane/go-acl

func GetLogonSid

func GetLogonSid(token syscall.Token) (*syscall.SID, error)

func GetSecurityInfo

func GetSecurityInfo(handle syscall.Handle,
	objectType ObjectType,
	securityInformation SecurityInformation,
	sidOwner **syscall.SID,
	sidGroup **syscall.SID,
	dacl **ACL,
	sacl **ACL,
	securityDescriptor **SecurityDescriptor) error

GetSecurityInfo - see https://msdn.microsoft.com/en-us/library/windows/desktop/aa446654(v=vs.85).aspx

func IsValidSid

func IsValidSid(sid *syscall.SID) error

func SetSecurityInfo

func SetSecurityInfo(handle syscall.Handle,
	objectType ObjectType,
	securityInformation SecurityInformation,
	sidOwner **syscall.SID,
	sidGroup **syscall.SID,
	dacl *ACL,
	sacl *ACL) error

SetSecurityInfo - see https://msdn.microsoft.com/en-us/library/windows/desktop/aa379588(v=vs.85).aspx

func SetTokenInformation

func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) error

copied from internal/syscall/windows

func SetTokenSessionId

func SetTokenSessionId(token syscall.Token, sessionID uint32) error

Types

type ACL

type ACL struct {
	AclRevision uint8
	Sbz1        uint8
	AclSize     uint16
	AceCount    uint16
	Sbz2        uint16
}

ACL is defined at https://msdn.microsoft.com/en-us/library/windows/desktop/aa374931(v=vs.85).aspx

type AccessMode

type AccessMode uint32
const (
	NotUsedAccess AccessMode = iota
	GrantAccess
	SetAccess
	DenyAccess
	RevokeAccess
	SetAuditSuccess
	SetAuditFailure
)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa374899.aspx

type ExplicitAccess

type ExplicitAccess struct {
	AccessPermissions uint32
	AccessMode        AccessMode
	Inheritance       InheritanceMode
	Trustee           Trustee
}

https://msdn.microsoft.com/en-us/library/windows/desktop/aa446627(v=vs.85).aspx

func GrantSid

func GrantSid(accessPermissions uint32, inheritance InheritanceMode, sid *syscall.SID) ExplicitAccess

Create an ExplicitAccess instance granting permissions to the provided SID

type InheritanceMode

type InheritanceMode uint32
const (
	NoInheritance                  InheritanceMode = 0x0
	SubObjectsOnlyInherit          InheritanceMode = 0x1
	SubContainersOnlyInherit       InheritanceMode = 0x2
	SubContainersAndObjectsInherit InheritanceMode = 0x3
	InheritNoPropagate             InheritanceMode = 0x4
	InheritOnly                    InheritanceMode = 0x8

	ObjectInheritAce      InheritanceMode = 0x1
	ContainerInheritAce   InheritanceMode = 0x2
	NoPropagateInheritAce InheritanceMode = 0x4
	InheritOnlyAce        InheritanceMode = 0x8
)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa446627.aspx https://msdn.microsoft.com/en-us/library/aa392711(v=vs.85).aspx

type MultipleTrusteeOperation

type MultipleTrusteeOperation uint32

type ObjectType

type ObjectType uint32

ObjectType is win32 SE_OBJECT_TYPE - see https://msdn.microsoft.com/en-us/library/windows/desktop/aa379593(v=vs.85).aspx

const (
	UnknownObjectType ObjectType = iota
	FileObject
	Service
	Printer
	RegistryKey
	LMShare
	KernelObject
	WindowObject
	DSObject
	DSObjectAll
	ProviderDefinedObject
	WmiGuidObject
	RegistryWow64_32Key
)

type SecurityDescriptor

type SecurityDescriptor struct{}

SecurityDescriptor is win32 SECURITY_DESCRIPTOR - see https://msdn.microsoft.com/en-us/library/windows/desktop/aa379561(v=vs.85).aspx

type SecurityInformation

type SecurityInformation uint32

SecurityInformation is win32 SECURITY_INFORMATION - https://msdn.microsoft.com/en-us/library/windows/desktop/aa379573(v=vs.85).aspx see also https://msdn.microsoft.com/en-us/library/windows/desktop/aa379573(v=vs.85).aspx

const (
	OwnerSecurityInformation             SecurityInformation = 0x00000001
	GroupSecurityInformation             SecurityInformation = 0x00000002
	DaclSecurityInformation              SecurityInformation = 0x00000004
	SaclSecurityInformation              SecurityInformation = 0x00000008
	LabelSecurityInformation             SecurityInformation = 0x00000010
	AttributeSecurityInformation         SecurityInformation = 0x00000020
	ScopeSecurityInformation             SecurityInformation = 0x00000040
	ProcessTrustLabelSecurityInformation SecurityInformation = 0x00000080
	BackupSecurityInformation            SecurityInformation = 0x00010000
	ProtectedDaclSecurityInformation     SecurityInformation = 0x80000000
	ProtectedSaclSecurityInformation     SecurityInformation = 0x40000000
	UnprotectedDaclSecurityInformation   SecurityInformation = 0x20000000
	UnprotectedSaclSecurityInformation   SecurityInformation = 0x10000000
)

type TokenGroups

type TokenGroups []syscall.SIDAndAttributes

func GetTokenGroups

func GetTokenGroups(token syscall.Token) (TokenGroups, error)

GetTokenGroups invokes GetTokenInformation, requesting TOKEN_GROUPS https://msdn.microsoft.com/en-us/library/windows/desktop/aa379624(v=vs.85).aspx

type Trustee

type Trustee struct {
	MultipleTrustee          *Trustee
	MultipleTrusteeOperation MultipleTrusteeOperation
	TrusteeForm              TrusteeForm
	TrusteeType              int32
	Name                     *uint16
}

https://msdn.microsoft.com/en-us/library/windows/desktop/aa379636(v=vs.85).aspx

type TrusteeForm

type TrusteeForm uint32
const (
	TrusteeIsSid TrusteeForm = iota
	TrusteeIsName
	TrusteeBadForm
	TrusteeIsObjectsAndSid
	TrusteeIsObjectsAndName
)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa379638.aspx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL