v1.13.0
ADDED: * Convenience functions to determine if a process is running in an elevated/dropped privileges context
This commit is contained in:
53
types_linux.go
Normal file
53
types_linux.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package sysutils
|
||||
|
||||
import (
|
||||
`golang.org/x/sys/unix`
|
||||
)
|
||||
|
||||
/*
|
||||
IDState collects information about the current running process.
|
||||
It should only be used as returned from GetIDState().
|
||||
Its methods WILL return false information if any of these values are altered.
|
||||
|
||||
FSUID/FSGID are not supported.
|
||||
*/
|
||||
type IDState struct {
|
||||
// RUID: Real UID
|
||||
RUID int
|
||||
// EUID: Effective UID
|
||||
EUID int
|
||||
// SUID: Saved Set UID
|
||||
SUID int
|
||||
// RGID: Real GID
|
||||
RGID int
|
||||
// EGID: Effective GID
|
||||
EGID int
|
||||
// SGID: Saved Set GID
|
||||
SGID int
|
||||
// SudoEnvUser is true if SUDO_USER or SUDO_UID is set.
|
||||
SudoEnvUser bool
|
||||
// SudoEnvGroup is true if SUDO_GID is set.
|
||||
SudoEnvGroup bool
|
||||
// SudoEnvCmd is true if SUDO_COMMAND is set.
|
||||
SudoEnvCmd bool
|
||||
// SudoEnvHome is true if SUDO_HOME is set.
|
||||
SudoEnvHome bool
|
||||
// SudoEnvVars is true if any of the "well-known" sudo environment variables are set.
|
||||
SudoEnvVars bool
|
||||
// PPIDUidMatch is true if the parent PID UID matches the current process UID (mismatch usually indicates sudo invocation).
|
||||
PPIDUidMatch bool
|
||||
// PPIDGidMatch is true if the parent PID GID matches the current process GID (mismatch usually indicates sudo invocation).
|
||||
PPIDGidMatch bool
|
||||
// uidsChecked is true if the RUID, EUID, and SUID have been populated. (They will be 0 if unset OR if root.)
|
||||
uidsChecked bool
|
||||
// gidsChecked is true if the RGID, EGID, and SGID have been populated. (They will be 0 if unset OR if root.)
|
||||
gidsChecked bool
|
||||
// sudoChecked is true if the SudoEnvVars is set.
|
||||
sudoChecked bool
|
||||
// ppidUidChecked is true if the PPIDUidMatch is set.
|
||||
ppidUidChecked bool
|
||||
// ppidGidChecked is true if the PPIDGidMatch is set.
|
||||
ppidGidChecked bool
|
||||
// stat holds the stat information for the parent PID.
|
||||
stat *unix.Stat_t
|
||||
}
|
||||
Reference in New Issue
Block a user