[Aide] hash cannot be calculated

Virolainen Pablo pablo at cs.tut.fi
Fri Nov 5 10:15:29 EET 2004


On Tue, 2 Nov 2004 jgd42-aide at yahoo.com wrote:

> Hello-
>
> I've been using AIDE for a while and when I initialized it today, I got this...
>
>   # aide --init
>   File /usr/bin/co was changed so that hash cannot be calculated for it
>
>   AIDE, version 0.10
>
>   ### AIDE database initialized.
>
>
> What does "hash cannot be calculated" mean?
> I ran 'aide --init' again and it worked fine (without that message).

Well, the message is no too informative.
See attachment for ?better? error report. About error levels I have no
idea, so I put them to level 6.

Duke NEMO / C.O.M.A
alias pablo the pallo virolainen
-------------- next part --------------
diff -nru aide-CVS-20041102/include/db_config.h aide-CVS-20041102-patched/include/db_config.h
--- aide-CVS-20041102/include/db_config.h	Thu Oct 28 15:43:33 2004
+++ aide-CVS-20041102-patched/include/db_config.h	Fri Nov  5 09:59:06 2004
@@ -98,6 +98,9 @@
    db_crc32b, 			/* "crc32b",  */
    db_attr,                     /* attributes */
    db_acl,                      /* access control list */
+   db_bsize,                    /* "bsize"    */
+   db_rdev,                     /* "rdev"     */
+   db_dev,                      /* "dev"      */
    db_checkmask,                /* "checkmask"*/
    db_unknown } DB_FIELD; 	/* "unknown"  */
 
@@ -131,8 +134,12 @@
 #define DB_GOST     (1<<18)	/* "gost",    */
 #define DB_CRC32B   (1<<19)	/* "crc32b",  */
 #define DB_ACL      (1<<20)     /* "acl"      */
-#define DB_CHECKMASK (1<<21)    /* "checkmask"*/
-#define DB_SIZEG     (1<<22)	/* "unknown"  */
+#define DB_BSIZE    (1<<21)     /* "bsize"    */
+#define DB_RDEV     (1<<22)     /* "rdev"     */
+#define DB_DEV      (1<<23)     /* "dev"      */
+
+#define DB_CHECKMASK (1<<24)    /* "checkmask"*/
+#define DB_SIZEG     (1<<25)	/* "unknown"  */
 
 
 #define DB_HASHES    (DB_MD5|DB_SHA1|DB_RMD160|DB_TIGER|DB_CRC32|DB_HAVAL| \
@@ -161,6 +168,9 @@
    "crc32b",
    "attr",
    "acl",
+   "bsize",
+   "rdev",
+   "dev",
    "checkmask",
    "unknown" } ; 
 
@@ -187,6 +197,9 @@
    db_crc32b, 		/* "crc32b",  */
    db_attr,             /* attributes */
    db_acl,              /* "acl"      */
+   db_bsize,            /* "bsize"    */
+   db_rdev,             /* "rdev"     */
+   db_dev,              /* "dev"      */
    db_checkmask,	/* "checkmask" */
    db_unknown };	/* "unknown"  */
 
diff -nru aide-CVS-20041102/src/do_md.c aide-CVS-20041102-patched/src/do_md.c
--- aide-CVS-20041102/src/do_md.c	Wed Apr 28 11:49:09 2004
+++ aide-CVS-20041102-patched/src/do_md.c	Fri Nov  5 10:05:00 2004
@@ -93,24 +93,20 @@
   if (f1==NULL || f2==NULL) {
     return RETFAIL;
   }
-#define stat_cmp_helper(n) (f1->n==f2->n)
+#define stat_cmp_helper(n,n2) ((f1->n==f2->n)*n2)
 
-  if (stat_cmp_helper(st_ino)&&
-      stat_cmp_helper(st_mode)&&
-      stat_cmp_helper(st_nlink)&&
-      stat_cmp_helper(st_size)&&
-      stat_cmp_helper(st_mtime)&&
-      stat_cmp_helper(st_ctime)&&
-      stat_cmp_helper(st_blocks)&&
-      stat_cmp_helper(st_blksize)&&
-      stat_cmp_helper(st_rdev)&&
-      stat_cmp_helper(st_gid)&&
-      stat_cmp_helper(st_uid)&&
-      stat_cmp_helper(st_nlink)&&
-      stat_cmp_helper(st_dev)) {
-    return RETOK;
-  }
-  return RETFAIL;
+  return (stat_cmp_helper(st_ino,DB_INODE)&
+	  stat_cmp_helper(st_mode,DB_PERM)&
+	  stat_cmp_helper(st_nlink,DB_LNKCOUNT)&
+	  stat_cmp_helper(st_size,DB_SIZE)&
+	  stat_cmp_helper(st_mtime,DB_MTIME)&
+	  stat_cmp_helper(st_ctime,DB_CTIME)&
+	  stat_cmp_helper(st_blocks,DB_BCOUNT)&
+	  stat_cmp_helper(st_blksize,DB_BSIZE)&
+	  stat_cmp_helper(st_rdev,DB_RDEV)&
+	  stat_cmp_helper(st_gid,DB_GID)&
+	  stat_cmp_helper(st_uid,DB_UID)&
+	  stat_cmp_helper(st_dev,DB_DEV));
 }
 
 
@@ -124,6 +120,7 @@
    */
   struct AIDE_STAT_TYPE fs;
   int sres=0;
+  int stat_diff;
 #ifdef _PARAMETER_CHECK_
   if (line==NULL) {
     abort();
@@ -151,7 +148,7 @@
   
   sres=AIDE_FSTAT_FUNC(filedes,&fs);
   
-  if (stat_cmp(&fs,old_fs)==RETOK) {
+  if ((stat_diff=stat_cmp(&fs,old_fs))==RETOK) {
     /*
       Now we have a 'valid' filehandle to read from a file.
      */
@@ -222,12 +219,19 @@
       return;
     }
   } else {
+    unsigned i;
     /*
       Something just wasn't correct, so no hash calculated.
     */
     
     error(5,"File %s was changed so that hash cannot be calculated for it\n"
 	  ,line->filename);
+
+    for(i=0;i<db_unknown;i++) {
+      if (((1<<i)&stat_diff)!=0) {
+	error(6,"Attribute %s has been changed\n",db_names[i]);
+      }
+    }
     
     no_hash(line);
     close(filedes);


More information about the Aide mailing list