URI: 
       t* Add contextual error information in die() - sup - small tool for privilege escalation
  HTML git clone https://git.parazyd.org/sup
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 8078fe60673809c9ce32dd85613e9f96d7278742
   DIR parent 0492cb034b11bc7ae89a4be974cf80678c74bfe8
  HTML Author: pancake@dazo <unknown>
       Date:   Mon,  4 Jan 2010 00:06:28 +0100
       
       * Add contextual error information in die()
       Diffstat:
         M sup.c                               |      24 ++++++++++++------------
       
       1 file changed, 12 insertions(+), 12 deletions(-)
       ---
   DIR diff --git a/sup.c b/sup.c
       t@@ -18,8 +18,8 @@ struct rule_t {
        
        #include "config.h"
        
       -static int die(int ret, const char *str) {
       -        fprintf (stderr, "%s\n", str);
       +static int die(int ret, const char *org, const char *str) {
       +        fprintf (stderr, "%s%s%s\n", org, org?": ":"", str);
                return ret;
        }
        
       t@@ -27,10 +27,10 @@ int main(int argc, char **argv) {
                int i, uid, gid, ret;
        
                if (argc < 2 || !strcmp (argv[1], "-h"))
       -                return die (1, HELP);
       +                return die (1, NULL, HELP);
        
                if (!strcmp (argv[1], "-v"))
       -                return die (1, VERSION);
       +                return die (1, NULL, VERSION);
        
                if (!strcmp (argv[1], "-l")) {
                        for (i = 0; rules[i].cmd != NULL; i++)
       t@@ -48,29 +48,29 @@ int main(int argc, char **argv) {
                                struct stat st;
                                lstat (rules[i].path, &st);
                                if (st.st_mode & 0222)
       -                                return die (1, "Cannot run writable binaries.");
       +                                return die (1, "stat", "Cannot run writable binaries.");
        #endif
                                if (uid != SETUID && rules[i].uid != -1 && rules[i].uid != uid)
       -                                return die (1, "User does not match");
       +                                return die (1, "urule", "User does not match");
        
                                if (gid != SETGID && rules[i].gid != -1 && rules[i].gid != gid)
       -                                return die (1, "Group id does not match");
       +                                return die (1, "grule", "Group id does not match");
        
                                if (setuid (SETUID) == -1 || setgid (SETGID) == -1 ||
                                    seteuid (SETUID) == -1 || setegid (SETGID) == -1)
       -                                return die (1, strerror (errno));
       +                                return die (1, "set[e][ug]id", strerror (errno));
        #ifdef CHROOT
                                if (*CHROOT)
                                        if (chdir (CHROOT) == -1 || chroot (".") == -1)
       -                                        return die (1, strerror (errno));
       +                                        return die (1, "chroot", strerror (errno));
                                if (*CHRDIR)
                                        if (chdir (CHRDIR) == -1)
       -                                        return die (1, strerror (errno));
       +                                        return die (1, "chdir", strerror (errno));
        #endif
                                ret = execv (*rules[i].path? rules[i].path:argv[1], argv+1);
       -                        return die (ret, strerror (errno));
       +                        return die (ret, "execv", strerror (errno));
                        }
                }
        
       -        return die (1, "Sorry");
       +        return die (1, NULL, "Sorry");
        }