AdguardTeam/AdGuardHome · error

parsing gid: %w

Error message

parsing gid: %w

What it means

After successfully looking up a group, its Gid string couldn't be parsed as an integer with strconv.Atoi. This indicates the group database returned a non-numeric gid — effectively malformed system data, since gids are numeric by POSIX definition.

Source

Thrown at internal/aghos/user_unix.go:20

package aghos

import (
	"fmt"
	"os/user"
	"strconv"
	"syscall"
)

func setGroup(groupName string) (err error) {
	g, err := user.LookupGroup(groupName)
	if err != nil {
		return fmt.Errorf("looking up group: %w", err)
	}

	gid, err := strconv.Atoi(g.Gid)
	if err != nil {
		return fmt.Errorf("parsing gid: %w", err)
	}

	err = syscall.Setgid(gid)
	if err != nil {
		return fmt.Errorf("setting gid: %w", err)
	}

	return nil
}

func setUser(userName string) (err error) {
	u, err := user.Lookup(userName)
	if err != nil {
		return fmt.Errorf("looking up user: %w", err)
	}

	uid, err := strconv.Atoi(u.Uid)
	if err != nil {

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Inspect the group entry: getent group <name> and check the third field is a plain integer
  2. Repair /etc/group syntax or fix the LDAP gidNumber attribute
  3. As a defensive measure in code, prefer strconv.ParseUint with a clearer error and validation before Setgid
Defensive patterns

Strategy: validation

Validate before calling

g, err := user.LookupGroup(name)
if err == nil {
    if _, err := strconv.Atoi(g.Gid); err != nil { /* malformed group DB; repair host */ }
}

Prevention

When it happens

Trigger: user.LookupGroup returns a Group whose Gid field contains garbage (non-numeric) — corrupted /etc/group, a broken NSS plugin returning empty or malformed fields, or an unusual libc/getent setup.

Common situations: Hand-edited /etc/group with syntax errors; exotic authentication backends (LDAP with malformed gidNumber); rarely hit in practice because most resolvers validate gids.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/eef4f4ab6fd3e95e. Report an issue: GitHub.