1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
12 #include "os_crypto/md5/md5_op.h"
13 #include "os_crypto/sha1/sha1_op.h"
16 /* Send integrity checking information about a file to the server */
17 int intcheck_file(const char *file_name, const char *dir)
29 if (stat(file_name, &statbuf) < 0)
31 if (lstat(file_name, &statbuf) < 0)
34 snprintf(newsum, 911, "%c:%s:-1 %s%s", SYSCHECK_MQ, SYSCHECK,
41 /* Generate new checksum */
43 if (S_ISREG(statbuf.st_mode))
45 if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
48 /* Generate SHA-1 of the file */
49 if (OS_SHA1_File(file_name, sf_sum, OS_TEXT) < 0) {
50 strncpy(sf_sum, "xxx", 4);
53 /* Generate MD5 of the file */
54 if (OS_MD5_File(file_name, mf_sum, OS_TEXT) < 0) {
55 strncpy(mf_sum, "xxx", 4);
59 snprintf(newsum, 911, "%c:%s:%d:%d:%d:%d:%s:%s %s%s",
60 SYSCHECK_MQ, SYSCHECK,
66 sf_sum, dir, file_name);