*** src/cfagent.c_ORIG 2003-10-18 07:18:46.000000000 -0400 --- src/cfagent.c 2003-11-25 15:34:54.000000000 -0500 *************** *** 245,250 **** --- 245,257 ---- snprintf(VBUFF,bufsize,"cfengine_%s",CanonifyName(VERSION)); AddClassToHeap(VBUFF); + if (stat("/etc/fedora-release",&statbuf) != -1) + { + Verbose("This appears to be a fedora system.\n"); + AddClassToHeap("fedora"); + linux_fedora_version(); + } + if (stat("/etc/redhat-release",&statbuf) != -1) { Verbose("This appears to be a redhat system.\n"); *** src/cfservd.c_ORIG 2003-10-18 04:41:30.000000000 -0400 --- src/cfservd.c 2003-11-25 15:35:10.000000000 -0500 *************** *** 256,261 **** --- 256,268 ---- GetNameInfo(); + if (stat("/etc/fedora-release",&statbuf) != -1) + { + Verbose("This appears to be a fedora system.\n"); + AddClassToHeap("fedora"); + linux_fedora_version(); + } + if (stat("/etc/redhat-release",&statbuf) != -1) { Verbose("This appears to be a redhat system.\n"); *** src/misc.c_ORIG 2003-10-11 13:14:12.000000000 -0400 --- src/misc.c 2003-11-25 15:40:12.000000000 -0500 *************** *** 823,828 **** --- 823,909 ---- /*********************************************************************************/ + int linux_fedora_version(void) + { + #define FEDORA_ID "Fedora Core" + + #define RELEASE_FLAG "release " + + /* We are looking for one of the following strings... + * + * Fedora Core release 1 (Yarrow) + */ + + #define FEDORA_REL_FILENAME "/etc/fedora-release" + + FILE *fp; + + /* The full string read in from fedora-release */ + char relstring[maxvarsize]; + char classbuf[maxvarsize]; + + /* Fedora */ + char *vendor=""; + /* Where the numerical release will be found */ + char *release=NULL; + + int major = -1; + char strmajor[maxvarsize]; + + /* Grab the first line from the file and then close it. */ + if ((fp = fopen(FEDORA_REL_FILENAME,"r")) == NULL) + { + return 1; + } + fgets(relstring, sizeof(relstring), fp); + fclose(fp); + + Verbose("Looking for fedora core linux info...\n"); + + /* First, try to grok the vendor */ + if(!strncmp(relstring, FEDORA_ID, strlen(FEDORA_ID))) + { + vendor = "fedora"; + } + else + { + Verbose("Could not identify OS distro from %s\n", FEDORA_REL_FILENAME); + return 2; + } + + /* Now, grok the release. We assume that all the strings will + * have the word 'release' before the numerical release. + */ + release = strstr(relstring, RELEASE_FLAG); + if(release == NULL) + { + Verbose("Could not find a numeric OS release in %s\n", + FEDORA_REL_FILENAME); + return 2; + } + else + { + release += strlen(RELEASE_FLAG); + if (sscanf(release, "%d", &major) == 1) + { + sprintf(strmajor, "%d", major); + }; + } + + if(major != -1 && vendor != "") + { + classbuf[0] = '\0'; + strcat(classbuf, vendor); + AddClassToHeap(classbuf); + strcat(classbuf, "_"); + strcat(classbuf, strmajor); + AddClassToHeap(classbuf); + } + return 0; + } + + /*********************************************************************************/ + int linux_redhat_version(void) { #define REDHAT_ID "Red Hat Linux" *** src/prototypes.h_ORIG 2003-10-18 06:00:42.000000000 -0400 --- src/prototypes.h 2003-11-25 15:34:12.000000000 -0500 *************** *** 668,673 **** --- 668,674 ---- /* misc.c */ + int linux_fedora_version ARGLIST((void)); int linux_redhat_version ARGLIST((void)); int linux_suse_version ARGLIST((void)); int debian_version ARGLIST((void));