Mercurial > hg > toybox
comparison lib/xwrap.c @ 1130:6df194c6de88 draft
Add xgetpwnam() to lib/xwrap.c.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 28 Nov 2013 21:06:15 -0600 |
parents | c644f85444d0 |
children | faf7117c4489 |
comparison
equal
deleted
inserted
replaced
1129:c644f85444d0 | 1130:6df194c6de88 |
---|---|
400 } | 400 } |
401 | 401 |
402 struct passwd *xgetpwuid(uid_t uid) | 402 struct passwd *xgetpwuid(uid_t uid) |
403 { | 403 { |
404 struct passwd *pwd = getpwuid(uid); | 404 struct passwd *pwd = getpwuid(uid); |
405 if (!pwd) error_exit(NULL); | 405 if (!pwd) error_exit("bad uid %ld", (long)uid); |
406 return pwd; | 406 return pwd; |
407 } | 407 } |
408 | 408 |
409 struct group *xgetgrgid(gid_t gid) | 409 struct group *xgetgrgid(gid_t gid) |
410 { | 410 { |
411 struct group *group = getgrgid(gid); | 411 struct group *group = getgrgid(gid); |
412 if (!group) error_exit(NULL); | 412 if (!group) error_exit("bad gid %ld", (long)gid); |
413 return group; | 413 return group; |
414 } | |
415 | |
416 struct passwd *xgetpwnam(char *name) | |
417 { | |
418 struct passwd *up = getpwnam(name); | |
419 if (!up) error_exit("bad user '%s'", name); | |
420 return up; | |
414 } | 421 } |
415 | 422 |
416 // This can return null (meaning file not found). It just won't return null | 423 // This can return null (meaning file not found). It just won't return null |
417 // for memory allocation reasons. | 424 // for memory allocation reasons. |
418 char *xreadlink(char *name) | 425 char *xreadlink(char *name) |