osutil

package
v5.0.0-preview.1+incom... Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 17 Imported by: 15

Documentation

Index

Constants

View Source
const ErrorNotDirectory string = "src is not a directory"

///////

View Source
const UserUidMin int = 1000

Variables

This section is empty.

Functions

func CheckProcessOpenDevTun

func CheckProcessOpenDevTun(pid int) (bool, string)

func CheckUidAuthority

func CheckUidAuthority(user string, pid int) (bool, error)

func CopyDir

func CopyDir(src string, dst string) error

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func GetAllProcesses

func GetAllProcesses() utils.Set

func GetAllUsers

func GetAllUsers(pid int, users map[int]string) (int, int, error)

This is to enter process' mount namespace and get the passwd file.

func GetContainerDaemonArgs

func GetContainerDaemonArgs() ([]string, error)

func GetContainerRealFilePath

func GetContainerRealFilePath(pid int, path string) (string, error)

try to get sym link

func GetContainerSocketTable

func GetContainerSocketTable(rootPid int) map[uint32]SocketInfo

Container's socket tables are located at /proc/[rootPid]/root/proc/1/net/ inode is unique and handle either only one service

func GetExePathFromLink(pid int) (string, error)

func GetFDSocketInode

func GetFDSocketInode(pid int, fd int) (uint32, error)

func GetFileHash

func GetFileHash(filepath string) ([fileHashKeep]byte, error)

func GetProcessGroupId

func GetProcessGroupId(pid int) int

func GetProcessName

func GetProcessName(pid int) string

func GetProcessPIDs

func GetProcessPIDs(pid int) (ppid, gid, sid int, status, cmd string)

Get ppid, group and session id from /proc/<pid>/stat Error if ppid is -1

func GetProcessSocketInodes

func GetProcessSocketInodes(pid int) (utils.Set, error)

func GetProcessUIDs

func GetProcessUIDs(pid int) (name string, ppid, ruid, euid int)

Get the process parent id and uid from /proc/<pid>/status Error if ppid is -1

func GetSessionId

func GetSessionId(pid int) int

func HashZero

func HashZero(hash [fileHashKeep]byte) bool

func IsPackageLib

func IsPackageLib(path string) bool

func IsPidValid

func IsPidValid(pid int) bool

Types

type Connection

type Connection struct {
	LocIP    net.IP
	RemIP    net.IP
	LocPort  uint16
	RemPort  uint16
	Ether    uint16
	Protocol uint8
}

func GetProcessConnection

func GetProcessConnection(pid int, clientPort *share.CLUSProtoPort, inodes utils.Set) *Connection

type FileInfoExt

type FileInfoExt struct {
	ContainerId string
	Path        string
	Link        string
	FileMode    os.FileMode
	Size        int64
	Hash        [fileHashKeep]byte
	Filter      interface{}
	Children    []*FileInfoExt
	Protect     bool
	UserAdded   bool
}

func GetFileDirInfo

func GetFileDirInfo(file string) FileInfoExt

func GetFileInfoExtFromPath

func GetFileInfoExtFromPath(root int, path string, flt interface{}, protect, userAdded bool) []*FileInfoExt

get the file information, if the file is a symlink, return both the symlink and the real file

func GetFileInfoExtFromPid

func GetFileInfoExtFromPid(root, pid int) []*FileInfoExt

type SocketInfo

type SocketInfo struct {
	IPProto uint8
	Port    uint16
	INode   uint32
}

Jump to

Keyboard shortcuts

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