keyctl

package
v5.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package keyctl is a Go interface to linux kernel keyrings (keyctl interface)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Link(parent Keyring, child ID) error

Link a key into a keyring

func SetPerm

func SetPerm(k ID, p KeyPerm) error

SetPerm sets the permissions on a key or keyring.

func Unlink(parent Keyring, child ID) error

Unlink an object from a keyring

Types

type ID

type ID interface {
	ID() int32
}

ID is unique 32-bit serial number identifiers for all Keys and Keyrings have.

type Key

type Key struct {
	Name string
	// contains filtered or unexported fields
}

Key represents a single key linked to one or more kernel keyrings.

func ReadUserKeyring

func ReadUserKeyring() ([]*Key, error)

ReadUserKeyring reads user keyring and returns slice of key with id(key_serial_t) representing the IDs of all the keys that are linked to it

func (*Key) Describe

func (k *Key) Describe() (string, error)

Describe returns a string describing the attributes of a specified key

func (*Key) Get

func (k *Key) Get() ([]byte, error)

Get the key's value as a byte slice

func (*Key) ID

func (k *Key) ID() int32

ID returns the 32-bit kernel identifier for a specific key

func (k *Key) Unlink() error

Unlink a key from the keyring it was loaded from (or added to). If the key is not linked to any other keyrings, it is destroyed.

type KeyPerm

type KeyPerm uint32

KeyPerm represents in-kernel access control permission to keys and keyrings as a 32-bit integer broken up into four permission sets, one per byte. In MSB order, the perms are: Processor, User, Group, Other.

const (
	// PermOtherAll sets all permission for Other
	PermOtherAll KeyPerm = 0x3f << (8 * iota)
	// PermGroupAll sets all permission for Group
	PermGroupAll
	// PermUserAll sets all permission for User
	PermUserAll
	// PermProcessAll sets all permission for Processor
	PermProcessAll
)

type Keyring

type Keyring interface {
	ID
	Add(string, []byte) (*Key, error)
	Search(string) (*Key, error)
}

Keyring is the basic interface to a linux keyctl keyring.

func SessionKeyring

func SessionKeyring() (Keyring, error)

SessionKeyring returns the current login session keyring

func UserKeyring

func UserKeyring() (Keyring, error)

UserKeyring returns the keyring specific to the current user.

Jump to

Keyboard shortcuts

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