X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=src%2Fsyscheckd%2Fcreate_db.c;fp=src%2Fsyscheckd%2Fcreate_db.c;h=4c0b6ba75970dcce9f595b1a9aa9145697ffaf85;hb=789cbc8e52da68eba3517b920ef22e000cf3c9fd;hp=91875cffb947c0b6b490e8defed530de4dd0db3b;hpb=ef70704f0b31b59bb719b884d6a99cb9e3e2044a;p=ossec-hids.git diff --git a/src/syscheckd/create_db.c b/src/syscheckd/create_db.c index 91875cf..4c0b6ba 100755 --- a/src/syscheckd/create_db.c +++ b/src/syscheckd/create_db.c @@ -106,6 +106,13 @@ int read_file(char *file_name, int opts, OSMatch *restriction) verbose("%s: Reading dir: %s\n",ARGV0, file_name); #endif + #ifdef WIN32 + /* Directory links are not supported */ + if (GetFileAttributes(file_name) & FILE_ATTRIBUTE_REPARSE_POINT) { + merror("%s: WARN: Links are not supported: '%s'", ARGV0, file_name); + return(-1); + } + #endif return(read_dir(file_name, opts, restriction)); } @@ -190,10 +197,11 @@ int read_file(char *file_name, int opts, OSMatch *restriction) buf = OSHash_Get(syscheck.fp, file_name); if(!buf) { - char alert_msg[912 +1]; + char alert_msg[916 +1]; /* 912 -> 916 to accommodate a long */ - alert_msg[912] = '\0'; + alert_msg[916] = '\0'; + #ifndef WIN32 if(opts & CHECK_SEECHANGES) { char *alertdump = seechanges_addfile(file_name); @@ -203,16 +211,17 @@ int read_file(char *file_name, int opts, OSMatch *restriction) alertdump = NULL; } } + #endif - snprintf(alert_msg, 912, "%c%c%c%c%c%c%d:%d:%d:%d:%s:%s", + snprintf(alert_msg, 916, "%c%c%c%c%c%c%ld:%d:%d:%d:%s:%s", opts & CHECK_SIZE?'+':'-', opts & CHECK_PERM?'+':'-', opts & CHECK_OWNER?'+':'-', opts & CHECK_GROUP?'+':'-', opts & CHECK_MD5SUM?'+':'-', sha1s, - opts & CHECK_SIZE?(int)statbuf.st_size:0, + opts & CHECK_SIZE?(long)statbuf.st_size:0, opts & CHECK_PERM?(int)statbuf.st_mode:0, opts & CHECK_OWNER?(int)statbuf.st_uid:0, opts & CHECK_GROUP?(int)statbuf.st_gid:0, @@ -226,9 +235,11 @@ int read_file(char *file_name, int opts, OSMatch *restriction) /* Sending the new checksum to the analysis server */ - alert_msg[912] = '\0'; - snprintf(alert_msg, 912, "%d:%d:%d:%d:%s:%s %s", - opts & CHECK_SIZE?(int)statbuf.st_size:0, + alert_msg[916] = '\0'; + + /* changed by chris st_size int to long, 912 to 916*/ + snprintf(alert_msg, 916, "%ld:%d:%d:%d:%s:%s %s", + opts & CHECK_SIZE?(long)statbuf.st_size:0, opts & CHECK_PERM?(int)statbuf.st_mode:0, opts & CHECK_OWNER?(int)statbuf.st_uid:0, opts & CHECK_GROUP?(int)statbuf.st_gid:0, @@ -254,8 +265,11 @@ int read_file(char *file_name, int opts, OSMatch *restriction) if(strcmp(c_sum, buf+6) != 0) { /* Sending the new checksum to the analysis server */ - char *fullalert = NULL; alert_msg[OS_MAXSTR] = '\0'; + #ifdef WIN32 + snprintf(alert_msg, 916, "%s %s", c_sum, file_name); + #else + char *fullalert = NULL; if(buf[5] == 's' || buf[5] == 'n') { fullalert = seechanges_addfile(file_name); @@ -267,13 +281,14 @@ int read_file(char *file_name, int opts, OSMatch *restriction) } else { - snprintf(alert_msg, 912, "%s %s", c_sum, file_name); + snprintf(alert_msg, 916, "%s %s", c_sum, file_name); } } else { - snprintf(alert_msg, 912, "%s %s", c_sum, file_name); + snprintf(alert_msg, 916, "%s %s", c_sum, file_name); } + #endif send_syscheck_msg(alert_msg); } } @@ -316,7 +331,7 @@ int read_dir(char *dir_name, int opts, OSMatch *restriction) struct dirent *entry; f_name[PATH_MAX +1] = '\0'; - + /* Directory should be valid */ if((dir_name == NULL)||((dir_size = strlen(dir_name)) > PATH_MAX))