Mercurial > hg > toybox
changeset 1452:8f9721561211 draft
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.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 31 Aug 2014 11:58:39 -0500 |
parents | 5f9fbf75ad34 |
children | 3c0ed9acbaa3 |
files | main.c |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Sat Aug 30 17:44:07 2014 -0500 +++ b/main.c Sun Aug 31 11:58:39 2014 -0500 @@ -96,8 +96,10 @@ 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");