MCPcopy Create free account
hub / github.com/coder/envbuilder / getUser

Function getUser

envbuilder.go:1375–1400  ·  view source on GitHub ↗
(username string)

Source from the content-addressed store, hash-verified

1373}
1374
1375func getUser(username string) (userInfo, error) {
1376 user, err := findUser(username)
1377 if err != nil {
1378 return userInfo{}, fmt.Errorf("find user: %w", err)
1379 }
1380 uid, err := strconv.Atoi(user.Uid)
1381 if err != nil {
1382 return userInfo{}, fmt.Errorf("parse uid: %w", err)
1383 }
1384 gid, err := strconv.Atoi(user.Gid)
1385 if err != nil {
1386 return userInfo{}, fmt.Errorf("parse gid: %w", err)
1387 }
1388 if user.Username == "" && uid == 0 {
1389 // This is nice for the visual display in log messages,
1390 // but has no actual functionality since the credential
1391 // in the syscall is what matters.
1392 user.Username = "root"
1393 user.HomeDir = "/root"
1394 }
1395 return userInfo{
1396 uid: uid,
1397 gid: gid,
1398 user: user,
1399 }, nil
1400}
1401
1402// findUser looks up a user by name or ID.
1403func findUser(nameOrID string) (*user.User, error) {

Callers 1

runFunction · 0.85

Calls 1

findUserFunction · 0.85

Tested by

no test coverage detected