github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/libcontainer/user/lookup_deprecated.go (about) 1 package user 2 3 import ( 4 "io" 5 6 "github.com/moby/sys/user" 7 ) 8 9 // LookupUser looks up a user by their username in /etc/passwd. If the user 10 // cannot be found (or there is no /etc/passwd file on the filesystem), then 11 // LookupUser returns an error. 12 func LookupUser(username string) (user.User, error) { 13 return user.LookupUser(username) 14 } 15 16 // LookupUid looks up a user by their user id in /etc/passwd. If the user cannot 17 // be found (or there is no /etc/passwd file on the filesystem), then LookupId 18 // returns an error. 19 func LookupUid(uid int) (user.User, error) { //nolint:revive // ignore var-naming: func LookupUid should be LookupUID 20 return user.LookupUid(uid) 21 } 22 23 // LookupGroup looks up a group by its name in /etc/group. If the group cannot 24 // be found (or there is no /etc/group file on the filesystem), then LookupGroup 25 // returns an error. 26 func LookupGroup(groupname string) (user.Group, error) { 27 return user.LookupGroup(groupname) 28 } 29 30 // LookupGid looks up a group by its group id in /etc/group. If the group cannot 31 // be found (or there is no /etc/group file on the filesystem), then LookupGid 32 // returns an error. 33 func LookupGid(gid int) (user.Group, error) { 34 return user.LookupGid(gid) 35 } 36 37 func GetPasswdPath() (string, error) { 38 return user.GetPasswdPath() 39 } 40 41 func GetPasswd() (io.ReadCloser, error) { 42 return user.GetPasswd() 43 } 44 45 func GetGroupPath() (string, error) { 46 return user.GetGroupPath() 47 } 48 49 func GetGroup() (io.ReadCloser, error) { 50 return user.GetGroup() 51 } 52 53 // CurrentUser looks up the current user by their user id in /etc/passwd. If the 54 // user cannot be found (or there is no /etc/passwd file on the filesystem), 55 // then CurrentUser returns an error. 56 func CurrentUser() (user.User, error) { 57 return user.CurrentUser() 58 } 59 60 // CurrentGroup looks up the current user's group by their primary group id's 61 // entry in /etc/passwd. If the group cannot be found (or there is no 62 // /etc/group file on the filesystem), then CurrentGroup returns an error. 63 func CurrentGroup() (user.Group, error) { 64 return user.CurrentGroup() 65 } 66 67 func CurrentUserSubUIDs() ([]user.SubID, error) { 68 return user.CurrentUserSubUIDs() 69 } 70 71 func CurrentUserSubGIDs() ([]user.SubID, error) { 72 return user.CurrentUserSubGIDs() 73 } 74 75 func CurrentProcessUIDMap() ([]user.IDMap, error) { 76 return user.CurrentProcessUIDMap() 77 } 78 79 func CurrentProcessGIDMap() ([]user.IDMap, error) { 80 return user.CurrentProcessGIDMap() 81 }