Mercurial > hg > toybox
diff lib/lib.c @ 370:c7a26e26ad08
Add TOYBOX_SUID.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 05 Jan 2010 12:17:05 -0600 |
parents | 5715eed39575 |
children | 74526fc22c25 |
line wrap: on
line diff
--- a/lib/lib.c Tue Jan 05 10:48:32 2010 -0600 +++ b/lib/lib.c Tue Jan 05 12:17:05 2010 -0600 @@ -369,6 +369,16 @@ if (!*p) break; } } + +// setuid() can fail (for example, too many processes belonging to that user), +// which opens a security hole if the process continues as the original user. + +void xsetuid(uid_t uid) +{ + if (setuid(uid)) perror_exit("xsetuid"); +} + + // Find all file in a colon-separated path with access type "type" (generally // X_OK or R_OK). Returns a list of absolute paths to each file found, in // order.