godrop

package module
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: BSD-3-Clause Imports: 9 Imported by: 7

README

godrop - drop privileges

Godrop is a simple library to drop privileges on Linux and OpenBSD.

See the examples directory on how to use the Drop and MultiDrop functions.

Documentation

Overview

Package godrop provides a simple library to drop privileges on Linux and OpenBSD.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Drop

func Drop(c Config, f func() (net.Listener, error)) error

Drop will spawn a new process and hand over the listening socket file descriptor

func GetListener

func GetListener() (net.Listener, error)

GetListener returns the listener socket of file descriptor 3

func GetListenerFd

func GetListenerFd(fd int) (net.Listener, error)

GetListenerFd returns the listener socket of the given file descriptor

func MultiDrop

func MultiDrop(c Config, f func() ([]net.Listener, error)) error

MultiDrop will spawn a new process and hand over the all listening sockets

func Pledge added in v2.1.0

func Pledge(promises, execpromises string) error

Pledge is currently only supported on OpenBSD.

func PledgeExecpromises added in v2.1.0

func PledgeExecpromises(execpromises string) error

PledgeExecPromises is currently only supported on OpenBSD.

func PledgePromises added in v2.1.0

func PledgePromises(promises string) error

PledgePromises is currently only supported on OpenBSD.

func Unveil added in v2.1.0

func Unveil(path, flags string) error

Unveil is currently only supported on OpenBSD.

func UnveilBlock added in v2.1.0

func UnveilBlock() error

UnveilBlock is currently only supported on OpenBSD.

Types

type Config

type Config struct {
	// User is the user to drop privileges to.
	User string
	// Group is the group to drop privileges to.
	Group string
	// Chroot is the directory to chroot into. Leave this emptry for no chroot.
	// When compiling without cgo, make sure the chroot directory contains the /etc/passwd and /etc/group files.
	Chroot string
	// Set to true, to run the process in the foreground.
	Foreground bool
}

Config represents the drop config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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