--- cfengine2-2.0.3.orig/src/cfagent.c +++ cfengine2-2.0.3/src/cfagent.c @@ -59,6 +59,7 @@ void GetEnvironment ARGLIST((void)); int NothingLeftToDo ARGLIST((void)); int linux_redhat_version ARGLIST((void)); +int debian_version ARGLIST((void)); /*******************************************************************/ /* Level 0 : Main */ @@ -256,6 +257,7 @@ { Verbose("\nThis appears to be a debian system.\n"); AddClassToHeap("debian"); + debian_version(); } /* Note we need to fix the options since the argv mechanism doesn't */ @@ -1870,7 +1898,8 @@ /* A few sanity checks */ if (strlen(fmt1) >= FMT_SIZ || strlen(fmt2) >= FMT_SIZ ) { - Verbose("Your %s is corrupted, either one of it's first words is longer than %i chars\n", RH_REL_FILENAME, FMT_SIZ); + Verbose("Your %s is corrupted, either one of it's first words is longer than %i chars\n", RH_REL_FILENAME, FMT_SIZ); + fclose(fp); return 2; } @@ -1902,5 +1931,40 @@ return 0; } + +int debian_version(void) +{ +#define DEBIAN_VERSION_FILENAME "/etc/debian_version" +int major = -1; +int release = -1; +char classname[maxvarsize] = ""; +FILE *fp; + +if ((fp = fopen(DEBIAN_VERSION_FILENAME,"r")) == NULL) + { + return 1; + } + +Verbose("Looking for Debian version...\n"); +switch (fscanf(fp, "%d.%d", &major, &release)) + { + case 2: + Verbose("This appears to be a Debian %u system..", major); + snprintf(classname, maxvarsize, "debian_%u", major); + AddClassToHeap(classname); + /* Fall-through */ + case 1: + Verbose("This appears to be a Debian %u.%u system..", major, release); + snprintf(classname, maxvarsize, "debian_%u_%u", major, release); + AddClassToHeap(classname); + break; + case 0: + Verbose("No Debian version number found."); + fclose(fp); + return 2; + } +fclose(fp); +return 0; +} /* EOF */