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
- func AddGroupFromCmd(syst osutil.System, group string) error
- func CheckSudo(syst osutil.System) (err error)
- func IsExist(err error) bool
- func MustBeSuperUser(syst osutil.System) (err error)
- func RealUser(syst osutil.System) (string, error)
- type IdUsedError
- type NoFoundError
- type RequiredError
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.
Functions ¶
func AddGroupFromCmd ¶
AddGroupFromCmd adds the given group to the original user. Returns an information message, if the command is run.
func CheckSudo ¶
CheckSudo executes command 'sudo' to check that the user has permission.
func IsExist ¶
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 ¶
MustBeSuperUser checks if the current user is in the superusers group. Panics if it is not being run as superuser.
func RealUser ¶
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 ¶
Path | Synopsis |
---|---|
userutil/crypt | Package crypt provides interface for password crypt functions and collects common constants. |
userutil/crypt/apr1_crypt | Package apr1_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD, and modified by the Apache project. |
userutil/crypt/common | Package common contains routines used by multiple password hashing algorithms. |
userutil/crypt/md5_crypt | Package md5_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD. |
userutil/crypt/sha256_crypt | Package sha256_crypt implements Ulrich Drepper's SHA256-crypt password hashing algorithm. |
userutil/crypt/sha512_crypt | Package sha512_crypt implements Ulrich Drepper's SHA512-crypt password hashing algorithm. |
- Version
- v1.1.2
- Published
- Aug 2, 2021
- Platform
- js/wasm
- Imports
- 14 packages
- Last checked
- 1 day ago –
Tools for package owners.