3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
16 #include "os_crypto/md5/md5_op.h"
17 #include "os_crypto/sha1/sha1_op.h"
22 * Sends integrity checking information about a file to the
25 int intcheck_file(char *file_name, char *dir)
38 /* Stating the file */
40 if(stat(file_name, &statbuf) < 0)
42 if(lstat(file_name, &statbuf) < 0)
45 snprintf(newsum, 911,"%c:%s:-1 %s%s", SYSCHECK_MQ, SYSCHECK,
53 /* Generating new checksum */
55 if(S_ISREG(statbuf.st_mode))
57 if(S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
60 /* generating md5 of the file */
61 if(OS_SHA1_File(file_name, sf_sum) < 0)
63 strncpy(sf_sum, "xxx", 4);
66 /* generating md5 of the file */
67 if(OS_MD5_File(file_name, mf_sum) < 0)
69 strncpy(mf_sum, "xxx", 4);
74 snprintf(newsum,911,"%c:%s:%d:%d:%d:%d:%s:%s %s%s",
75 SYSCHECK_MQ, SYSCHECK,
81 sf_sum, dir, file_name);