fix: PUID and PGID as 32 bit unsigned integers
This commit is contained in:
19
internal/configuration/sources/env/system.go
vendored
19
internal/configuration/sources/env/system.go
vendored
@@ -34,20 +34,23 @@ func (r *Reader) readSystem() (system settings.System, err error) {
|
||||
var ErrSystemIDNotValid = errors.New("system ID is not valid")
|
||||
|
||||
func (r *Reader) readID(key, retroKey string) (
|
||||
id *uint16, err error) {
|
||||
id *uint32, err error) {
|
||||
idEnvKey, idString := r.getEnvWithRetro(key, retroKey)
|
||||
if idString == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
idInt, err := strconv.Atoi(idString)
|
||||
const base = 10
|
||||
const bitSize = 64
|
||||
const max = uint64(^uint32(0))
|
||||
idUint64, err := strconv.ParseUint(idString, base, bitSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("environment variable %s: %w: %s: %s",
|
||||
idEnvKey, ErrSystemIDNotValid, idString, err)
|
||||
} else if idInt < 0 || idInt > 65535 {
|
||||
return nil, fmt.Errorf("environment variable %s: %w: %d: must be between 0 and 65535",
|
||||
idEnvKey, ErrSystemIDNotValid, idInt)
|
||||
return nil, fmt.Errorf("environment variable %s: %w: %s",
|
||||
idEnvKey, ErrSystemIDNotValid, err)
|
||||
} else if idUint64 > max {
|
||||
return nil, fmt.Errorf("environment variable %s: %w: %d: must be between 0 and %d",
|
||||
idEnvKey, ErrSystemIDNotValid, idUint64, max)
|
||||
}
|
||||
|
||||
return uint16Ptr(uint16(idInt)), nil
|
||||
return uint32Ptr(uint32(idUint64)), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user