X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Frootcheck%2Fcheck_rc_if.c;h=1d4dd62fadc9afe0ecb87884bafef2fb056fd17c;hp=096aa4eed60e37e50f529036b426658db70f8a11;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hpb=301048b51990573e58a30dc4a5bb4ec285cad554 diff --git a/src/rootcheck/check_rc_if.c b/src/rootcheck/check_rc_if.c index 096aa4e..1d4dd62 100755 --- a/src/rootcheck/check_rc_if.c +++ b/src/rootcheck/check_rc_if.c @@ -1,4 +1,5 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/rootcheck/check_rc_if.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. @@ -13,7 +14,7 @@ #include #include -#include +#include #include #include @@ -49,9 +50,9 @@ int run_ifconfig(char *ifconfig) if(system(nt) == 0) return(1); - return(0); + return(0); } - + /* check_rc_if: v0.1 * Check all interfaces for promiscuous mode @@ -60,7 +61,7 @@ void check_rc_if() { int _fd, _errors = 0, _total = 0; struct ifreq tmp_str[16]; - + struct ifconf _if; struct ifreq *_ir; struct ifreq *_ifend; @@ -73,34 +74,34 @@ void check_rc_if() return; } - + memset(tmp_str, 0, sizeof(struct ifreq)*16); _if.ifc_len = sizeof(tmp_str); _if.ifc_buf = (caddr_t)(tmp_str); - + if (ioctl(_fd, SIOCGIFCONF, &_if) < 0) { close(_fd); merror("%s: Error checking interfaces (ioctl)", ARGV0); return; } - + _ifend = (struct ifreq*) ((char*)tmp_str + _if.ifc_len); _ir = tmp_str; /* Looping on all interfaces */ - for (; _ir < _ifend; _ir++) + for (; _ir < _ifend; _ir++) { strncpy(_ifr.ifr_name, _ir->ifr_name, sizeof(_ifr.ifr_name)); /* Getting information from each interface */ - if (ioctl(_fd, SIOCGIFFLAGS, (char*)&_ifr) == -1) + if (ioctl(_fd, SIOCGIFFLAGS, (char*)&_ifr) == -1) { continue; } _total++; - + if ((_ifr.ifr_flags & IFF_PROMISC) ) { @@ -120,7 +121,7 @@ void check_rc_if() } _errors++; } - } + } close(_fd); if(_errors == 0) @@ -130,7 +131,7 @@ void check_rc_if() " Analyzed %d interfaces.", _total); notify_rk(ALERT_OK, op_msg); } - + return; }