keyctl

package module
v0.0.0-...-b8df48b Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

README

keyctl

Slim version of github.com/jsipprell/keyctl with basic keyring operations.

Documentation

Overview

A Go interface to linux kernel keyrings (keyctl interface)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chgrp

func Chgrp(k Id, group int) error

Change group ownership on a key or keyring.

func Chown

func Chown(k Id, user int) error

Change user ownership on a key or keyring.

func SetPerm

func SetPerm(k Id, p KeyPerm) error

Set 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
	// contains filtered or unexported methods
}

All Keys and Keyrings have unique 32-bit serial number identifiers.

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 (*Key) Get

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

Get returns 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 (*Key) Set

func (k *Key) Set(b []byte) error

Set the key's value from a bytes slice. Expiration, if active, is reset by calling this method.

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 (
	PermOtherView KeyPerm = 1 << iota
	PermOtherRead
	PermOtherWrite
	PermOtherSearch
	PermOtherLink
	PermOtherSetattr
)
const (
	PermGroupView KeyPerm = 1 << (8 + iota)
	PermGroupRead
	PermGroupWrite
	PermGroupSearch
	PermGroupLink
	PermGroupSetattr
)
const (
	PermUserView KeyPerm = 1 << (16 + iota)
	PermUserRead
	PermUserWrite
	PermUserSearch
	PermUserLink
	PermUserSetattr
)
const (
	PermProcessView KeyPerm = 1 << (24 + iota)
	PermProcessRead
	PermProcessWrite
	PermProcessSearch
	PermProcessLink
	PermProcessSetattr
)
const (
	PermOtherAll KeyPerm = 0x3f << (8 * iota)
	PermGroupAll
	PermUserAll
	PermProcessAll
)

func (KeyPerm) Group

func (p KeyPerm) Group() string

Returns the group permissions in symbolic form

func (KeyPerm) Other

func (p KeyPerm) Other() string

Returns other (default) permissions in symbolic form

func (KeyPerm) Process

func (p KeyPerm) Process() string

Returns processor permissions in symbolic form

func (KeyPerm) String

func (p KeyPerm) String() string

func (KeyPerm) User

func (p KeyPerm) User() string

Returns the user permissions in symbolic form

type Keyring

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

Basic interface to a linux keyctl keyring.

func SessionKeyring

func SessionKeyring() (Keyring, error)

Return the current login session keyring

type NamedKeyring

type NamedKeyring interface {
	Keyring
	Name() string
}

Named keyrings are user-created keyrings linked to a parent keyring. The parent can be either named or one of the in-built keyrings (session, group etc). The in-built keyrings have no parents. Keyring searching is performed hierarchically.

Jump to

Keyboard shortcuts

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