1 /* @(#) $Id: ./src/client-agent/intcheck_op.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
17 #include "os_crypto/md5/md5_op.h"
18 #include "os_crypto/sha1/sha1_op.h"
23 * Sends integrity checking information about a file to the
26 int intcheck_file(char *file_name, char *dir)
39 /* Stating the file */
41 if(stat(file_name, &statbuf) < 0)
43 if(lstat(file_name, &statbuf) < 0)
46 snprintf(newsum, 911,"%c:%s:-1 %s%s", SYSCHECK_MQ, SYSCHECK,
54 /* Generating new checksum */
56 if(S_ISREG(statbuf.st_mode))
58 if(S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
61 /* generating md5 of the file */
62 if(OS_SHA1_File(file_name, sf_sum) < 0)
64 strncpy(sf_sum, "xxx", 4);
67 /* generating md5 of the file */
68 if(OS_MD5_File(file_name, mf_sum) < 0)
70 strncpy(mf_sum, "xxx", 4);
75 snprintf(newsum,911,"%c:%s:%d:%d:%d:%d:%s:%s %s%s",
76 SYSCHECK_MQ, SYSCHECK,
82 sf_sum, dir, file_name);