From e0377fb294821a68112d4da09f836ac42e3d5956 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 5 Jan 2010 12:17:05 -0600 Subject: Add TOYBOX_SUID. --- lib/lib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index 48689d3d..08c991dd 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -369,6 +369,16 @@ void xmkpath(char *path, int mode) 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. -- cgit v1.2.3