X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient-agent%2Fintcheck_op.c;fp=src%2Fclient-agent%2Fintcheck_op.c;h=395af7d7f7990eb578aededae539034ff13f6420;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=a7025c62dd4e0e36899d93cfa884e426bc0e7963;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b;p=ossec-hids.git diff --git a/src/client-agent/intcheck_op.c b/src/client-agent/intcheck_op.c old mode 100755 new mode 100644 index a7025c6..395af7d --- a/src/client-agent/intcheck_op.c +++ b/src/client-agent/intcheck_op.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/client-agent/intcheck_op.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -10,80 +7,65 @@ * Foundation */ - - #include "shared.h" #include "agentd.h" #include "os_crypto/md5/md5_op.h" #include "os_crypto/sha1/sha1_op.h" - -/* intcheck_file - * Sends integrity checking information about a file to the - * server. - */ -int intcheck_file(char *file_name, char *dir) +/* Send integrity checking information about a file to the server */ +int intcheck_file(const char *file_name, const char *dir) { struct stat statbuf; - - os_md5 mf_sum; - os_sha1 sf_sum; - - char newsum[912 +1]; + os_md5 mf_sum = ""; + os_sha1 sf_sum = ""; + char newsum[912 + 1]; newsum[0] = '\0'; newsum[912] = '\0'; - - /* Stating the file */ - #ifdef WIN32 - if(stat(file_name, &statbuf) < 0) - #else - if(lstat(file_name, &statbuf) < 0) - #endif + /* Stat the file */ +#ifdef WIN32 + if (stat(file_name, &statbuf) < 0) +#else + if (lstat(file_name, &statbuf) < 0) +#endif { - snprintf(newsum, 911,"%c:%s:-1 %s%s", SYSCHECK_MQ, SYSCHECK, - dir, file_name); + snprintf(newsum, 911, "%c:%s:-1 %s%s", SYSCHECK_MQ, SYSCHECK, + dir, file_name); send_msg(0, newsum); - return(1); + return (1); } - - /* Generating new checksum */ - #ifdef WIN32 - if(S_ISREG(statbuf.st_mode)) - #else - if(S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) - #endif + /* Generate new checksum */ +#ifdef WIN32 + if (S_ISREG(statbuf.st_mode)) +#else + if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) +#endif { - /* generating md5 of the file */ - if(OS_SHA1_File(file_name, sf_sum) < 0) - { + /* Generate SHA-1 of the file */ + if (OS_SHA1_File(file_name, sf_sum, OS_TEXT) < 0) { strncpy(sf_sum, "xxx", 4); } - /* generating md5 of the file */ - if(OS_MD5_File(file_name, mf_sum) < 0) - { + /* Generate MD5 of the file */ + if (OS_MD5_File(file_name, mf_sum, OS_TEXT) < 0) { strncpy(mf_sum, "xxx", 4); } } - - snprintf(newsum,911,"%c:%s:%d:%d:%d:%d:%s:%s %s%s", - SYSCHECK_MQ, SYSCHECK, - (int)statbuf.st_size, - (int)statbuf.st_mode, - (int)statbuf.st_uid, - (int)statbuf.st_gid, - mf_sum, - sf_sum, dir, file_name); - + snprintf(newsum, 911, "%c:%s:%d:%d:%d:%d:%s:%s %s%s", + SYSCHECK_MQ, SYSCHECK, + (int)statbuf.st_size, + (int)statbuf.st_mode, + (int)statbuf.st_uid, + (int)statbuf.st_gid, + mf_sum, + sf_sum, dir, file_name); send_msg(0, newsum); - return(1); + return (1); } -/* EOF */