From afba5b8efdf1bac2c02ca787840a2be053c800f7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 23 Dec 2013 06:49:38 -0600 Subject: Fix some issues raised (albeit indirectly) by Isaac Dunham. POLL_IN defined as a constant by some libc. Factor out login.c's change_identity() to xwrap.c as xsetuser(). Replace xsetuid() with xsetuser() Put a space between argument globals and non-argument globals. TT starts zeroed, don't need to re-zero entries in it. STDIN_FILENO has been 0 since 1969, even DOS copied that. Just say 0. Added an xchroot() using xchdir() to lib/xwrap.c. Remove endgrent() call until somebody can explain why it was there. --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 7355f0a2..8fe8e058 100644 --- a/main.c +++ b/main.c @@ -92,7 +92,8 @@ void toy_init(struct toy_list *which, char *argv[]) uid_t uid = getuid(), euid = geteuid(); if (!(which->flags & TOYFLAG_STAYROOT)) { - if (uid != euid) xsetuid(euid=uid); // drop root + if (uid != euid) + if (!setuid(euid=uid)) perror_exit("setuid"); // drop root } else if (CFG_TOYBOX_DEBUG && uid && which != toy_list) error_msg("Not installed suid root"); -- cgit v1.2.3