aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-06-07 03:13:19 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2013-06-07 03:13:19 +0200
commit96c3fcd9789a88d6bc403fff2434e26f3ddca69d (patch)
tree49fc3b5c117805542841415e50adc8650de22e98
parentlibggnet: traceroute sends packets in TCP and ICMP (diff)
downloadglouglou-96c3fcd9789a88d6bc403fff2434e26f3ddca69d.tar.xz
glouglou-96c3fcd9789a88d6bc403fff2434e26f3ddca69d.zip
libggnet: use droppriv() from libglouglou
-rw-r--r--libglouglou/examples/traceroute.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/libglouglou/examples/traceroute.c b/libglouglou/examples/traceroute.c
index 9d76a7d..de2e58f 100644
--- a/libglouglou/examples/traceroute.c
+++ b/libglouglou/examples/traceroute.c
@@ -17,7 +17,7 @@
#include <string.h>
#include <err.h>
-#include <libglouglou.h> /* for get_iface */
+#include <libglouglou.h> /* for get_iface and droppriv */
#include <libggnet_traceroute.h>
static void _droppriv(char *, int, char *);
@@ -48,7 +48,7 @@ main(int argc, char *argv[])
_ev_base = event_base_new();
ggtr = ggnet_traceroute_new(_ev_base, get_iface(argv[1]));
- _droppriv("nobody", 1, NULL); /* bad practise you should use dedicated user */
+ droppriv("nobody", 1, NULL); /* bad practise you should use dedicated user */
ggnet_traceroute_trace(ggtr, &ip, TRACEMODE_ICMP, _cb_traceroute, NULL);
event_base_loopexit(_ev_base, &tv);
@@ -65,34 +65,6 @@ main(int argc, char *argv[])
return 0;
}
-/* from libglouglou utils.c */
-static void
-_droppriv(char *user, int do_chroot, char *chroot_path)
-{
- struct passwd *pw;
-
- pw = getpwnam(user);
- if (!pw)
- err(1, "unknown user %s", user);
- if (do_chroot) {
- if (!chroot_path)
- chroot_path = pw->pw_dir;
- if (chroot(chroot_path) != 0)
- err(1, "unable to chroot");
- }
- if (chdir("/") != 0)
- err(1, "unable to chdir");
- if (setgroups(1, &pw->pw_gid) == -1)
- err(1, "setgroups() failed");
- if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1)
- err(1, "setresgid failed");
- if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1)
- err(1, "setresuid() failed");
- endpwent();
- printf("droppriv done\n");
-}
-
-
static void
_cb_traceroute(struct addr *ip,
struct ggnet_traceroute_req *route, void *data)