From fbe357b1e6bcc92b5353c5e95c493ea34d590b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Sun, 24 Dec 2023 14:04:55 -0300 Subject: [PATCH] fix checkInPingGroup bugs - Must check for the *effective* GID. - Must allow range from 0 to 4294967294 in current kernels. --- ingress/icmp_linux.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ingress/icmp_linux.go b/ingress/icmp_linux.go index 321b5c3f..b327813c 100644 --- a/ingress/icmp_linux.go +++ b/ingress/icmp_linux.go @@ -78,19 +78,19 @@ func checkInPingGroup() error { if err != nil { return err } - groupID := os.Getgid() + groupID := uint64(os.Getegid()) // Example content: 999 59999 found := findGroupIDRegex.FindAll(file, 2) if len(found) == 2 { - groupMin, err := strconv.ParseInt(string(found[0]), 10, 32) + groupMin, err := strconv.ParseUint(string(found[0]), 10, 32) if err != nil { return errors.Wrapf(err, "failed to determine minimum ping group ID") } - groupMax, err := strconv.ParseInt(string(found[1]), 10, 32) + groupMax, err := strconv.ParseUint(string(found[1]), 10, 32) if err != nil { - return errors.Wrapf(err, "failed to determine minimum ping group ID") + return errors.Wrapf(err, "failed to determine maximum ping group ID") } - if groupID < int(groupMin) || groupID > int(groupMax) { + if groupID < groupMin || groupID > groupMax { return fmt.Errorf("Group ID %d is not between ping group %d to %d", groupID, groupMin, groupMax) } return nil