[Aide] hostname in aide.conf?

Virolainen Pablo pablo at cs.tut.fi
Mon Jan 3 21:00:58 EET 2005


On Fri, 17 Dec 2004, leam wrote:

> New to aide, have a questions already.  :)
>
> I have several machines I want to use Aide with. My plan, so far, is to
> have an nfs share mounted read-only with the binaries and original
> databases to compare to. What I'm trying to figure out is how to insert
> the hostname into the database=:@@ line so that each host compares to
> its own database.
>
> I see that the aide.conf file uses @@ as the variable prefix. Is there
> a way in the config file to:
>
>   @@define HOST `hostname`
>
> Or something like that? So the database line is:
>
>   database=files:@@{FILELOCATION}/aide.db.@@{HOST}
>
> ciao!

Something like
<example>
@@ifhost ipi.fi
database=files:/aide_databases/ipi.fi.aide.db
@@endif
</example>
does the trick. Yes, I know that this isn't that usefull. But patch will
give you @@{HOSTNAME}

<aide.hostname.patch>
--- aide/src/aide.c     Mon Jan  3 20:58:35 2005
+++ aide/src/aide.c.new Mon Jan  3 20:57:04 2005
@@ -50,6 +50,10 @@
 /*for locale support*/
 db_config* conf;

+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif
+
 void usage(int exitvalue)
 {
   fprintf(stderr,
@@ -248,8 +252,21 @@
 {
   char* urlstr=INITIALERRORSTO;
   url_t* u=NULL;
+  char*
s=(char*)malloc(sizeof(char)*MAXHOSTNAMELEN+1);

+  /*
+    Set up the hostname
+  */
   conf=(db_config*)malloc(sizeof(db_config));
+  conf->defsyms=NULL;
+
+  if (gethostname(s,MAXHOSTNAMELEN)==-1) {
+    error(0,_("Couldn't get hostname"));
+    free(s);
+  } else {
+    s=(char*)realloc((void*)s,strlen(s)+1);
+    do_define("HOSTNAME",s);
+  }

   /* Setting some defaults */
   conf->report_db=0;
@@ -308,7 +325,6 @@
   conf->equrxlst=NULL;
   conf->negrxlst=NULL;

-  conf->defsyms=NULL;
   conf->groupsyms=NULL;

   conf->start_time=time(&(conf->start_time));
</aide.hostname.patch>

Duke NEMO / C.O.M.A
alias pablo the pallo virolainen
-------------- next part --------------
--- aide/src/aide.c	Mon Jan  3 20:58:35 2005
+++ aide/src/aide.c.new	Mon Jan  3 20:57:04 2005
@@ -50,6 +50,10 @@
 /*for locale support*/
 db_config* conf;
 
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif
+
 void usage(int exitvalue)
 {
   fprintf(stderr, 
@@ -248,8 +252,21 @@
 {
   char* urlstr=INITIALERRORSTO;
   url_t* u=NULL;
+  char* s=(char*)malloc(sizeof(char)*MAXHOSTNAMELEN+1);
 
+  /*
+    Set up the hostname
+  */
   conf=(db_config*)malloc(sizeof(db_config));
+  conf->defsyms=NULL;
+  
+  if (gethostname(s,MAXHOSTNAMELEN)==-1) {
+    error(0,_("Couldn't get hostname"));
+    free(s);
+  } else {
+    s=(char*)realloc((void*)s,strlen(s)+1);
+    do_define("HOSTNAME",s);
+  }
   
   /* Setting some defaults */
   conf->report_db=0;  
@@ -308,7 +325,6 @@
   conf->equrxlst=NULL;
   conf->negrxlst=NULL;
 
-  conf->defsyms=NULL;
   conf->groupsyms=NULL;
 
   conf->start_time=time(&(conf->start_time));


More information about the Aide mailing list