Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hectane/go-acl
Go library for manipulating ACLs on Windows
https://github.com/hectane/go-acl
acl chmod golang permissions
Last synced: 28 days ago
JSON representation
Go library for manipulating ACLs on Windows
- Host: GitHub
- URL: https://github.com/hectane/go-acl
- Owner: hectane
- License: mit
- Created: 2015-10-29T23:01:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T03:12:52.000Z (almost 2 years ago)
- Last Synced: 2024-02-15T10:35:56.619Z (10 months ago)
- Topics: acl, chmod, golang, permissions
- Language: Go
- Size: 36.1 KB
- Stars: 118
- Watchers: 10
- Forks: 28
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- cybersecurity-golang-security - go-acl - Go library for manipulating ACLs on Windows. (Windows Specific)
- awesome-go-security - go-acl - Go library for manipulating ACLs on Windows. (Windows Specific)
README
## go-acl
[![Build status](https://ci.appveyor.com/api/projects/status/rbdyu7c39o2j0ru9?svg=true)](https://ci.appveyor.com/project/nathan-osman/go-acl)
[![GoDoc](https://godoc.org/github.com/hectane/go-acl?status.svg)](https://godoc.org/github.com/hectane/go-acl)
[![MIT License](http://img.shields.io/badge/license-MIT-9370d8.svg?style=flat)](http://opensource.org/licenses/MIT)Manipulating ACLs (Access Control Lists) on Windows is difficult. go-acl wraps the Windows API functions that control access to objects, simplifying the process.
### Using the Package
To use the package add the following imports:
import (
"github.com/hectane/go-acl"
"golang.org/x/sys/windows"
)### Examples
Probably the most commonly used function in this package is `Chmod`:
if err := acl.Chmod("C:\\path\\to\\file.txt", 0755); err != nil {
panic(err)
}To grant read access to user "Alice" and deny write access to user "Bob":
if err := acl.Apply(
"C:\\path\\to\\file.txt",
false,
false,
acl.GrantName(windows.GENERIC_READ, "Alice"),
acl.DenyName(windows.GENERIC_WRITE, "Bob"),
); err != nil {
panic(err)
}### Using the API Directly
go-acl's `api` package exposes the individual Windows API functions that are used to manipulate ACLs. For example, to retrieve the current owner of a file:
import (
"github.com/hectane/go-acl/api"
"golang.org/x/sys/windows"
)var (
owner *windows.SID
secDesc windows.Handle
)
err := api.GetNamedSecurityInfo(
"C:\\path\\to\\file.txt",
api.SE_FILE_OBJECT,
api.OWNER_SECURITY_INFORMATION,
&owner,
nil,
nil,
nil,
&secDesc,
)
if err != nil {
panic(err)
}
defer windows.LocalFree(secDesc)`owner` will then point to the SID for the owner of the file.