[Aide] Question about report output
Pablo Virolainen
pablo at vapaa.fi
Wed Nov 29 12:20:20 EET 2006
On Tue, 28 Nov 2006, Jason Martens wrote:
> Thanks, this helps. So, how should I decipher the report line:
> File /var/lib/opennms/rrd/snmp in databases has different attributes,
> 4029,2077
> ?
>
> Which of the attributes listed changed? I know that not all of them did.
> Is it the difference between the two listed?
>
> The report would be much more useful if it listed what changed in human
> readable form, rather than hex or some other numerical method. Or, at
> least have a readily accessible table so us poor humans can convert
> it... :)
>
> Thanks for helping me understand this.
Originally that print was for developers only.
See attachment for human readable output (yeah.. not the prittiest code)
and my try to solve the whirlpool problem. At least, AIDE seems to build
ok whith older mhash library.
Pablo Virolainen
-------------- next part --------------
? whirlpool_and_human_readable_attrdiff.diff
Index: configure.in
===================================================================
RCS file: /cvsroot/aide/aide/configure.in,v
retrieving revision 1.62
diff -u -r1.62 configure.in
--- configure.in 25 Nov 2006 19:47:41 -0000 1.62
+++ configure.in 29 Nov 2006 10:13:45 -0000
@@ -608,6 +608,10 @@
[CRYPTLIB="${CRYPTLIB} -lmhash"
compoptionstring="${compoptionstring}WITH_MHASH\\n"
with_mhash=yes
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[#include <mhash.h>
+ int i=MHASH_WHIRLPOOL;
+ ]])],AC_DEFINE(HAVE_MHASH_WHIRLPOOL,1,[mhash has whirlpool]))
AC_DEFINE(WITH_MHASH,1,[use mhash library])],
[AC_MSG_WARN(No mhash means no hmac.)]
)
Index: include/db.h
===================================================================
RCS file: /cvsroot/aide/aide/include/db.h,v
retrieving revision 1.3
diff -u -r1.3 db.h
--- include/db.h 15 Nov 2005 16:17:11 -0000 1.3
+++ include/db.h 29 Nov 2006 10:13:45 -0000
@@ -35,6 +35,7 @@
int db_close(db_config*);
void free_db_line(db_line* dl);
+void print_attr_diff(int errorlevel,const char* filename1,const char* filename2,DB_ATTR_TYPE attr1,DB_ATTR_TYPE attr2);
extern const char* db_names[];
extern const int db_value[];
Index: include/md.h
===================================================================
RCS file: /cvsroot/aide/aide/include/md.h,v
retrieving revision 1.4
diff -u -r1.4 md.h
--- include/md.h 24 Nov 2006 18:25:02 -0000 1.4
+++ include/md.h 29 Nov 2006 10:13:45 -0000
@@ -32,7 +32,12 @@
#ifdef WITH_MHASH
#include <mhash.h>
-#define HASH_MHASH_COUNT MHASH_WHIRLPOOL /* WHIRLPOOL == 22 on 2006-10-11 */
+
+#ifdef HAVE_MHASH_WHIRLPOOL
+# define HASH_MHASH_COUNT MHASH_WHIRLPOOL /* WHIRLPOOL == 22 on 2006-10-11 */
+#else
+# define HASH_MHASH_COUNT MHASH_RIPEMD320
+#endif
#define MHASH_RMD160 MHASH_RIPEMD160
#define MHASH_HAVAL MHASH_HAVAL256
#endif
Index: src/aide.c
===================================================================
RCS file: /cvsroot/aide/aide/src/aide.c,v
retrieving revision 1.24
diff -u -r1.24 aide.c
--- src/aide.c 24 Nov 2006 19:21:39 -0000 1.24
+++ src/aide.c 29 Nov 2006 10:13:45 -0000
@@ -370,8 +370,10 @@
#ifdef WITH_MHASH
do_groupdef("gost",DB_GOST);
+#ifdef HAVE_MHASH_WHIRLPOOL
do_groupdef("whirlpool",DB_WHIRLPOOL);
#endif
+#endif
p=0LLU;
#if defined(WITH_MHASH) || defined(WITH_GCRYPT)
Index: src/compare_db.c
===================================================================
RCS file: /cvsroot/aide/aide/src/compare_db.c,v
retrieving revision 1.19
diff -u -r1.19 compare_db.c
--- src/compare_db.c 27 Oct 2006 20:44:38 -0000 1.19
+++ src/compare_db.c 29 Nov 2006 10:13:45 -0000
@@ -945,8 +945,11 @@
int localignorelist=old->attr ^ ((db_line*)r->data)->attr;
if ((localignorelist&(~(DB_NEWFILE|DB_RMFILE)))!=0) {
+ print_attr_diff(2,old->filename,NULL,old->attr,((db_line*)r->data)->attr);
+ /*
error(2,"File %s in databases has different attributes, %llx,%llx\n",
old->filename,old->attr,((db_line*)r->data)->attr);
+ */
}
localignorelist|=ignorelist;
Index: src/db.c
===================================================================
RCS file: /cvsroot/aide/aide/src/db.c,v
retrieving revision 1.16
diff -u -r1.16 db.c
--- src/db.c 25 Nov 2006 10:07:40 -0000 1.16
+++ src/db.c 29 Nov 2006 10:13:45 -0000
@@ -129,6 +129,63 @@
db_lnkcount } ; /* "count", */
+void print_attr_diff(int errorlevel,const char* filename1,const char* filename2,DB_ATTR_TYPE attr1,DB_ATTR_TYPE attr2)
+{
+ static const char* stdmsg=
+ "File %s%s%s in databases has different attributes "
+ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
+ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
+ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
+ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s";
+ const char* p[64];
+ char* delim;
+ int count=0,pos=0;
+
+
+ if (attr1==0 || attr2==0) {
+ return;
+ }
+
+ if (filename2==NULL) {
+ filename2="";
+ delim="";
+ } else {
+ delim=" ";
+ }
+
+ while(attr1!=attr2) {
+ if ((attr1&1) != (attr2&1)) {
+ p[count]=db_names[pos];
+ count++;
+ if (attr1&1) {
+ p[count]=":N ";
+ } else {
+ p[count]=":O ";
+ }
+ count++;
+ }
+ if (pos!=db_unknown) {
+ pos++;
+ }
+ attr1=attr1>>1;
+ attr2=attr2>>1;
+ }
+
+ if (count==0) {
+ /* Programming error */
+ abort();
+ }
+ for(;count<64;count++) {
+ p[count]="";
+ }
+ error(errorlevel,stdmsg,filename1,delim,filename2,
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15],
+ p[16], p[17], p[18], p[19], p[20], p[21], p[22], p[23], p[24], p[25], p[26], p[27], p[28], p[29], p[30], p[31],
+ p[32], p[33], p[34], p[35], p[36], p[37], p[38], p[39], p[40], p[41], p[42], p[43], p[44], p[45], p[46], p[47],
+ p[48], p[49], p[50], p[51], p[52], p[53], p[54], p[55], p[56], p[57], p[58], p[59], p[60], p[61], p[62], p[63]
+ );
+}
+
int db_init(int db)
{
void* rv=NULL;
Index: src/gen_list.c
===================================================================
RCS file: /cvsroot/aide/aide/src/gen_list.c,v
retrieving revision 1.29
diff -u -r1.29 gen_list.c
--- src/gen_list.c 24 Nov 2006 18:25:02 -0000 1.29
+++ src/gen_list.c 29 Nov 2006 10:13:46 -0000
@@ -1218,8 +1218,11 @@
if((node->checked&DB_OLD)&&(node->checked&DB_NEW)){
localignorelist=(node->new_data->attr^node->old_data->attr);
if (localignorelist!=0) {
+ print_attr_diff(2,node->old_data->filename,NULL,node->old_data->attr,node->new_data->attr);
+ /*
error(2,"File %s in databases has different attributes, %llx,%llx\n",
node->old_data->filename,node->old_data->attr,node->new_data->attr);
+ */
}
localignorelist|=ignorelist;
@@ -1267,8 +1270,11 @@
localignorelist=(oldData->attr^newData->attr)&(~(DB_NEWFILE|DB_RMFILE));
if (localignorelist!=0) {
+ print_attr_diff(5,newData->filename,oldData->filename,newData->attr,oldData->attr);
+ /*
error(5,"File \"%s\" \"%s\" in databases has different attributes (here3), %llx,%llx\n",
newData->filename,oldData->filename,oldData->attr,newData->attr);
+ */
}
localignorelist|=ignorelist|DB_CTIME;
Index: src/md.c
===================================================================
RCS file: /cvsroot/aide/aide/src/md.c,v
retrieving revision 1.5
diff -u -r1.5 md.c
--- src/md.c 24 Nov 2006 18:25:02 -0000 1.5
+++ src/md.c 29 Nov 2006 10:13:47 -0000
@@ -142,10 +142,12 @@
r=DB_SHA512;
break;
}
+#ifdef HAVE_MHASH_WHIRLPOOL
case MHASH_WHIRLPOOL: {
r=DB_WHIRLPOOL;
break;
}
+#endif
case MHASH_ADLER32: {
break;
}
@@ -309,7 +311,9 @@
get_mhash_hash(MHASH_CRC32B,crc32b);
get_mhash_hash(MHASH_SHA256,sha256);
get_mhash_hash(MHASH_SHA512,sha512);
+#ifdef HAVE_MHASH_WHIRLPOOL
get_mhash_hash(MHASH_WHIRLPOOL,whirlpool);
+#endif
/*
There might be more hashes in the library we want to use.
More information about the Aide
mailing list