Added SEC prefix for wwlog levels

This SEC-levels are meant for internal documentation of security
relevant messages so that this code sections are marked.
This commit is contained in:
Christian Goll
2022-04-07 11:01:01 +02:00
committed by Christian Goll
parent 95d1b23921
commit 0ef96c575d
2 changed files with 38 additions and 13 deletions

View File

@@ -98,7 +98,7 @@ func BuildHostOverlay() error {
return errors.Wrap(err, "could not build host overlay ")
}
if !(stats.Mode() == os.FileMode(0750|os.ModeDir) || stats.Mode() == os.FileMode(0700|os.ModeDir)) {
wwlog.Printf(wwlog.WARN, "Permissions of host overlay dir %s are %s (750 is considered as secure)\n", hostdir, stats.Mode())
wwlog.Printf(wwlog.SECWARN, "Permissions of host overlay dir %s are %s (750 is considered as secure)\n", hostdir, stats.Mode())
}
return BuildOverlayIndir(host, []string{"host"}, "/")
}

View File

@@ -6,38 +6,63 @@ import (
)
const (
CRITICAL = 0
ERROR = 1
WARN = 2
INFO = 3
VERBOSE = 4
DEBUG = 5
CRITICAL = 0
SECCRITICAL = 1
ERROR = 2
SECERROR = 3
WARN = 4
SECWARN = 5
INFO = 6
SECINFO = 7
VERBOSE = 8
SECVERBOSE = 9
DEBUG = 10
SECDEBUG = 11
)
var (
logLevel = INFO
)
/*
Set the central log level. Uneven values are security related
lof entries.
*/
func SetLevel(level int) {
logLevel = level
Printf(DEBUG, "Set log level to: %d\n", logLevel)
}
/*
generate the prefix for log level
*/
func prefixGen(level int) string {
switch level {
case DEBUG:
return "[DEBUG] : "
return "[DEBUG] : "
case SECDEBUG:
return "[SECDEBUG] : "
case VERBOSE:
return "[VERBOSE] : "
return "[VERBOSE] : "
case SECVERBOSE:
return "[SECVERBOSE] : "
case INFO:
return "[INFO] : "
return "[INFO] : "
case SECINFO:
return "[SECINFO] : "
case WARN:
return "[WARNING] : "
return "[WARNING] : "
case SECWARN:
return "[SECWARNING] : "
case ERROR:
return "[ERROR] : "
return "[ERROR] : "
case SECERROR:
return "[SECERROR] : "
case CRITICAL:
return "[CRITICAL]: "
return "[CRITICAL] : "
case SECCRITICAL:
return "[SECCRITICAL]: "
}
return "[UNDEF] : "
}