From 62b53ed9e64e40d2534f1239c4b314d84e79f15f Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 9 Feb 2016 16:43:35 +0100 Subject: main.c: fix non-root usage when installed suid root When toybox is installed suid root and invoked by a non-root user for commands which do not require root privileges, it drops the root privileges during initialization. However, since commit afba5b8efd the result check of setuid() was inverted such that it aborted on success, making toybox unusuable for non-root users. Signed-off-by: Patrick Ohly --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 6dd4cea6..cf82872d 100644 --- a/main.c +++ b/main.c @@ -107,7 +107,7 @@ void toy_init(struct toy_list *which, char *argv[]) if (!(which->flags & TOYFLAG_STAYROOT)) { if (uid != euid) { - if (!setuid(uid)) perror_exit("setuid %d->%d", euid, uid); // drop root + if (setuid(uid)) perror_exit("setuid %d->%d", euid, uid); // drop root euid = uid; toys.wasroot++; } -- cgit v1.2.3