Documentation
¶
Overview ¶
Package util contains common functions for use in the osconfig agent.
Index ¶
- func AtomicWrite(path string, content []byte, mode os.FileMode) (err error)
- func AtomicWriteFileStream(r io.Reader, checksum, path string, mode os.FileMode) (string, error)
- func Exists(name string) bool
- func NormPath(path string) (string, error)
- func SanitizePath(path string) string
- func TempFile(dir string, pattern string, mode os.FileMode) (f *os.File, err error)
- type CommandRunner
- type DefaultRunner
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicWrite ¶
AtomicWrite attempts to atomically write a file.
func AtomicWriteFileStream ¶
AtomicWriteFileStream attempts to atomically write data from the provided reader to the path checking the checksum if provided.
func NormPath ¶
NormPath transforms a windows path into an extended-length path as described in https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath when not running on windows it will just return the input path.
func SanitizePath ¶
SanitizePath ensures that relative path does not contains ".." to avoid directory traversal attacks. As well run filepath.Clean to remove redundant path segments.
Types ¶
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, command *exec.Cmd) ([]byte, []byte, error)
}
CommandRunner will execute the commands and return the results of that execution.