netbirdio/netbird · error

get current user: %v

Error message

get current user: %v

What it means

`netbird logout --profile <name>` failed to resolve the OS user running the CLI via os/user user.Current(). The username is sent with the LogoutRequest so the daemon can scope the deregistration to that user's profiles. In CGO-disabled builds (the released static binaries) Go falls back to parsing /etc/passwd (or getent), so a UID with no passwd entry fails here.

Source

Thrown at client/cmd/logout.go:42

		ctx, cancel := context.WithTimeout(cmd.Context(), time.Second*15)
		defer cancel()

		conn, err := DialClientGRPCServer(ctx, daemonAddr)
		if err != nil {
			return fmt.Errorf("connect to daemon: %v", err)
		}
		defer conn.Close()

		daemonClient := proto.NewDaemonServiceClient(conn)

		req := &proto.LogoutRequest{}

		if profileName != "" {
			req.ProfileName = &profileName

			currUser, err := user.Current()
			if err != nil {
				return fmt.Errorf("get current user: %v", err)
			}
			username := currUser.Username
			req.Username = &username
		}

		if _, err := daemonClient.Logout(ctx, req); err != nil {
			return daemonCallError("deregister", err)
		}

		cmd.Println("Deregistered successfully")
		return nil
	},
}

func init() {
	logoutCmd.PersistentFlags().StringVar(&profileName, profileNameFlag, "", profileNameDesc)
}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Run the CLI as a real user with a passwd entry (e.g. `su - <user>` or fix `docker run -u`)
  2. Add the current UID/GID to /etc/passwd and /etc/group in the container/host (useradd/nss-wrapper)
  3. Verify with `id` and `getent passwd $(id -u)` that the lookup succeeds, then retry
  4. If in a container, ensure /etc/passwd is mounted/readable and not shadowed

Example fix

# before (fails when UID has no passwd entry)
docker run --rm -u 12345 netbirdio/netbird logout --profile work
# after (UID resolvable)
docker run --rm -u "$(id -u):$(id -g)" -v /etc/passwd:/etc/passwd:ro netbirdio/netbird logout --profile work
Defensive patterns

Strategy: validation

Validate before calling

currUser, err := user.Current()
if err != nil {
    if runtime.GOOS == "linux" {
        log.Printf("UID %d has no passwd entry; fix /etc/passwd or run as a real user", os.Getuid())
    }
    return err
}

Type guard

func userResolvable() bool {
    _, err := user.Current()
    return err == nil
}

Prevention

When it happens

Trigger: Running the CLI as a UID that has no entry in /etc/passwd (container arbitrary-UID, systemd DynamicUser); /etc/passwd unreadable; NSS lookup failure in CGO builds; broken user database in a minimal container image.

Common situations: docker run -u 1000123 images without passwd entries; CI runners with synthetic UIDs; hardened/minimal images (distroless without passwd); running under a service account created after the image was built.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/b747bba05ec692a6. Report an issue: GitHub.