capabilities

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

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

Go to latest
Published: Nov 11, 2024 License: BSD-3-Clause Imports: 2 Imported by: 5

Documentation

Overview

capabilities is a convenience module based on kernel.org/pub/linux/libs/security/libcap for linux capabilities(7) with common functions to set/drop privileges and get/list the current capabilities of a process.

You want to use this early in your main() function.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() (set string, iab string)

Get returns lists for the running process of all capabilities set and all inheritable capability vectors: Inh, Amb and Bound as strings.

Example
package main

import (
	"fmt"

	"catinello.eu/capabilities"
)

func main() {
	set, iab := capabilities.Get()

	fmt.Printf("Available capabilities set '%q' and IAB '%q'\n", set, iab)
}
Output:

Available capabilities set '"="' and IAB '""'

func GetAsOne

func GetAsOne() string

GetAsOne combines the returned results of Get() in one string.

func Set

func Set(capabilities string) error

Set drops all available capabilities except for the given capabilities (cap_from_text(3)) on the running process.

Example
package main

import (
	"fmt"
	"log"

	"catinello.eu/capabilities"
)

func main() {
	if err := capabilities.Set(""); err != nil {
		log.Fatal(err)
	}

	set, iab := capabilities.Get()

	fmt.Printf("Available capabilities set '%q' and IAB '%q'\n", set, iab)
}
Output:

Available capabilities set '"="' and IAB '""'

Types

This section is empty.

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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