Skip to content

amenzhinsky/go-polkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-polkit

PolKit client library and CLI for golang.

CLI Installation

$ cd $GOPATH/src/github.com/amenzhinsky/go-polkit
$ go install 

CLI Usage

List all PolKit actions:

$ pkquery -verbose

View particular actions:

$ pkquery -verbose org.freedesktop.udisks2.filesystem-fstab org.freedesktop.udisks2.filesystem-mount

Check access to an action:

$ pkquery -check-access org.freedesktop.udisks2.filesystem-fstab

Check access and allow user to interact by typing his password when PolKit requires it:

$ pkquery -check-access -allow-password org.freedesktop.udisks2.filesystem-fstab

Library Usage

Authorization checking

authority, err := polkit.NewAuthority()
if err != nil {
	panic(err)
}

result, err := authority.CheckAuthorization(
	"org.freedesktop.udisks2.filesystem-fstab",
	nil,
	polkit.CheckAuthorizationAllowUserInteraction, "",
)

if err != nil {
	panic(err)
}

fmt.Printf("Is authorized: %t\n", result.IsAuthorized)
fmt.Printf("Is challenge:  %t\n", result.IsChallenge)
fmt.Printf("Details:       %v\n", result.Details)

Actions Enumerating

authority, err := polkit.NewAuthority()
if err != nil {
	panic(err)
}

actions, err := authority.EnumerateActions("")
if err != nil {
	panic(err)
}

for _, action := range actions {
	fmt.Println(action.ActionID)
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages