blob: 6bdda51a232107fec6b80d7c424b746279348709 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
$NetBSD: patch-aa,v 1.1.1.1 2002/04/04 17:02:30 atatat Exp $
Do *ALL* the root stuff right up front and then completely lose
privileges.
--- main.c.orig Mon Aug 13 20:07:33 2001
+++ main.c Fri Mar 29 23:46:01 2002
@@ -150,6 +150,17 @@
char setflags[1024] = {'\0'};
int c, hdr_size;
+ /* open raw socket */
+ sockraw = open_sockraw();
+ if (sockraw == -1) {
+ printf("[main] can't open raw socket\n");
+ exit(1);
+ }
+ if (getuid() && setuid(getuid()) == -1) {
+ printf("[main] can't drop privs\n");
+ exit(1);
+ }
+
if ( parse_options(argc, argv) == -1 )
{
printf("hping2: missing host argument\n"
@@ -187,13 +199,6 @@
{
printf("using %s, addr: %s, MTU: %d\n",
ifname, ifstraddr, h_if_mtu);
- }
-
- /* open raw socket */
- sockraw = open_sockraw();
- if (sockraw == -1) {
- printf("[main] can't open raw socket\n");
- exit(1);
}
/* set SO_BROADCAST option */
|