sup

simple user privilege escalation
git clone git://git.suckless.org/sup
Log | Files | Refs

commit a9bc8aa095aabbb77bc77d990cc410c65cae19ba
parent 989bc1c744d8fe03a58692410a6d68ad00a872c8
Author: pancake@dazo <unknown>
Date:   Mon, 14 Dec 2009 01:30:40 +0100

* Use chroot () in a secure way
  - chdir+chroot
* Added CHRDIR to chdir after chrooting
* Fix support to 'run any command'
Diffstat:
config.def.h | 3++-
sup.c | 8++++++--
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -4,7 +4,8 @@ #define SETUID 0 #define SETGID 0 -#define CHROOT "/" +#define CHROOT "" +#define CHRDIR "" #define ENFORCE 1 diff --git a/sup.c b/sup.c @@ -60,10 +60,14 @@ int main(int argc, char **argv) { seteuid (SETUID) == -1 || setegid (SETGID) == -1) return die (1, strerror (errno)); #ifdef CHROOT - if (chroot (CHROOT) == -1) + if (*CHROOT) + if (chdir (CHROOT) == -1 || chroot (".") == -1) return die (1, strerror (errno)); + if (*CHRDIR) + if (chdir (CHRDIR) == -1) + return die (1, strerror (errno)); #endif - ret = execv (rules[i].path? rules[i].path:argv[1], argv+1); + ret = execv (*rules[i].path? rules[i].path:argv[1], argv+1); return die (ret, strerror (errno)); } }