Blame SOURCES/aide-0.15-syslog-format.patch

bc4ae4
diff -up ./doc/aide.conf.5.in.syslog-format ./doc/aide.conf.5.in
bc4ae4
--- ./doc/aide.conf.5.in.syslog-format	2010-08-08 13:39:31.000000000 -0400
bc4ae4
+++ ./doc/aide.conf.5.in	2017-03-07 11:12:49.964000000 -0500
bc4ae4
@@ -44,6 +44,25 @@ inclusive. This parameter can only be gi
bc4ae4
 occurence is used. If \-\-verbose or \-V is used then the value from that
bc4ae4
 is used. The default is 5. If verbosity is 20 then additional report
bc4ae4
 output is written when doing \-\-check, \-\-update or \-\-compare.
bc4ae4
+.IP "syslog_format"
bc4ae4
+Valid values are yes,true,no and false. This option enables new syslog format
bc4ae4
+which is suitable for logging. Every change is logged as one simple line. This option
bc4ae4
+changes verbose level to 0 and prints everything that was changed. It is suggested 
bc4ae4
+to use this option with "report_url=syslog:...". Default value is "false/no".
bc4ae4
+Maximum size of message is 1KB which is limitation of syslog call. If message is 
bc4ae4
+greater than limit, message will be truncated.
bc4ae4
+Option summarize_changes has no impact for this format.
bc4ae4
+.nf
bc4ae4
+.eo
bc4ae4
+
bc4ae4
+Output always starts with:
bc4ae4
+"AIDE found differences between database and filesystem!!"
bc4ae4
+And it is followed by summary:
bc4ae4
+summary;total_number_of_files=1000;added_files=0;removed_files=0;changed_files=1
bc4ae4
+And finally there are logs about changes:
bc4ae4
+dir=/usr/sbin;Mtime_old=0000-00-00 00:00:00;Mtime_new=0000-00-00 00:00:00;...
bc4ae4
+.ec
bc4ae4
+.fi
bc4ae4
 .IP "report_url"
bc4ae4
 The url that the output is written to. There can be multiple instances
bc4ae4
 of this parameter. Output is written to all of them. The default is
bc4ae4
diff -up ./include/db_config.h.syslog-format ./include/db_config.h
bc4ae4
--- ./include/db_config.h.syslog-format	2010-08-08 13:39:31.000000000 -0400
bc4ae4
+++ ./include/db_config.h	2017-03-07 11:12:49.964000000 -0500
bc4ae4
@@ -264,6 +264,7 @@ typedef struct db_config {
bc4ae4
   FILE* db_out;
bc4ae4
   
bc4ae4
   int config_check;
bc4ae4
+  int syslog_format;
bc4ae4
 
bc4ae4
 #ifdef WITH_ZLIB
bc4ae4
   gzFile db_gzin;
bc4ae4
diff -up ./src/aide.c.syslog-format ./src/aide.c
bc4ae4
--- ./src/aide.c.syslog-format	2017-03-07 11:12:49.960000000 -0500
bc4ae4
+++ ./src/aide.c	2017-03-07 11:12:49.964000000 -0500
bc4ae4
@@ -264,6 +264,7 @@ void setdefaults_before_config()
bc4ae4
   }
bc4ae4
   
bc4ae4
   /* Setting some defaults */
bc4ae4
+  conf->syslog_format=0;
bc4ae4
   conf->report_db=0;  
bc4ae4
   conf->tree=NULL;
bc4ae4
   conf->config_check=0;
bc4ae4
@@ -468,6 +469,9 @@ void setdefaults_after_config()
bc4ae4
   if(conf->verbose_level==-1){
bc4ae4
     conf->verbose_level=5;
bc4ae4
   }
bc4ae4
+  if(conf->syslog_format==1){
bc4ae4
+    conf->verbose_level=0;
bc4ae4
+  }
bc4ae4
 }
bc4ae4
 
bc4ae4
 
bc4ae4
@@ -664,6 +668,7 @@ int main(int argc,char**argv)
bc4ae4
   gcry_control(GCRYCTL_TERM_SECMEM, 0);
bc4ae4
 #endif /* WITH_GCRYPT */
bc4ae4
   return RETOK;
bc4ae4
+
bc4ae4
 }
bc4ae4
 const char* aide_key_3=CONFHMACKEY_03;
bc4ae4
 const char* db_key_3=DBHMACKEY_03;
bc4ae4
diff -up ./src/compare_db.c.syslog-format ./src/compare_db.c
bc4ae4
--- ./src/compare_db.c.syslog-format	2010-08-08 13:39:31.000000000 -0400
bc4ae4
+++ ./src/compare_db.c	2017-03-07 11:30:52.630000000 -0500
bc4ae4
@@ -50,6 +50,7 @@
bc4ae4
 #include "md.h"
bc4ae4
 
bc4ae4
 /*************/
bc4ae4
+#define MESSAGE_SIZE 1024
bc4ae4
 /* contruction area for report lines */
bc4ae4
 const int old_col  = 12;   
bc4ae4
 const int new_col  = 40;   
bc4ae4
@@ -60,6 +61,9 @@ char      oline[129];
bc4ae4
 char      nline[129];
bc4ae4
 const char* entry_format=        " %-9s: %-33s, %s\n";
bc4ae4
 const char* entry_format_justnew=" %-9s: %-33c  %s\n";
bc4ae4
+const char* entry_syslog=        "%s_old=%s;%s_new=%s";
bc4ae4
+const char* entry_syslog_justnew="%s_new=%s";
bc4ae4
+
bc4ae4
 #ifdef WITH_E2FSATTRS
bc4ae4
     /* flag->character mappings defined in lib/e2p/pf.c (part of e2fsprogs-1.41.12 sources) */
bc4ae4
     unsigned long flag_bits[] = { EXT2_SECRM_FL, EXT2_UNRM_FL, EXT2_SYNC_FL, EXT2_DIRSYNC_FL, EXT2_IMMUTABLE_FL,
bc4ae4
@@ -415,7 +419,7 @@ DB_ATTR_TYPE compare_dbline(db_line* l1,
bc4ae4
   return ret;
bc4ae4
 }
bc4ae4
 
bc4ae4
-void print_str_changes(char*old,char*new,const char *name, DB_ATTR_TYPE force)
bc4ae4
+void print_str_changes(char*old,char*new,const char *name, DB_ATTR_TYPE force, char* part_message)
bc4ae4
 {
bc4ae4
   int mode = 0;
bc4ae4
   if(old==NULL){
bc4ae4
@@ -438,50 +442,80 @@ void print_str_changes(char*old,char*new
bc4ae4
   }
bc4ae4
    if(mode == 1) {
bc4ae4
      error(2,(char*)entry_format,name,oline,nline);
bc4ae4
+     if(part_message!=NULL && conf->syslog_format){
bc4ae4
+       snprintf(part_message, MESSAGE_SIZE, entry_syslog, name, oline, name, nline);
bc4ae4
+     }
bc4ae4
    } else if (mode == 2) {
bc4ae4
     error(2,(char*)entry_format_justnew,name,' ',nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog_justnew, name, nline);
bc4ae4
+    }
bc4ae4
+   } else {
bc4ae4
+      part_message="\0";
bc4ae4
    }
bc4ae4
    return;
bc4ae4
 }
bc4ae4
 
bc4ae4
 #ifdef WITH_ACL
bc4ae4
-void print_single_acl(acl_type* acl)
bc4ae4
+void print_single_acl(acl_type* acl, char* line)
bc4ae4
 {
bc4ae4
   if (acl==NULL) {
bc4ae4
     error(2,"<NULL>\n");
bc4ae4
+    if (conf->syslog_format)snprintf(line, long_part_len, "<NULL>");
bc4ae4
   } else {
bc4ae4
 #ifdef WITH_POSIX_ACL
bc4ae4
-    if (!acl->acl_a)
bc4ae4
+    if (!acl->acl_a) {
bc4ae4
       error(2,"A: <NONE>\n                  ");
bc4ae4
-    else
bc4ae4
+      if (conf->syslog_format)snprintf(line, long_part_len, "A:<NONE>");
bc4ae4
+    }
bc4ae4
+    else {
bc4ae4
       error(2,"A:\n----\n%s----\n                  ",acl->acl_a);
bc4ae4
-    if (!acl->acl_d)
bc4ae4
+      if (conf->syslog_format)snprintf(line, long_part_len, "A:%s", acl->acl_a);
bc4ae4
+    }
bc4ae4
+    size_t len=strlen(line);
bc4ae4
+    if (!acl->acl_d) {
bc4ae4
       error(2,"D: <NONE>\n");
bc4ae4
-    else
bc4ae4
+      if (conf->syslog_format&&len<(size_t)long_part_len)snprintf(line+len-1, long_part_len, "|D:<NONE>");
bc4ae4
+    }
bc4ae4
+    else {
bc4ae4
       error(2,"D:\n----\n%s----\n",acl->acl_d);
bc4ae4
+      if (conf->syslog_format&&len<(size_t)long_part_len)snprintf(line+len-1, long_part_len, "|D:%s", acl->acl_d);
bc4ae4
+    }
bc4ae4
 #endif
bc4ae4
 #ifdef WITH_SUN_ACL
bc4ae4
     aclt=acltotext(acl->acl,acl->entries);
bc4ae4
     if (aclt==NULL) {
bc4ae4
       error(2,"ERROR\n");
bc4ae4
+      if (conf->syslog_format)snprintf(line, long_part_len, "<ERROR>");
bc4ae4
     } else {
bc4ae4
       error(2,"%s ,\n",aclt);
bc4ae4
+      if (conf->syslog_format)snprintf(line, long_part_len, "%s", aclt);
bc4ae4
       free(aclt);
bc4ae4
     }
bc4ae4
 #endif
bc4ae4
   }
bc4ae4
 }
bc4ae4
 
bc4ae4
-void print_acl_changes(acl_type* old,acl_type* new, DB_ATTR_TYPE force) {
bc4ae4
+void print_acl_changes(acl_type* old,acl_type* new, DB_ATTR_TYPE force, char* part_message) {
bc4ae4
   
bc4ae4
   if (compare_acl(old,new)==RETFAIL) {
bc4ae4
     error(2," ACL      : old = ");
bc4ae4
-    print_single_acl(old);
bc4ae4
+    print_single_acl(old, oline);
bc4ae4
     error(2,"            new = ");
bc4ae4
-    print_single_acl(new);
bc4ae4
+    print_single_acl(new, nline);
bc4ae4
+    if (conf->syslog_format) {
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, "ACL_old=|%s|;ACL_new=|%s|", oline, nline);
bc4ae4
+      unsigned int i;
bc4ae4
+      for (i = 0; i < strlen(part_message); i++) if (part_message[i] == '\n') part_message[i] = ' ';
bc4ae4
+    }
bc4ae4
   } else if (old!=NULL && new!=NULL && force) {
bc4ae4
       error(2," ACL      :       ");
bc4ae4
-      print_single_acl(new);
bc4ae4
+      print_single_acl(new, nline);
bc4ae4
+      if (conf->syslog_format) {
bc4ae4
+        snprintf(part_message, MESSAGE_SIZE, "ACL_new=|%s|", nline);
bc4ae4
+        unsigned int i;
bc4ae4
+        for (i = 0; i < strlen(part_message); i++) if (part_message[i] == '\n') part_message[i] = ' ';
bc4ae4
+      }
bc4ae4
   }
bc4ae4
 }
bc4ae4
 #endif
bc4ae4
@@ -502,15 +536,18 @@ static size_t xstrnspn(const char *s1, s
bc4ae4
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                \
bc4ae4
     ".-_:;,[]{}<>()!@#$%^&*|\\/?~"
bc4ae4
 
bc4ae4
-void print_single_xattrs(xattrs_type* xattrs)
bc4ae4
+void print_single_xattrs(xattrs_type* xattrs, char* line)
bc4ae4
 {
bc4ae4
   if (xattrs==NULL) {
bc4ae4
     error(2,"num=0\n");
bc4ae4
+    if (conf->syslog_format)snprintf(line, MESSAGE_SIZE, "num=0");
bc4ae4
   } else {
bc4ae4
     size_t num = 0;
bc4ae4
     int width = 0;
bc4ae4
-    
bc4ae4
+    char tmp[MESSAGE_SIZE]={0};    
bc4ae4
+
bc4ae4
     error(2,"num=%lu\n", (unsigned long)xattrs->num);
bc4ae4
+    if (conf->syslog_format)snprintf(line, MESSAGE_SIZE, "num=%lu", (unsigned long)xattrs->num);
bc4ae4
 
bc4ae4
     width = log10(xattrs->num); /* make them the same width */
bc4ae4
     
bc4ae4
@@ -524,33 +561,44 @@ void print_single_xattrs(xattrs_type* xa
bc4ae4
       len = xstrnspn(val, xattrs->ents[num - 1].vsz, PRINTABLE_XATTR_VALS);
bc4ae4
       
bc4ae4
       if ((len ==  xattrs->ents[num - 1].vsz) ||
bc4ae4
-          ((len == (xattrs->ents[num - 1].vsz - 1)) && !val[len]))
bc4ae4
+          ((len == (xattrs->ents[num - 1].vsz - 1)) && !val[len])) {
bc4ae4
         error(2,"             [%.*zd] %s = %s\n", width, num,
bc4ae4
               xattrs->ents[num - 1].key, val);
bc4ae4
-      else        
bc4ae4
-      {
bc4ae4
+        if (conf->syslog_format)snprintf(tmp, MESSAGE_SIZE, "[%.*zd]%s=%s", width, num,
bc4ae4
+              xattrs->ents[num - 1].key, val);
bc4ae4
+      }
bc4ae4
+      else {
bc4ae4
         val = encode_base64(xattrs->ents[num - 1].val,
bc4ae4
                             xattrs->ents[num - 1].vsz);
bc4ae4
         error(2,"             [%.*zd] %s <=> %s\n", width, num,
bc4ae4
               xattrs->ents[num - 1].key, val);
bc4ae4
+        if (conf->syslog_format)snprintf(tmp, MESSAGE_SIZE, "[%.*zd]%s<=>%s", width, num,
bc4ae4
+              xattrs->ents[num - 1].key, val);
bc4ae4
         free(val);
bc4ae4
       }
bc4ae4
-      
bc4ae4
+
bc4ae4
+      if (conf->syslog_format&&len
bc4ae4
+        len=strlen(line);
bc4ae4
+        snprintf(line+len, MESSAGE_SIZE-len, "|%s", tmp);
bc4ae4
+      }
bc4ae4
     }
bc4ae4
   }
bc4ae4
 }
bc4ae4
 
bc4ae4
 void print_xattrs_changes(xattrs_type* old,xattrs_type* new,
bc4ae4
-        DB_ATTR_TYPE force) {
bc4ae4
-  
bc4ae4
+        DB_ATTR_TYPE force, char* part_message) {
bc4ae4
+  char old_attrs[MESSAGE_SIZE]={0};
bc4ae4
+  char new_attrs[MESSAGE_SIZE]={0};
bc4ae4
   if (compare_xattrs(old,new)==RETFAIL) {
bc4ae4
     error(2," XAttrs   : old = ");
bc4ae4
-    print_single_xattrs(old);
bc4ae4
+    print_single_xattrs(old, (char*)old_attrs);
bc4ae4
     error(2,"            new = ");
bc4ae4
-    print_single_xattrs(new);
bc4ae4
+    print_single_xattrs(new, (char*)new_attrs);
bc4ae4
+    if (conf->syslog_format)snprintf(part_message, MESSAGE_SIZE, "XAttrs_old=|%s|;XAttrs_new=|%s|", (char*)old_attrs, (char*)new_attrs);
bc4ae4
   } else if (force) {
bc4ae4
       error(2," XAttrs   : ");
bc4ae4
-      print_single_xattrs(new);
bc4ae4
+      print_single_xattrs(new, (char*)new_attrs);
bc4ae4
+      if (conf->syslog_format)snprintf(part_message, MESSAGE_SIZE, "XAttrs_new=|%s|", (char*)new_attrs);
bc4ae4
   }
bc4ae4
   
bc4ae4
 }
bc4ae4
@@ -571,7 +619,7 @@ char* e2fsattrs2char(unsigned long flags
bc4ae4
 }
bc4ae4
 #endif
bc4ae4
 
bc4ae4
-void print_md_changes(byte*old,byte*new,int len,char* name, DB_ATTR_TYPE force)
bc4ae4
+void print_md_changes(byte*old,byte*new,int len,char* name, DB_ATTR_TYPE force, char* part_message)
bc4ae4
 {
bc4ae4
     int mode = 0;
bc4ae4
     if (old!=NULL && new!=NULL) {
bc4ae4
@@ -594,8 +642,14 @@ void print_md_changes(byte*old,byte*new,
bc4ae4
     }
bc4ae4
     if (mode == 1) {
bc4ae4
         error(2,(char*)entry_format,name,oline,nline);
bc4ae4
+        if(part_message!=NULL && conf->syslog_format){
bc4ae4
+          snprintf(part_message, MESSAGE_SIZE, entry_syslog, name, oline, name, nline);
bc4ae4
+        }
bc4ae4
     } else if (mode == 2) {
bc4ae4
         error(2,(char*)entry_format_justnew,name,' ',nline);
bc4ae4
+        if(part_message!=NULL && conf->syslog_format){
bc4ae4
+          snprintf(part_message, MESSAGE_SIZE, entry_syslog_justnew, name, nline);
bc4ae4
+        }
bc4ae4
     }
bc4ae4
     return;
bc4ae4
 }
bc4ae4
@@ -607,7 +661,7 @@ int is_time_null(struct tm *ot)
bc4ae4
             && ot->tm_hour == 1 &&  ot->tm_min == 0 && ot->tm_sec == 0);
bc4ae4
 }
bc4ae4
 
bc4ae4
-void print_time_changes(const char* name, time_t old_time, time_t new_time,int justnew)
bc4ae4
+void print_time_changes(const char* name, time_t old_time, time_t new_time,int justnew, char* part_message)
bc4ae4
 {
bc4ae4
   struct tm otm;
bc4ae4
   struct tm *ot = &otm;
bc4ae4
@@ -640,12 +694,18 @@ void print_time_changes(const char* name
bc4ae4
   }
bc4ae4
   if (justnew) {
bc4ae4
     error(2,(char*)entry_format_justnew,name,' ',nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog_justnew, name, nline);
bc4ae4
+    }
bc4ae4
   } else {
bc4ae4
-    error(2,(char*)entry_format,name,oline,nline); 
bc4ae4
+    error(2,(char*)entry_format,name,oline,nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog, name, oline, name, nline);
bc4ae4
+    }
bc4ae4
   }
bc4ae4
 }
bc4ae4
 
bc4ae4
-void print_int_changes(const char* name, int old, int new, int justnew)
bc4ae4
+void print_int_changes(const char* name, int old, int new, int justnew, char* part_message)
bc4ae4
 {
bc4ae4
   if (!justnew) {
bc4ae4
     snprintf(oline,part_len,"%i",old);
bc4ae4
@@ -653,11 +713,17 @@ void print_int_changes(const char* name,
bc4ae4
   snprintf(nline,part_len,"%i",new);
bc4ae4
   if (justnew) {
bc4ae4
     error(2,(char*)entry_format_justnew,name,' ',nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog_justnew, name, nline);
bc4ae4
+    }
bc4ae4
   } else {
bc4ae4
     error(2,(char*)entry_format,name,oline,nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog, name, oline, name, nline);
bc4ae4
+    }
bc4ae4
   }
bc4ae4
 }
bc4ae4
-void print_long_changes(const char* name, AIDE_OFF_TYPE old, AIDE_OFF_TYPE new, int justnew)
bc4ae4
+void print_long_changes(const char* name, AIDE_OFF_TYPE old, AIDE_OFF_TYPE new, int justnew, char* part_message)
bc4ae4
 {
bc4ae4
 #if SIZEOF_OFF64_T == SIZEOF_LONG_LONG
bc4ae4
   if (!justnew) {
bc4ae4
@@ -672,12 +738,18 @@ void print_long_changes(const char* name
bc4ae4
 #endif
bc4ae4
   if (justnew) {
bc4ae4
     error(2,(char*)entry_format_justnew,name,' ',nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog_justnew, name, nline);
bc4ae4
+    }
bc4ae4
   } else {
bc4ae4
     error(2,(char*)entry_format,name,oline,nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog, name, oline, name, nline);
bc4ae4
+    }
bc4ae4
   }
bc4ae4
 }
bc4ae4
 
bc4ae4
-void print_string_changes(const char* name, const char* old, const char* new, int justnew)
bc4ae4
+void print_string_changes(const char* name, const char* old, const char* new, int justnew, char* part_message)
bc4ae4
 {
bc4ae4
   if (!justnew) {
bc4ae4
     snprintf(oline,part_len,"%s",old);
bc4ae4
@@ -685,8 +757,14 @@ void print_string_changes(const char* na
bc4ae4
   snprintf(nline,part_len,"%s",new);
bc4ae4
   if (justnew) {
bc4ae4
     error(2,(char*)entry_format_justnew,name,' ',nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog_justnew, name, nline);
bc4ae4
+    }
bc4ae4
   } else {
bc4ae4
-    error(2,(char*)entry_format,name,oline,nline); 
bc4ae4
+    error(2,(char*)entry_format,name,oline,nline);
bc4ae4
+    if(part_message!=NULL && conf->syslog_format){
bc4ae4
+      snprintf(part_message, MESSAGE_SIZE, entry_syslog, name, oline, name, nline);
bc4ae4
+    } 
bc4ae4
   }
bc4ae4
 }
bc4ae4
 
bc4ae4
@@ -954,168 +1032,226 @@ void print_changed_line(db_line* old,db_
bc4ae4
     }
bc4ae4
 }
bc4ae4
 
bc4ae4
+static void p_swap(char** first, char** second)
bc4ae4
+{
bc4ae4
+  if(first==NULL||second==NULL)return;
bc4ae4
+  char* tmp=*first;
bc4ae4
+  *first=*second;
bc4ae4
+  *second=tmp;
bc4ae4
+}
bc4ae4
+
bc4ae4
+#define DO_APPEND(x,y,z) do{ \
bc4ae4
+                           if(conf->syslog_format&&z[0]!=0){ \
bc4ae4
+                             snprintf(x, MESSAGE_SIZE,"%s;%s",y,z); \
bc4ae4
+                             p_swap((char**)&x,(char**)&y); \
bc4ae4
+                             z[0]='\0';  \
bc4ae4
+                           } \
bc4ae4
+                         }while(0) 
bc4ae4
+
bc4ae4
 void print_dbline_changes(db_line* old,db_line* new,
bc4ae4
                           DB_ATTR_TYPE ignorelist,DB_ATTR_TYPE forced_attrs)
bc4ae4
 {
bc4ae4
   char* tmp=NULL;
bc4ae4
   char* tmp2=NULL;
bc4ae4
-  
bc4ae4
+
bc4ae4
+  char part_message[MESSAGE_SIZE]={0};
bc4ae4
+  char message1[MESSAGE_SIZE]={0};
bc4ae4
+  char message2[MESSAGE_SIZE]={0};
bc4ae4
+  char* message=&message1[0];
bc4ae4
+  char* message_old=&message2[0];
bc4ae4
   /*
bc4ae4
     Force just entries, that exists.
bc4ae4
   */
bc4ae4
   forced_attrs&=new->attr;
bc4ae4
   
bc4ae4
   error(2,"\n%s: %s\n",get_file_type_string(new->perm),new->filename);
bc4ae4
+  
bc4ae4
+  if(conf->syslog_format){
bc4ae4
+    if(S_ISDIR(new->perm_o))
bc4ae4
+      snprintf(message, MESSAGE_SIZE, "dir=%s", old->filename);
bc4ae4
+    else
bc4ae4
+      snprintf(message, MESSAGE_SIZE, "file=%s", old->filename);
bc4ae4
+    p_swap(&message,&message_old);
bc4ae4
+  }
bc4ae4
 
bc4ae4
   if ((!(DB_FTYPE&ignorelist)) && (((DB_FTYPE&old->attr && DB_FTYPE&new->attr) && get_file_type_char(old->perm)!=get_file_type_char(new->perm)) || DB_FTYPE&forced_attrs)) {
bc4ae4
-          print_string_changes("File type", get_file_type_string(old->perm),get_file_type_string(new->perm), get_file_type_char(old->perm)==get_file_type_char(new->perm));
bc4ae4
+    if(conf->syslog_format)
bc4ae4
+      print_string_changes("file_type", get_file_type_string(old->perm),get_file_type_string(new->perm), get_file_type_char(old->perm)==get_file_type_char(new->perm), ((char*)part_message));
bc4ae4
+    else
bc4ae4
+      print_string_changes("File type", get_file_type_string(old->perm),get_file_type_string(new->perm), get_file_type_char(old->perm)==get_file_type_char(new->perm), NULL);
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
   if(!(DB_LINKNAME&ignorelist)){
bc4ae4
-    print_str_changes(old->linkname,new->linkname, "Lname", DB_LINKNAME&forced_attrs);
bc4ae4
+    print_str_changes(old->linkname,new->linkname, "Lname", DB_LINKNAME&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (((!(DB_SIZEG&ignorelist)) && (((DB_SIZEG&old->attr && DB_SIZEG&new->attr)  && old->size>new->size) || DB_SIZEG&forced_attrs))
bc4ae4
      || ((!(DB_SIZE&ignorelist)) && (((DB_SIZE&old->attr && DB_SIZE&new->attr) && old->size!=new->size) || DB_SIZE&forced_attrs)) ) {
bc4ae4
-          print_long_changes("Size", old->size,new->size,old->size==new->size);
bc4ae4
+          print_long_changes("Size", old->size,new->size,old->size==new->size, ((char*)part_message));
bc4ae4
+          DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (!(DB_BCOUNT&ignorelist)) {
bc4ae4
     if(old->bcount!=new->bcount ||(DB_BCOUNT&forced_attrs) ){
bc4ae4
-      print_int_changes("Bcount", old->bcount,new->bcount,old->bcount==new->bcount);
bc4ae4
+      print_int_changes("Bcount", old->bcount,new->bcount,old->bcount==new->bcount, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   if (!(DB_PERM&ignorelist)) {
bc4ae4
     if((DB_PERM&old->attr && DB_PERM&new->attr && old->perm!=new->perm) || DB_PERM&forced_attrs){
bc4ae4
       tmp=perm_to_char(old->perm);
bc4ae4
       tmp2=perm_to_char(new->perm);
bc4ae4
-      print_string_changes("Perm", tmp,tmp2,old->perm==new->perm);
bc4ae4
+      print_string_changes("Perm", tmp,tmp2,old->perm==new->perm, ((char*)part_message));
bc4ae4
       free(tmp);
bc4ae4
       free(tmp2);
bc4ae4
       tmp=NULL;
bc4ae4
       tmp2=NULL;
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_UID&ignorelist)) {
bc4ae4
     if(old->uid!=new->uid||DB_UID&forced_attrs){
bc4ae4
-      print_int_changes("Uid", old->uid,new->uid,old->uid==new->uid);
bc4ae4
+      print_int_changes("Uid", old->uid,new->uid,old->uid==new->uid, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_GID&ignorelist)) {
bc4ae4
     if(old->gid!=new->gid||DB_GID&forced_attrs){
bc4ae4
-      print_int_changes("Gid", old->gid,new->gid,old->gid==new->gid);
bc4ae4
+      print_int_changes("Gid", old->gid,new->gid,old->gid==new->gid, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_ATIME&ignorelist)) {
bc4ae4
     if(old->atime!=new->atime||DB_ATIME&forced_attrs){
bc4ae4
-      print_time_changes("Atime", old->atime, new->atime,old->atime==new->atime);
bc4ae4
+      print_time_changes("Atime", old->atime, new->atime,old->atime==new->atime, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_MTIME&ignorelist)) {
bc4ae4
     if(old->mtime!=new->mtime||DB_MTIME&forced_attrs){
bc4ae4
-      print_time_changes("Mtime", old->mtime, new->mtime,old->mtime==new->mtime);
bc4ae4
+      print_time_changes("Mtime", old->mtime, new->mtime,old->mtime==new->mtime, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_CTIME&ignorelist)) {
bc4ae4
     if(old->ctime!=new->ctime||DB_CTIME&forced_attrs){
bc4ae4
-      print_time_changes("Ctime", old->ctime, new->ctime,old->ctime==new->ctime);
bc4ae4
+      print_time_changes("Ctime", old->ctime, new->ctime,old->ctime==new->ctime, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (!(DB_INODE&ignorelist)) {
bc4ae4
     if(((DB_INODE&old->attr && (DB_INODE&new->attr)) && old->inode!=new->inode) ||DB_INODE&forced_attrs){
bc4ae4
-      print_int_changes("Inode", old->inode,new->inode,old->inode==new->inode);
bc4ae4
+      print_int_changes("Inode", old->inode,new->inode,old->inode==new->inode, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
   if (!(DB_LNKCOUNT&ignorelist)) {
bc4ae4
     if(old->nlink!=new->nlink||DB_LNKCOUNT&forced_attrs){
bc4ae4
-      print_int_changes("Linkcount", old->nlink,new->nlink,old->nlink==new->nlink);
bc4ae4
+      print_int_changes("Linkcount", old->nlink,new->nlink,old->nlink==new->nlink, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
     }
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (!(DB_MD5&ignorelist)) {  
bc4ae4
     print_md_changes(old->md5,new->md5,
bc4ae4
 		     HASH_MD5_LEN,
bc4ae4
-		     "MD5", DB_MD5&forced_attrs);
bc4ae4
+		     "MD5", DB_MD5&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_SHA1&ignorelist)) {
bc4ae4
       print_md_changes(old->sha1,new->sha1,
bc4ae4
 		       HASH_SHA1_LEN,
bc4ae4
-		       "SHA1", DB_SHA1&forced_attrs);
bc4ae4
+		       "SHA1", DB_SHA1&forced_attrs, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (!(DB_RMD160&ignorelist)) {
bc4ae4
     print_md_changes(old->rmd160,new->rmd160,
bc4ae4
 		     HASH_RMD160_LEN,
bc4ae4
-		     "RMD160", DB_RMD160&forced_attrs);
bc4ae4
+		     "RMD160", DB_RMD160&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_TIGER&ignorelist)) {
bc4ae4
     print_md_changes(old->tiger,new->tiger,
bc4ae4
 		     HASH_TIGER_LEN,
bc4ae4
-		     "TIGER", DB_TIGER&forced_attrs);
bc4ae4
+		     "TIGER", DB_TIGER&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_SHA256&ignorelist)) {
bc4ae4
       print_md_changes(old->sha256,new->sha256,
bc4ae4
 		       HASH_SHA256_LEN,
bc4ae4
-		       "SHA256", DB_SHA256&forced_attrs);
bc4ae4
+		       "SHA256", DB_SHA256&forced_attrs, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (!(DB_SHA512&ignorelist)) {
bc4ae4
       print_md_changes(old->sha512,new->sha512,
bc4ae4
 		       HASH_SHA512_LEN,
bc4ae4
-		       "SHA512", DB_SHA512&forced_attrs);
bc4ae4
+		       "SHA512", DB_SHA512&forced_attrs, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
 #ifdef WITH_MHASH
bc4ae4
   if (!(DB_CRC32&ignorelist)) {
bc4ae4
     print_md_changes(old->crc32,new->crc32,
bc4ae4
 		     HASH_CRC32_LEN,
bc4ae4
-		     "CRC32", DB_CRC32&forced_attrs);
bc4ae4
+		     "CRC32", DB_CRC32&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_HAVAL&ignorelist)) {
bc4ae4
     print_md_changes(old->haval,new->haval,
bc4ae4
 		     HASH_HAVAL256_LEN,
bc4ae4
-		     "HAVAL", DB_HAVAL&forced_attrs);
bc4ae4
+		     "HAVAL", DB_HAVAL&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_GOST&ignorelist)) {
bc4ae4
     print_md_changes(old->gost,new->gost,
bc4ae4
 		     HASH_GOST_LEN,
bc4ae4
-		     "GOST", DB_GOST&forced_attrs);
bc4ae4
+		     "GOST", DB_GOST&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
   if (!(DB_CRC32B&ignorelist)) {
bc4ae4
     print_md_changes(old->crc32b,new->crc32b,
bc4ae4
 		     HASH_CRC32B_LEN,
bc4ae4
-		     "CRC32B", DB_CRC32B&forced_attrs);
bc4ae4
+		     "CRC32B", DB_CRC32B&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 
bc4ae4
   if (!(DB_WHIRLPOOL&ignorelist)) {
bc4ae4
       print_md_changes(old->whirlpool,new->whirlpool,
bc4ae4
 		       HASH_WHIRLPOOL_LEN,
bc4ae4
-		       "WHIRLPOOL", DB_WHIRLPOOL&forced_attrs);
bc4ae4
+		       "WHIRLPOOL", DB_WHIRLPOOL&forced_attrs, ((char*)part_message));
bc4ae4
+      DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 #endif                   
bc4ae4
 
bc4ae4
 #ifdef WITH_ACL
bc4ae4
   if (!(DB_ACL&ignorelist)) {
bc4ae4
-    print_acl_changes(old->acl,new->acl, DB_ACL&forced_attrs);
bc4ae4
+    print_acl_changes(old->acl,new->acl, DB_ACL&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
 #endif
bc4ae4
   if (!(DB_XATTRS&ignorelist)) {
bc4ae4
-    print_xattrs_changes(old->xattrs,new->xattrs, DB_XATTRS&forced_attrs);
bc4ae4
+    print_xattrs_changes(old->xattrs,new->xattrs, DB_XATTRS&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   if (!(DB_SELINUX&ignorelist)) {
bc4ae4
-    print_str_changes(old->cntx,new->cntx, "SELinux", DB_SELINUX&forced_attrs);
bc4ae4
+    print_str_changes(old->cntx,new->cntx, "SELinux", DB_SELINUX&forced_attrs, ((char*)part_message));
bc4ae4
+    DO_APPEND(message,message_old,part_message);
bc4ae4
   }
bc4ae4
   
bc4ae4
 #ifdef WITH_E2FSATTRS
bc4ae4
@@ -1123,13 +1259,19 @@ void print_dbline_changes(db_line* old,d
bc4ae4
       if(old->e2fsattrs!=new->e2fsattrs || DB_E2FSATTRS&forced_attrs ) {
bc4ae4
           tmp=e2fsattrs2char(old->e2fsattrs);
bc4ae4
           tmp2=e2fsattrs2char(new->e2fsattrs);
bc4ae4
-          print_string_changes("E2FSAttrs", tmp, tmp2, old->e2fsattrs==new->e2fsattrs);
bc4ae4
+          print_string_changes("E2FSAttrs", tmp, tmp2, old->e2fsattrs==new->e2fsattrs, ((char*)part_message));
bc4ae4
           free(tmp); free(tmp2);
bc4ae4
           tmp=NULL; tmp2=NULL;
bc4ae4
+          DO_APPEND(message,message_old,part_message);
bc4ae4
       }
bc4ae4
   }
bc4ae4
 #endif
bc4ae4
 
bc4ae4
+  if (conf->syslog_format) {
bc4ae4
+    /* Already swapped */
bc4ae4
+    error(0, "%s\n", message_old);
bc4ae4
+  }
bc4ae4
+
bc4ae4
   return;
bc4ae4
 }
bc4ae4
 
bc4ae4
@@ -1207,8 +1349,13 @@ void print_report_header(int nfil,int na
bc4ae4
   error(2,_("Start timestamp: %.4u-%.2u-%.2u %.2u:%.2u:%.2u\n"),
bc4ae4
 	st->tm_year+1900, st->tm_mon+1, st->tm_mday,
bc4ae4
 	st->tm_hour, st->tm_min, st->tm_sec);
bc4ae4
-  error(0,_("\nSummary:\n  Total number of files:\t%i\n  Added files:\t\t\t%i\n"
bc4ae4
+  if(!conf->syslog_format){
bc4ae4
+    error(0,_("\nSummary:\n  Total number of files:\t%i\n  Added files:\t\t\t%i\n"
bc4ae4
 	    "  Removed files:\t\t%i\n  Changed files:\t\t%i\n\n"),nfil,nadd,nrem,nchg);
bc4ae4
+  }else{
bc4ae4
+   error(0,_("summary;total_number_of_files=%i;added_files=%i;"
bc4ae4
+            "removed_files=%i;changed_files=%i\n"),nfil,nadd,nrem,nchg);
bc4ae4
+  }
bc4ae4
   
bc4ae4
 }
bc4ae4
 
bc4ae4
@@ -1312,6 +1459,7 @@ long report_tree(seltree* node,int stage
bc4ae4
     }
bc4ae4
     if(node->checked&NODE_ADDED){
bc4ae4
       print_added_line(node->new_data);
bc4ae4
+      if(conf->syslog_format) error(0, "file=%s; added\n", node->new_data->filename);
bc4ae4
     }
bc4ae4
   }
bc4ae4
 
bc4ae4
@@ -1323,6 +1471,7 @@ long report_tree(seltree* node,int stage
bc4ae4
     }
bc4ae4
     if(node->checked&NODE_REMOVED){
bc4ae4
       print_removed_line(node->old_data);
bc4ae4
+      if(conf->syslog_format) error(0, "file=%s; removed\n", node->old_data->filename);
bc4ae4
     }
bc4ae4
   }
bc4ae4
 
bc4ae4
@@ -1337,7 +1486,7 @@ long report_tree(seltree* node,int stage
bc4ae4
     }
bc4ae4
   }
bc4ae4
 
bc4ae4
-  if((stage==4)&&(conf->verbose_level>=5)&&status[4]){
bc4ae4
+  if((stage==4)&&(conf->verbose_level>=5||conf->syslog_format)&&status[4]){
bc4ae4
     if(top){
bc4ae4
       error(2,_("\n---------------------------------------------------\n"));
bc4ae4
       error(2,_("Detailed information about changes:\n"));
bc4ae4
diff -up ./src/conf_lex.l.syslog-format ./src/conf_lex.l
bc4ae4
--- ./src/conf_lex.l.syslog-format	2010-08-08 13:39:31.000000000 -0400
bc4ae4
+++ ./src/conf_lex.l	2017-03-07 11:12:49.965000000 -0500
bc4ae4
@@ -12,7 +12,7 @@ EX      [" "\t]*
bc4ae4
 
bc4ae4
 %{
bc4ae4
 
bc4ae4
-#define YYDEBUG
bc4ae4
+//#define YYDEBUG
bc4ae4
 
bc4ae4
 /*
bc4ae4
  * Copyright (C) 1999-2002,2004-2006,2010 Rami Lehti, Pablo Virolainen, Richard
bc4ae4
@@ -349,6 +349,12 @@ int var_in_conflval=0;
bc4ae4
   return (TGZIPDBOUT);
bc4ae4
 }
bc4ae4
 
bc4ae4
+^[\t\ ]*"syslog_format"{E} {
bc4ae4
+  error(230,"%li:syslog_format =\n",conf_lineno);
bc4ae4
+  BEGIN CONFVALHUNT;
bc4ae4
+  return (SYSLOG_FORMAT);
bc4ae4
+}
bc4ae4
+
bc4ae4
 ^[\t\ ]*"recstop"{E} {
bc4ae4
   error(230,"%li:recstop =\n",conf_lineno);
bc4ae4
   BEGIN CONFVALHUNT;
bc4ae4
diff -up ./src/conf_yacc.y.syslog-format ./src/conf_yacc.y
bc4ae4
--- ./src/conf_yacc.y.syslog-format	2010-08-08 13:39:31.000000000 -0400
bc4ae4
+++ ./src/conf_yacc.y	2017-03-07 11:12:49.965000000 -0500
bc4ae4
@@ -81,6 +81,7 @@ extern long conf_lineno;
bc4ae4
 %token TDATABASE_NEW
bc4ae4
 %token TREPORT_URL
bc4ae4
 %token TGZIPDBOUT
bc4ae4
+%token SYSLOG_FORMAT
bc4ae4
 %token TUMASK
bc4ae4
 %token TTRUE
bc4ae4
 %token TFALSE
bc4ae4
@@ -150,7 +151,7 @@ lines : lines line | ;
bc4ae4
 line : rule | equrule | negrule | definestmt | undefstmt
bc4ae4
        | ifdefstmt | ifndefstmt | ifhoststmt | ifnhoststmt
bc4ae4
        | groupdef | db_in | db_out | db_new | verbose | config_version 
bc4ae4
-       | report | gzipdbout | recursion_stopper | warn_dead_symlinks | grouped
bc4ae4
+       | report | gzipdbout | syslogformat | recursion_stopper | warn_dead_symlinks | grouped
bc4ae4
        | summarize_changes | acl_no_symlink_follow | beginconfigstmt | endconfigstmt
bc4ae4
        | TEOF {
bc4ae4
             newlinelastinconfig=1;
bc4ae4
@@ -329,6 +330,13 @@ conf->gzip_dbout=0;
bc4ae4
 #endif
bc4ae4
 } ;
bc4ae4
 
bc4ae4
+syslogformat : SYSLOG_FORMAT TTRUE {
bc4ae4
+conf->syslog_format=1;
bc4ae4
+} |
bc4ae4
+               SYSLOG_FORMAT TFALSE {
bc4ae4
+conf->syslog_format=0;
bc4ae4
+} ;
bc4ae4
+
bc4ae4
 recursion_stopper : TRECSTOP TSTRING {
bc4ae4
   /* FIXME implement me */  
bc4ae4
   
bc4ae4
diff -up ./src/db_lex.l.syslog-format ./src/db_lex.l
bc4ae4
--- ./src/db_lex.l.syslog-format	2010-08-08 13:39:31.000000000 -0400
bc4ae4
+++ ./src/db_lex.l	2017-03-07 11:12:49.965000000 -0500
bc4ae4
@@ -45,7 +45,7 @@ extern YYSTYPE yylval;
bc4ae4
 #define YY_DECL int db_scan(void)
bc4ae4
 
bc4ae4
 
bc4ae4
-#define YYDEBUG
bc4ae4
+//#define YYDEBUG
bc4ae4
 
bc4ae4
 #include "aide.h"
bc4ae4
 #include "conf_yacc.h"