[libgtop] More debug messages to trace euid/egid changes.



commit 45c8452140e65d3f677db0c99d097e02c8a9a6f3
Author: Benoit Dejean <bdejean gmail com>
Date:   Sun Jul 19 22:37:09 2015 +0200

    More debug messages to trace euid/egid changes.

 src/daemon/server.c         |    7 +++++++
 sysdeps/freebsd/suid_open.c |    4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/daemon/server.c b/src/daemon/server.c
index 44b7f61..eafa25a 100644
--- a/src/daemon/server.c
+++ b/src/daemon/server.c
@@ -25,6 +25,7 @@
 #include <glibtop.h>
 #include <glibtop/union.h>
 #include <glibtop/sysdeps.h>
+#include <glibtop/error.h>
 
 #include <sys/utsname.h>
 
@@ -42,6 +43,8 @@ main(int argc, char *argv[])
        uid = getuid (); euid = geteuid ();
        gid = getgid (); egid = getegid ();
 
+       glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
+
        if (uname (&uts) < 0) _exit (1);
 
 #ifdef _AIX
@@ -74,10 +77,14 @@ main(int argc, char *argv[])
 
        glibtop_init_p (glibtop_global_server, 0, 0);
 
+       glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
+
        if (setreuid (euid, uid)) _exit (1);
 
        if (setregid (egid, gid)) _exit (1);
 
+       glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
+
        /* !!! END OF SUID ROOT PART !!! */
 
        handle_slave_connection (0, 0);
diff --git a/sysdeps/freebsd/suid_open.c b/sysdeps/freebsd/suid_open.c
index c27e492..5545607 100644
--- a/sysdeps/freebsd/suid_open.c
+++ b/sysdeps/freebsd/suid_open.c
@@ -71,12 +71,16 @@ glibtop_open_p (glibtop *server, const char *program_name,
 
        /* Drop priviledges. */
 
+       glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
+
        if (setreuid (server->machine.euid, server->machine.uid))
                _exit (1);
 
        if (setregid (server->machine.egid, server->machine.gid))
                _exit (1);
 
+       glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
+
        /* !!! END OF SUID ROOT PART !!! */
 
        /* Our effective uid is now those of the user invoking the server,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]