IsUIDMapped returns true if the given uid is mapped in SubUIDFile and otherwise it returns false
(uid uint32)
| 390 | // IsUIDMapped returns true if the given uid is mapped in SubUIDFile |
| 391 | // and otherwise it returns false |
| 392 | func IsUIDMapped(uid uint32) bool { |
| 393 | config, err := GetConfig(SubUIDFile, false, getPwNam) |
| 394 | if err != nil { |
| 395 | return false |
| 396 | } |
| 397 | defer config.Close() |
| 398 | |
| 399 | userinfo, err := getPwUID(uid) |
| 400 | if err != nil { |
| 401 | sylog.Fatalf("could not retrieve user with UID %d: %s", uid, err) |
| 402 | } |
| 403 | e, err := config.GetUserEntry(userinfo.Name) |
| 404 | if err != nil && !errors.Is(err, errRangeTooLow) { |
| 405 | return false |
| 406 | } |
| 407 | if e != nil && e.disabled { |
| 408 | return false |
| 409 | } |
| 410 | return true |
| 411 | } |
no test coverage detected