diff options
author | Rob Landley <rob@landley.net> | 2014-08-31 11:58:39 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-08-31 11:58:39 -0500 |
commit | 5c87c1426b5c99dd1f2a3ac7493996c342efef4e (patch) | |
tree | ea3f7d88780d714c0a0a2db13eab2a5f0e47913f | |
parent | 96146200ea3b7b67b7e4a6b91f3419013d4cfaab (diff) | |
download | toybox-5c87c1426b5c99dd1f2a3ac7493996c342efef4e.tar.gz |
Give a hint when setuid logic fails.
Toybox expects to be setuid root; setuid some other user confuses the attempt to drop privileges, and we err on the side of avoiding shenanigans.
-rw-r--r-- | main.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -96,8 +96,10 @@ void toy_init(struct toy_list *which, char *argv[]) uid_t uid = getuid(), euid = geteuid(); if (!(which->flags & TOYFLAG_STAYROOT)) { - if (uid != euid) - if (!setuid(euid=uid)) perror_exit("setuid"); // drop root + if (uid != euid) { + if (!setuid(uid)) perror_exit("setuid %d->%d", euid, uid); // drop root + else euid = uid; + } } else if (CFG_TOYBOX_DEBUG && uid && which != toy_list) error_msg("Not installed suid root"); |