- /* Run diff. */
- date_of_change = File_DateofChange(old_location);
- snprintf(diff_cmd, 2048, "diff \"%s\" \"%s\" > \"%s/local/%s/diff.%d\" "
- "2>/dev/null",
- tmp_location, old_location,
- DIFF_DIR_PATH, filename +1, date_of_change);
- if(system(diff_cmd) != 256)
- {
- merror("%s: ERROR: Unable to run diff for %s",
- ARGV0, filename);
- return(NULL);
+ new_date_of_change = File_DateofChange(old_location);
+
+ /* Create file names */
+ snprintf(
+ old_tmp,
+ OS_MAXSTR,
+ "%s/%s/syscheck-changes-%s-%d",
+ DEFAULTDIR,
+ TMP_DIR,
+ md5sum_old,
+ (int)old_date_of_change
+ );
+
+ snprintf(
+ new_tmp,
+ OS_MAXSTR,
+ "%s/%s/syscheck-changes-%s-%d",
+ DEFAULTDIR,
+ TMP_DIR,
+ md5sum_new,
+ (int)new_date_of_change
+ );
+
+ snprintf(
+ diff_tmp,
+ OS_MAXSTR,
+ "%s/%s/syscheck-changes-%s-%d-%s-%d",
+ DEFAULTDIR,
+ TMP_DIR,
+ md5sum_old,
+ (int)old_date_of_change,
+ md5sum_new,
+ (int)new_date_of_change
+ );
+ /* Create diff location */
+ snprintf(
+ diff_location,
+ OS_MAXSTR,
+ "%s/local/%s/diff.%d",
+ DIFF_DIR_PATH,
+ filename + 1,
+ (int)new_date_of_change
+ );
+
+ /* Create symlinks */
+ if (symlink(old_location, old_tmp) == -1) {
+ merror(LINK_ERROR, ARGV0, old_location, old_tmp, errno, strerror(errno));
+ goto cleanup;