diff options
author | Rob Landley <rob@landley.net> | 2010-01-05 12:17:05 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2010-01-05 12:17:05 -0600 |
commit | e0377fb294821a68112d4da09f836ac42e3d5956 (patch) | |
tree | 489d2a2b21393f7283870c2f21ed82b5818f1d82 /main.c | |
parent | 1e01cd1f48bff3fdd12f45bf1c3adfab821ee287 (diff) | |
download | toybox-e0377fb294821a68112d4da09f836ac42e3d5956.tar.gz |
Add TOYBOX_SUID.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -64,6 +64,21 @@ static const int NEED_OPTIONS = void toy_init(struct toy_list *which, char *argv[]) { + // Drop permissions for non-suid commands. + + if (CFG_TOYBOX_SUID) { + uid_t uid = getuid(), euid = geteuid(); + + if (!(which->flags & TOYFLAG_STAYROOT)) { + if (uid != euid) xsetuid(euid=uid); + } else if (CFG_TOYBOX_DEBUG && uid) + error_exit("Not installed suid root"); + + if ((which->flags & TOYFLAG_NEEDROOT) && euid) + error_exit("Not root"); + + } + // Free old toys contents here? toys.which = which; |