localexec

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIllegalCmdsFields Cmds经空格切分后,每一部分都必须不以/为前缀、且不存在..
	ErrIllegalCmdsFields = errors.New("the fields of cmds has illegal prefix `/` or contains illegal string `..`")
	// ErrIllegalRelativePath relativePath包含..或其为绝对路径
	ErrIllegalRelativePath = errors.New("relativePath contains illegal string `..` and must not be absolute path")
	// ErrIllegalAbsPath absPath包含..、不为绝对路径或不包含指定前缀
	ErrIllegalAbsPath = errors.New("relativePath contains illegal string `..`, must not be absolute path and must have special prefix")
)

Functions

func ValidateAbsPath

func ValidateAbsPath(absPath string, basedir string) error

ValidateAbsPath 验证相对路径是否合法

func ValidateRelativePath

func ValidateRelativePath(relativePath string) error

ValidateRelativePath 验证相对路径是否合法

Types

type Result

type Result struct {
	Code   int    `json:"code"`
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
}

Result cmd的返回结果

func ExecBatchCmdS

func ExecBatchCmdS(timeout time.Duration, dir string, cmds string) (*Result, error)

ExecBatchCmdS 批量执行shell命令

func ExecCmd

func ExecCmd(timeout time.Duration, dir string, cmdName string, args ...string) (*Result, error)

ExecCmd 执行linux命令

func ExecRestrictedBatchCmdS

func ExecRestrictedBatchCmdS(timeout time.Duration, basedir, relativePath, cmds string) (*Result, error)

ExecRestrictedBatchCmdS 批量执行受限的shell命令 relativePath中不得包含.. cmds中不得包含/的前缀或..

Jump to

Keyboard shortcuts

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