Raise error if /etc/hostid not readable

This commit is contained in:
yo
2022-04-05 22:21:04 +02:00
parent 0f97270a6a
commit e0f371693a
2 changed files with 11 additions and 4 deletions

View File

@ -18,12 +18,12 @@ import (
/*****************************************************************************
* Mandatory constructor for JailConfig type. It set default values
*****************************************************************************/
func NewJailConfig() JailConfig {
func NewJailConfig() (JailConfig, error) {
var jc JailConfig
hostid, err := ioutil.ReadFile("/etc/hostid")
if err != nil {
hostid = []byte("12345678-abcd-ef98-7654-321012345678")
return err
} else {
hostid = []byte(strings.Replace(string(hostid), "\n", "", -1))
}