Mercurial > hg > toybox
comparison lib/xwrap.c @ 1400:31cb9ba1815c draft
Improve gid/uid error messages.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 21 Jul 2014 19:57:36 -0500 |
parents | 9fd2bcedbeb5 |
children | 411cf82cdf77 |
comparison
equal
deleted
inserted
replaced
1399:a0c328bc2c14 | 1400:31cb9ba1815c |
---|---|
448 } | 448 } |
449 | 449 |
450 struct group *xgetgrgid(gid_t gid) | 450 struct group *xgetgrgid(gid_t gid) |
451 { | 451 { |
452 struct group *group = getgrgid(gid); | 452 struct group *group = getgrgid(gid); |
453 if (!group) error_exit("bad gid %ld", (long)gid); | 453 |
454 if (!group) perror_exit("gid %ld", (long)gid); | |
454 return group; | 455 return group; |
455 } | 456 } |
456 | 457 |
457 struct passwd *xgetpwnam(char *name) | 458 struct passwd *xgetpwnam(char *name) |
458 { | 459 { |
459 struct passwd *up = getpwnam(name); | 460 struct passwd *up = getpwnam(name); |
460 if (!up) error_exit("bad user '%s'", name); | 461 |
462 if (!up) perror_exit("user '%s'", name); | |
461 return up; | 463 return up; |
462 } | 464 } |
463 | 465 |
464 // setuid() can fail (for example, too many processes belonging to that user), | 466 // setuid() can fail (for example, too many processes belonging to that user), |
465 // which opens a security hole if the process continues as the original user. | 467 // which opens a security hole if the process continues as the original user. |