osbuild2: do not use reflect in pam.limits.conf stage
Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
09cd5b3576
commit
96000173db
1 changed files with 3 additions and 4 deletions
|
|
@ -3,7 +3,6 @@ package osbuild2
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// PamLimitsConfStageOptions represents a single pam_limits module configuration file.
|
||||
|
|
@ -134,13 +133,13 @@ func (l *PamLimitsConfigLine) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
|
||||
var value PamLimitsValue
|
||||
switch valueType := reflect.TypeOf(rawLine.Value); valueType.Kind() {
|
||||
switch valueType := rawLine.Value.(type) {
|
||||
// json.Unmarshal() uses float64 for JSON numbers
|
||||
// https://pkg.go.dev/encoding/json#Unmarshal
|
||||
// However the expected value is only integer.
|
||||
case reflect.Float64:
|
||||
case float64:
|
||||
value = PamLimitsValueInt(rawLine.Value.(float64))
|
||||
case reflect.String:
|
||||
case string:
|
||||
value = PamLimitsValueStr(rawLine.Value.(string))
|
||||
default:
|
||||
return fmt.Errorf("the 'value' item has unsupported type %q", valueType)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue