From 804049aa11e75d1361daf519234493032a8a26fb Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 21 Feb 2012 18:03:01 +0100 Subject: [PATCH] xio: removed misc.{c,h}, placed function into xio.c --- src/ashunt.c | 1 - src/ashunt/CMakeLists.txt | 1 - src/flowtop/CMakeLists.txt | 2 +- src/ifpps.c | 4 ++-- src/ifpps/CMakeLists.txt | 2 +- src/misc.c | 19 ------------------- src/misc.h | 13 ------------- src/netsniff-ng.c | 1 - src/netsniff-ng/CMakeLists.txt | 1 - src/trafgen.c | 2 +- src/trafgen/CMakeLists.txt | 1 - src/xio.c | 6 ++++++ src/xio.h | 1 + 13 files changed, 12 insertions(+), 42 deletions(-) delete mode 100644 src/misc.c delete mode 100644 src/misc.h diff --git a/src/ashunt.c b/src/ashunt.c index 29947f2c..974b500d 100644 --- a/src/ashunt.c +++ b/src/ashunt.c @@ -226,7 +226,6 @@ Please report bugs to #include #include -#include "misc.h" #include "bpf.h" #include "die.h" #include "tprintf.h" diff --git a/src/ashunt/CMakeLists.txt b/src/ashunt/CMakeLists.txt index d82707f4..86c47e97 100644 --- a/src/ashunt/CMakeLists.txt +++ b/src/ashunt/CMakeLists.txt @@ -9,7 +9,6 @@ IF (LIBGEOIP_FOUND AND CMAKE_HAVE_PTHREAD_CREATE) ADD_EXECUTABLE(${PROJECT_NAME} ../xmalloc.c ../strlcpy.c ../xio.c - ../misc.c ../netdev.c ../aslookup.c ../bpf.c diff --git a/src/flowtop/CMakeLists.txt b/src/flowtop/CMakeLists.txt index 032bd8e5..96515614 100644 --- a/src/flowtop/CMakeLists.txt +++ b/src/flowtop/CMakeLists.txt @@ -12,7 +12,7 @@ IF(CURSES_FOUND AND CMAKE_HAVE_PTHREAD_CREATE AND LIBGEOIP_FOUND AND LIBNETFILTE ADD_EXECUTABLE(${PROJECT_NAME} ../xmalloc.c ../strlcpy.c ../parser.c - ../misc.c + ../xio.c ../hash.c ../dissector_eth.c ../dissector.c diff --git a/src/ifpps.c b/src/ifpps.c index 3579ef07..3a9d03a1 100644 --- a/src/ifpps.c +++ b/src/ifpps.c @@ -123,7 +123,7 @@ Please report bugs to #include "die.h" #include "xmalloc.h" #include "psched.h" -#include "misc.h" +#include "xio.h" #include "timespec.h" #include "tty.h" #include "netdev.h" @@ -179,7 +179,7 @@ struct ifstat { static int mode = 0; static int loop = 0; -static sig_atomic_t sigint = 0; +sig_atomic_t sigint = 0; static const char *short_options = "d:t:vhcCHlp"; diff --git a/src/ifpps/CMakeLists.txt b/src/ifpps/CMakeLists.txt index d29d87ca..9ad92def 100644 --- a/src/ifpps/CMakeLists.txt +++ b/src/ifpps/CMakeLists.txt @@ -7,7 +7,7 @@ FIND_PACKAGE(Curses) IF(CURSES_FOUND) ADD_EXECUTABLE(${PROJECT_NAME} ../xmalloc.c ../strlcpy.c - ../misc.c + ../xio.c ../netdev.c ../ifpps.c) diff --git a/src/misc.c b/src/misc.c deleted file mode 100644 index 5e74b475..00000000 --- a/src/misc.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * netsniff-ng - the packet sniffing beast - * By Daniel Borkmann - * Copyright 2011 Daniel Borkmann. - * Subject to the GPL, version 2. - */ - -#include -#include - -#include "die.h" -#include "misc.h" - -void check_for_root_maybe_die(void) -{ - if (geteuid() != 0 || geteuid() != getuid()) - panic("Uhhuh, not root?!\n"); -} - diff --git a/src/misc.h b/src/misc.h deleted file mode 100644 index 46cbbdc5..00000000 --- a/src/misc.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * netsniff-ng - the packet sniffing beast - * By Daniel Borkmann - * Copyright 2011 Daniel Borkmann. - * Subject to the GPL, version 2. - */ - -#ifndef MISC_H -#define MISC_H - -extern void check_for_root_maybe_die(void); - -#endif /* MISC_H */ diff --git a/src/netsniff-ng.c b/src/netsniff-ng.c index 7b3feb23..1eb36f73 100644 --- a/src/netsniff-ng.c +++ b/src/netsniff-ng.c @@ -53,7 +53,6 @@ #include "dissector.h" #include "xmalloc.h" #include "psched.h" -#include "misc.h" #include "mtrand.h" #define CPU_UNKNOWN -1 diff --git a/src/netsniff-ng/CMakeLists.txt b/src/netsniff-ng/CMakeLists.txt index 4af0039e..7c23312c 100644 --- a/src/netsniff-ng/CMakeLists.txt +++ b/src/netsniff-ng/CMakeLists.txt @@ -10,7 +10,6 @@ IF (CMAKE_HAVE_PTHREAD_CREATE) ../dissector_eth.c ../xmalloc.c ../strlcpy.c - ../misc.c ../bpf.c ../parser.c ../psched.c diff --git a/src/trafgen.c b/src/trafgen.c index e28e917f..05776359 100644 --- a/src/trafgen.c +++ b/src/trafgen.c @@ -173,7 +173,7 @@ Please report bugs to #include "die.h" #include "netdev.h" #include "psched.h" -#include "misc.h" +#include "xio.h" #include "tty.h" #include "timespec.h" #include "mtrand.h" diff --git a/src/trafgen/CMakeLists.txt b/src/trafgen/CMakeLists.txt index 11c4e623..2ff55d7d 100644 --- a/src/trafgen/CMakeLists.txt +++ b/src/trafgen/CMakeLists.txt @@ -5,7 +5,6 @@ SET(BUILD_STRING "generic") ADD_EXECUTABLE(${PROJECT_NAME} ../xmalloc.c ../strlcpy.c ../psched.c - ../misc.c ../parser.c ../mtrand.c ../opt_memcpy.c diff --git a/src/xio.c b/src/xio.c index 27cbb691..54fff4a1 100644 --- a/src/xio.c +++ b/src/xio.c @@ -126,3 +126,9 @@ ssize_t write_exact(int fd, void *buf, size_t len, int mayexit) } return num; } + +void check_for_root_maybe_die(void) +{ + if (geteuid() != 0 || geteuid() != getuid()) + panic("Uhhuh, not root?!\n"); +} diff --git a/src/xio.h b/src/xio.h index e1e39141..f4ca7e9f 100644 --- a/src/xio.h +++ b/src/xio.h @@ -15,5 +15,6 @@ extern ssize_t read_or_die(int fd, void *buf, size_t count); extern ssize_t write_or_die(int fd, const void *buf, size_t count); extern ssize_t read_exact(int fd, void *buf, size_t len, int mayexit); extern ssize_t write_exact(int fd, void *buf, size_t len, int mayexit); +extern void check_for_root_maybe_die(void); #endif /* XIO_H */ -- 2.11.4.GIT