[Aide-commits] aide branch, master, updated. 230bce65b0a2163d44d567ae54e2ff3ab374c43e
Brought to you by:
hvhaugwitz,
rvdb
From: Hannes v. H. <hvh...@us...> - 2010-06-10 19:08:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "aide". The branch, master has been updated via 230bce65b0a2163d44d567ae54e2ff3ab374c43e (commit) from f43fbf3bff2358641302c7056dacad0e562a0f02 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 230bce65b0a2163d44d567ae54e2ff3ab374c43e Author: Hannes von Haugwitz <ha...@vo...> Date: Thu Jun 10 14:10:53 2010 +0200 Added file type change detection support diff --git a/ChangeLog b/ChangeLog index 0c02404..419c353 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-06-10 Hannes von Haugwitz <ha...@vo...> + * Added file type change detection support + 2010-06-09 Hannes von Haugwitz <ha...@vo...> * Fixed handling of size and growing size bits diff --git a/NEWS b/NEWS index e2937c3..845d59a 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ========================================================= Version UNRELEASED + * Added support for ftype attribute * Bug fixes Version 0.14.2 diff --git a/contrib/aide-attributes.sh b/contrib/aide-attributes.sh index d72dc3c..13266be 100644 --- a/contrib/aide-attributes.sh +++ b/contrib/aide-attributes.sh @@ -24,7 +24,7 @@ attributes=( "filename" "linkname" "perm" "uid" "gid" "size" "atime" \ "rmd160" "tiger" "crc32" "haval" "gost" "crc32b" "attr" \ "acl" "bsize" "rdev" "dev" "checkmask" "growingsize" "checkinode" \ "allownewfile" "allowrmfile" "sha256" "sha512" "selinux" \ - "xattrs" "whirlpool" ) + "xattrs" "whirlpool" "ftype" ) NAME="aide-attributes" diff --git a/doc/aide.conf.5.in b/doc/aide.conf.5.in index 91acd9f..a164f2e 100644 --- a/doc/aide.conf.5.in +++ b/doc/aide.conf.5.in @@ -68,7 +68,7 @@ The general format is like the string YlZbpugamcinCAXS, where Y is replaced by the file-type (\fBf\fP for a regular file, \fBd\fP for a directory, \fBL\fP for a symbolic link, \fBD\fP for a character device, \fBB\fP for a block device, \fBF\fP for a FIFO, \fBs\fP for a unix -socket, \fB|\fP for a Solaris door and \fB?\fP otherwise). +socket, \fB|\fP for a Solaris door, \fB!\fP if file type has changed and \fB?\fP otherwise). The Z is replaced as follows: A \fB=\fP means that the size has not changed, a \fB<\fP reports a shrinked size and a \fB>\fP reports a grown size. @@ -233,6 +233,7 @@ Input is read from filedescriptor \fBnumber\fR or output is written to .IP "And also the following if you have mhash support enabled" .IP "gost: gost checksum" .IP "whirlpool: whirlpool checksum" +.IP "ftype: file type" .IP "The followingg is available when explicitly enabled using configure" .IP "acl: access control list" .IP "selinux: selinux attributes" diff --git a/include/db_config.h b/include/db_config.h index 010ffc9..8d54146 100644 --- a/include/db_config.h +++ b/include/db_config.h @@ -203,6 +203,7 @@ typedef enum { #define DB_SELINUX (1LLU<<32) /* "selinux", */ #define DB_XATTRS (1LLU<<33) /* "xattrs", */ #define DB_WHIRLPOOL (1LLU<<34) /* "whirlpool", */ +#define DB_FTYPE (1LLU<<35) /* "file type", */ #define DB_HASHES (DB_MD5|DB_SHA1|DB_RMD160|DB_TIGER|DB_CRC32|DB_HAVAL| \ DB_GOST|DB_CRC32B|DB_SHA256|DB_SHA512|DB_WHIRLPOOL) diff --git a/src/aide.c b/src/aide.c index f95a490..deb7ae0 100644 --- a/src/aide.c +++ b/src/aide.c @@ -376,6 +376,7 @@ void setdefaults_before_config() do_groupdef("whirlpool",DB_WHIRLPOOL); #endif #endif + do_groupdef("ftype",DB_FTYPE); p=0LLU; #if defined(WITH_MHASH) || defined(WITH_GCRYPT) diff --git a/src/compare_db.c b/src/compare_db.c index 14a5a72..f2cd41b 100644 --- a/src/compare_db.c +++ b/src/compare_db.c @@ -266,6 +266,24 @@ static int compare_str(const char *s1, const char *s2) return RETOK; } +char get_file_type_char(mode_t mode) { + if (S_ISREG(mode)) return 'f'; + else if(S_ISDIR(mode)) return 'd'; +#ifdef S_ISFIFO + else if (S_ISFIFO(mode)) return 'F'; +#endif + else if (S_ISLNK(mode)) return 'L'; + else if (S_ISBLK(mode)) return 'B'; + else if (S_ISCHR(mode)) return 'D'; +#ifdef S_ISSOCK + else if (S_ISSOCK(mode)) return 's'; +#endif +#ifdef S_ISDOOR + else if (S_ISDOOR(mode)) return '|'; +#endif + else return '?'; +} + /* We assume @@ -296,6 +314,12 @@ DB_ATTR_TYPE compare_dbline(db_line* l1,db_line* l2,DB_ATTR_TYPE ignorelist) DB_ATTR_TYPE ret=0; + if (!(DB_FTYPE&ignorelist)) { + if ((DB_FTYPE&l1->attr && DB_FTYPE&l2->attr) && get_file_type_char(l1->perm)!=get_file_type_char(l2->perm)) { + ret|=DB_FTYPE; + } + } + if (!(DB_LINKNAME&ignorelist)) { if(compare_str(l1->linkname, l2->linkname)){ ret|=DB_LINKNAME; @@ -626,24 +650,6 @@ void print_string_changes(const char* name, const char* old, const char* new, in } } -char get_file_type_char(mode_t mode) { - if (S_ISREG(mode)) return 'f'; - else if(S_ISDIR(mode)) return 'd'; -#ifdef S_ISFIFO - else if (S_ISFIFO(mode)) return 'F'; -#endif - else if (S_ISLNK(mode)) return 'L'; - else if (S_ISBLK(mode)) return 'B'; - else if (S_ISCHR(mode)) return 'D'; -#ifdef S_ISSOCK - else if (S_ISSOCK(mode)) return 's'; -#endif -#ifdef S_ISDOOR - else if (S_ISDOOR(mode)) return '|'; -#endif - else return '?'; -} - char* get_file_type_string(mode_t mode) { switch (get_file_type_char(mode)) { case 'f': return "File"; @@ -750,7 +756,9 @@ void print_changed_line(db_line* old,db_line* new, DB_ATTR_TYPE ignorelist) { if(conf->summarize_changes==1) { char summary[]=" "; - summary[0]=get_file_type_char(new->perm); + summary[0]= ((!(DB_FTYPE&ignorelist)) && + (((DB_FTYPE&old->attr && DB_FTYPE&new->attr) && + get_file_type_char(old->perm)!=get_file_type_char(new->perm)))) ? '!' : get_file_type_char(new->perm); easy_compare_char(DB_LINKNAME,str_has_changed(old->linkname,new->linkname),'l',1); summary[2]=get_size_char(ignorelist, old, new); easy_char(DB_BCOUNT,bcount,'b',3); @@ -867,7 +875,11 @@ void print_dbline_changes(db_line* old,db_line* new, forced_attrs&=new->attr; error(2,"\n%s: %s\n",get_file_type_string(new->perm),new->filename); - + + 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)) { + 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)); + } + if(!(DB_LINKNAME&ignorelist)){ print_str_changes(old->linkname,new->linkname, "Lname"); } ----------------------------------------------------------------------- Summary of changes: ChangeLog | 3 ++ NEWS | 1 + contrib/aide-attributes.sh | 2 +- doc/aide.conf.5.in | 3 +- include/db_config.h | 1 + src/aide.c | 1 + src/compare_db.c | 52 +++++++++++++++++++++++++++----------------- 7 files changed, 41 insertions(+), 22 deletions(-) hooks/post-receive -- aide |