Documentation ¶
Overview ¶
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
Index ¶
- Variables
- func ErrorExit(template string, stuff ...interface{}) int
- func Exec(stdin io.Reader, stdout, stderr io.Writer, programName string, ...) (exitStatus int, stdoutStr, stderrStr string, execErr error)
- func GetHostnameAndIP() (hostname string, ip string)
- func Input(mandatory bool, defaultHint string, format string, values ...interface{}) string
- func InputAbsFilePath(mandatory bool, defaultHint string, format string, values ...interface{}) string
- func InputBool(defaultHint bool, format string, values ...interface{}) bool
- func InputInt(mandatory bool, defaultHint, lowerLimit, upperLimit int, format string, ...) int
- func InputPassword(mandatory bool, defaultHint string, format string, values ...interface{}) string
- func LockMem()
- func SetTermEcho(echo bool)
- func SystemctlDisableStop(svc string) error
- func SystemctlEnableRestart(svc string) error
- func SystemctlEnableStart(svc string) error
- func SystemctlGetMainPID(svc string) (mainPID int)
- func SystemctlIsRunning(svc string) bool
- func SystemctlStart(svc string) error
- func SystemctlStop(svc string) error
- func WalkProcs(fun func(cmdLine []string) bool) error
- type Sysconfig
- func (conf *Sysconfig) GetBool(key string, defaultValue bool) bool
- func (conf *Sysconfig) GetInt(key string, defaultValue int) int
- func (conf *Sysconfig) GetIntArray(key string, defaultValue []int) (ret []int)
- func (conf *Sysconfig) GetString(key, defaultValue string) string
- func (conf *Sysconfig) GetStringArray(key string, defaultValue []string) (ret []string)
- func (conf *Sysconfig) GetUint64(key string, defaultValue uint64) uint64
- func (conf *Sysconfig) Set(key string, value interface{})
- func (conf *Sysconfig) SetIntArray(key string, values []int)
- func (conf *Sysconfig) SetStrArray(key string, values []string)
- func (conf *Sysconfig) ToText() string
- type SysconfigEntry
Constants ¶
This section is empty.
Variables ¶
var TermEcho bool = true // keep track of the latest change to terminal echo made by SetTermEcho function
Functions ¶
func ErrorExit ¶
Print the message to stderr and exit the program with status 1. The function does not return, however it is defined to have a return value to help with coding style.
func Exec ¶
func Exec(stdin io.Reader, stdout, stderr io.Writer, programName string, programArgs ...string) (exitStatus int, stdoutStr, stderrStr string, execErr error)
Run an external program, wait till it finishes execution, eventually return its exit status. Optionally return the program output only if stdout/stderr are left nil.
func GetHostnameAndIP ¶
Make a best effort at determining this computer's host name (FQDN preferred) and IP address.
func Input ¶
Print a prompt in stdout and return a trimmed line read from stdin. If mandatory switch is turned on, the function will keep asking for an input if default hint is unavailable.
func InputAbsFilePath ¶
func InputAbsFilePath(mandatory bool, defaultHint string, format string, values ...interface{}) string
Print a prompt in stdout and return a file path (must exist be absolute) read from stdin.
func InputInt ¶
func InputInt(mandatory bool, defaultHint, lowerLimit, upperLimit int, format string, values ...interface{}) int
Print a prompt in stdout and return an integer read from stdin.
func InputPassword ¶
Disable terminal echo and read a password input from stdin, then re-enable terminal echo.
func LockMem ¶
func LockMem()
Lock all program memory into main memory to prevent sensitive data from leaking into swap.
func SystemctlDisableStop ¶
SystemctlStop uses systemctl command to disable and stop a service.
func SystemctlEnableRestart ¶
Cal systemctl enable and then systemctl start on thing. Panic on error.
func SystemctlEnableStart ¶
Cal systemctl enable and then systemctl start on the service.
func SystemctlGetMainPID ¶
Cal systemctl to get main PID of a service. Return 0 on failure.
func SystemctlIsRunning ¶
Return true only if systemctl suggests that the thing is running.
func SystemctlStop ¶
SystemctlStop uses systemctl command to stop a service.
Types ¶
type Sysconfig ¶
type Sysconfig struct { AllValues []*SysconfigEntry // All key-value pairs in the orignal order. KeyValue map[string]*SysconfigEntry }
Key-value pairs of a sysconfig file. It is able to convert back to original text in the original key order.
func ParseSysconfig ¶
Read sysconfig text and parse the text into memory structures.
func ParseSysconfigFile ¶
Read sysconfig file and parse the file content into memory structures.
func (*Sysconfig) GetBool ¶
Return bool value that belongs to the key, or the default value if key does not exist. True values are "yes" or "true".
func (*Sysconfig) GetInt ¶
Return integer value that belongs to the key, or the default if the key does not exist or value is not an integer.
func (*Sysconfig) GetIntArray ¶
Assume the key carries a space-separated array of integers, return the array. Discard malformed integers.
func (*Sysconfig) GetString ¶
Return string value that belongs to the key, or the default value if the key does not exist.
func (*Sysconfig) GetStringArray ¶
Assume the key carries a space-separated array value, return the value array.
func (*Sysconfig) GetUint64 ¶
Return uint64 value that belongs to the key, or the default if the key does not exist or value is not an integer.
func (*Sysconfig) SetIntArray ¶
Give a space-separated integer array value to a key. If the key does not yet exist, it is created.
func (*Sysconfig) SetStrArray ¶
Give a space-separated string array value to a key. If the key does not yet exist, it is created.
type SysconfigEntry ¶
type SysconfigEntry struct { LeadingComments []string // The comment lines leading to the key-value pair, including prefix '#', excluding end-of-line. Key string // The key. Value string // The value, excluding '=' character and double-quotes. Values will always come in double-quotes when converted to text. }
A single key-value pair in sysconfig file.