package userutil

import "github.com/tredoe/osutil/userutil"

Package userutil provides access to UNIX users database in local files.

You must have enough privileges to access to databases in shadowed files '/etc/shadow' and '/etc/gshadow'. This usually means have to be root. Note: those files are backed-up before of be modified.

In testing, to print the configuration read from the system, there is to use "-v" flag.

Index

Variables

var (
	ErrUserExist  = errors.New("user already exists")
	ErrGroupExist = errors.New("group already exists")
)
var DO_BACKUP = true

DO_BACKUP does a backup before of modify the original files.

var Log = log.New(io.Discard, "", 0)

Functions

func AddGroupFromCmd

func AddGroupFromCmd(syst osutil.System, group string) error

AddGroupFromCmd adds the given group to the original user. Returns an information message, if the command is run.

func CheckSudo

func CheckSudo(syst osutil.System) (err error)

CheckSudo executes command 'sudo' to check that the user has permission.

func IsExist

func IsExist(err error) bool

IsExist returns whether the error is known to report that an user or group already exists. It is satisfied by ErrUserExist and ErrGroupExist.

func MustBeSuperUser

func MustBeSuperUser(syst osutil.System) (err error)

MustBeSuperUser checks if the current user is in the superusers group. Panics if it is not being run as superuser.

func RealUser

func RealUser(syst osutil.System) (string, error)

RealUser returns the original user at Unix systems.

Types

type IdUsedError

type IdUsedError int

IdUsedError reports the presence of an identifier already used.

func (IdUsedError) Error

func (e IdUsedError) Error() string

type NoFoundError

type NoFoundError struct {
	// contains filtered or unexported fields
}

A NoFoundError reports the absence of a value.

func (NoFoundError) Error

func (e NoFoundError) Error() string

type RequiredError

type RequiredError string

A RequiredError reports the name of a required field.

func (RequiredError) Error

func (e RequiredError) Error() string

Source Files

cmd_group.go doc.go error.go file.go log.go sudo.go util.go

Directories

PathSynopsis
userutil/cryptPackage crypt provides interface for password crypt functions and collects common constants.
userutil/crypt/apr1_cryptPackage apr1_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD, and modified by the Apache project.
userutil/crypt/commonPackage common contains routines used by multiple password hashing algorithms.
userutil/crypt/md5_cryptPackage md5_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD.
userutil/crypt/sha256_cryptPackage sha256_crypt implements Ulrich Drepper's SHA256-crypt password hashing algorithm.
userutil/crypt/sha512_cryptPackage sha512_crypt implements Ulrich Drepper's SHA512-crypt password hashing algorithm.
Version
v1.1.3
Published
Aug 2, 2021
Platform
js/wasm
Imports
14 packages
Last checked
1 day ago

Tools for package owners.