X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Frootcheck%2Fcheck_rc_if.c;h=1d4dd62fadc9afe0ecb87884bafef2fb056fd17c;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hp=34158612aaef6695bda5df74f0717e703c7b0958;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/rootcheck/check_rc_if.c b/src/rootcheck/check_rc_if.c index 3415861..1d4dd62 100755 --- a/src/rootcheck/check_rc_if.c +++ b/src/rootcheck/check_rc_if.c @@ -1,11 +1,12 @@ -/* @(#) $Id: check_rc_if.c,v 1.10 2009/06/24 18:53:07 dcid Exp $ */ +/* @(#) $Id: ./src/rootcheck/check_rc_if.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -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; }