* Use chroot () in a secure way - chdir+chroot * Added CHRDIR to chdir after chrooting * Fix support to 'run any command' - sup - small tool for privilege escalation
 (HTM) git clone git://bitreich.org/sup git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sup
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit a9bc8aa095aabbb77bc77d990cc410c65cae19ba
 (DIR) parent 989bc1c744d8fe03a58692410a6d68ad00a872c8
 (HTM) 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:
         M config.def.h                        |       3 ++-
         M sup.c                               |       8 ++++++--
       
       2 files changed, 8 insertions(+), 3 deletions(-)
       ---
 (DIR) 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
        
 (DIR) 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));
                        }
                }