info

package module
v0.0.0-...-0f65fa0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UsersFile  string = "/etc/passwd"
	GroupsFile string = "/etc/group"
)

Functions

func MustHome

func MustHome() string

MustHome returns running users home, if found/exists or not.

  1. Get home from system data.
  2. Get home from environment variable.
  3. Set home from resolved UID → USERNAME to /home/USERNAME.
  4. Get user from environment variable and assume /home/USERNAME.
  5. Fallback to /home/UID.

func UUID

func UUID() uuid.UUID

UUID provides a simple reproducable pseudo system-UUID for that running system. Just like product_serial or similar to identify the system.

This seems as reliant as product_serial's since operating systems can move anywhere now from physical to virtual hardware and back.

This UUID consists of the following UTS bytes:

Nodename - Usually only set once for a VM.
Machine - Archtecture like x86_64 or arm64. (immutable)
Sysname - VM's usually get a new deployment on reinstall. (Linux/FreeBSD/...)

These bytes get hashed by xxhash3. The returned 16 bytes have special values of "e" at postions 6,8,10 to identify as pseudo system-uuid.

Example: ec9692b4-a3c5-eeb7-eeb1-eeca85334893

UUID() will return a Nil value 00000000-0000-0000-0000-000000000000 if an error occured. You can check the result with uuid.IsNil().

Types

type Group

type Group struct {
	Name    string
	Gid     uint32
	Members []string
}

func GroupById

func GroupById(id uint32) (Group, bool)

GroupById returns the group parameters of the given GID and a found boolean value.

func GroupByName

func GroupByName(name string) (Group, bool)

GroupByName returns the group parameters of the given name and a found boolean value.

func Groups

func Groups() ([]Group, error)

Groups returns all found groups of this system.

type User

type User struct {
	Name    string
	Uid     uint32
	Gid     uint32
	Comment string
	Home    string
	Shell   string
}

func UserById

func UserById(id uint32) (User, bool)

UserById returns the user parameters of the given UID and a found boolean value.

func UserByName

func UserByName(name string) (User, bool)

UserByName returns the user parameters of the given name and a found boolean value.

func Users

func Users() ([]User, error)

Users returns all found users of this system.

type Utsname

type Utsname struct {
	Sysname    []byte
	Nodename   []byte
	Release    []byte
	Version    []byte
	Machine    []byte
	Domainname []byte
}

func Uname

func Uname() (*Utsname, error)

Uname returns a pointer on a filled datastrutre of Utsname.

Directories

Path Synopsis
group module
internal
system module
user module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳