github.com/meulengracht/snapd@v0.0.0-20210719210640-8bde69bcc84e/osutil/group_no_cgo.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  // +build !cgo
     3  
     4  package osutil
     5  
     6  // The builtin os/user functions only look at /etc/passwd and
     7  // /etc/group when building without cgo.
     8  //
     9  // So if something extra is configured via nsswitch.conf, like
    10  // extrausers those are not searched with the standard user.Lookup()
    11  // which is used in find{Uid,Gid}NoGetenvFallback.
    12  //
    13  // To fix this behavior we use find{Uid,Gid}WithGetentFallback() that
    14  // perform a 'getent <database> <name>' automatically if no local user
    15  // is found and getent will use the libc nss functions to search all
    16  // configured data sources.
    17  
    18  var (
    19  	findUid = findUidWithGetentFallback
    20  	findGid = findGidWithGetentFallback
    21  )