diff options
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; |