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
15 #include "os_crypto/md5/md5_op.h"
16 #include "os_net/os_net.h"
19 time_t g_saved_time = 0;
23 /* getfiles: Return the name of the files in a directory
25 char *getsharedfiles()
34 if(OS_MD5_File(SHAREDCFG_FILE, md5sum) != 0)
42 /* we control these files, max size is m_size */
43 ret = (char *)calloc(m_size +1, sizeof(char));
46 merror(MEM_ERROR, ARGV0);
51 snprintf(ret, m_size, "%s merged.mg\n", md5sum);
59 /* run_notify: Send periodically notification to server */
62 char tmp_msg[OS_SIZE_1024 +1];
72 /* Check if the server has responded */
73 if((curr_time - available_server) > (3*NOTIFY_TIME))
75 /* If response is not available, set lock and
78 verbose(SERVER_UNAV, ARGV0);
81 /* Send sync message */
84 verbose(SERVER_UP, ARGV0);
90 /* Check if time has elapsed */
91 if((curr_time - g_saved_time) < (NOTIFY_TIME - 120))
95 g_saved_time = curr_time;
97 debug1("%s: DEBUG: Sending agent notification.", ARGV0);
101 * Message is going to be the
102 * uname\n checksum file\n checksum file\n
109 merror(MEM_ERROR,ARGV0);
114 /* get shared files */
115 shared_files = getsharedfiles();
118 shared_files = strdup("\0");
122 merror(MEM_ERROR,ARGV0);
128 /* creating message */
129 if(File_DateofChange(AGENTCONFIGINT) > 0)
132 if(OS_MD5_File(AGENTCONFIGINT, md5sum) != 0)
134 snprintf(tmp_msg, OS_SIZE_1024, "#!-%s\n%s",uname, shared_files);
138 snprintf(tmp_msg, OS_SIZE_1024, "#!-%s / %s\n%s",uname, md5sum, shared_files);
143 snprintf(tmp_msg, OS_SIZE_1024, "#!-%s\n%s",uname, shared_files);
147 /* Sending status message */
148 send_msg(0, tmp_msg);