Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur cfengine-3.4.0.ls/src/cf3.defs.h cfengine-3.4.0/src/cf3.defs.h
- --- cfengine-3.4.0.ls/src/cf3.defs.h 2012-11-26 11:13:20.000000000 +0000
- +++ cfengine-3.4.0/src/cf3.defs.h 2012-11-28 14:23:04.000000000 +0000
- @@ -322,6 +322,7 @@
- enum classes
- {
- hard_class_unknown,
- + aaa_virtuozzo,
- hp,
- aix,
- linuxx,
- diff -Naur cfengine-3.4.0.ls/src/classes.c cfengine-3.4.0/src/classes.c
- --- cfengine-3.4.0.ls/src/classes.c 2012-11-26 11:13:20.000000000 +0000
- +++ cfengine-3.4.0/src/classes.c 2012-11-28 14:24:57.000000000 +0000
- @@ -27,6 +27,7 @@
- const char *CLASSTEXT[HARD_CLASSES_MAX] =
- {
- "<unknown>",
- + "aaa_virtuozzo",
- "hpux",
- "aix",
- "linux",
- @@ -48,6 +49,7 @@
- const char *VPSCOMM[HARD_CLASSES_MAX] =
- {
- "",
- + "/bin/vzps -E 0", /* virtuozzo */
- "/bin/ps", /* hpux */
- "/bin/ps", /* aix */
- "/bin/ps", /* linux */
- @@ -72,6 +74,7 @@
- const char *VPSOPTS[HARD_CLASSES_MAX] =
- {
- "",
- + "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args", /* virtuozzo */
- "-ef", /* hpux */
- "-N -eo user,pid,ppid,pgid,pcpu,pmem,vsz,ni,stat,st=STIME,time,args", /* aix */
- "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args", /* linux */
- @@ -93,6 +96,7 @@
- const char *VFSTAB[HARD_CLASSES_MAX] =
- {
- "-",
- + "/etc/fstab", /* virtuozzo */
- "/etc/fstab", /* hpux */
- "/etc/filesystems", /* aix */
- "/etc/fstab", /* linux */
- diff -Naur cfengine-3.4.0.ls/src/sysinfo.c cfengine-3.4.0/src/sysinfo.c
- --- cfengine-3.4.0.ls/src/sysinfo.c 2012-11-26 11:13:20.000000000 +0000
- +++ cfengine-3.4.0/src/sysinfo.c 2012-11-28 14:22:29.000000000 +0000
- @@ -49,6 +49,7 @@
- static int Linux_Mandrake_Version(void);
- static int Linux_Mandriva_Version(void);
- static int Linux_Mandriva_Version_Real(char *filename, char *relstring, char *vendor);
- +static int Linux_Virtuozzo_Version(void);
- static int VM_Version(void);
- static int Xen_Domain(void);
- @@ -66,6 +67,7 @@
- static const char *CLASSATTRIBUTES[HARD_CLASSES_MAX][3] =
- {
- {"-", "-", "-"}, /* as appear here are matched. The fields are sysname and machine */
- + {"aaa_virtuozzo", ".*", ".*"}, /* virtuozzo */
- {"hp-ux", ".*", ".*"}, /* hpux */
- {"aix", ".*", ".*"}, /* aix */
- {"linux", ".*", ".*"}, /* linux */
- @@ -87,6 +89,7 @@
- static const char *VRESOLVCONF[HARD_CLASSES_MAX] =
- {
- "-",
- + "/etc/resolv.conf", /* virtuozzo */
- "/etc/resolv.conf", /* hpux */
- "/etc/resolv.conf", /* aix */
- "/etc/resolv.conf", /* linux */
- @@ -108,6 +111,7 @@
- static const char *VMAILDIR[HARD_CLASSES_MAX] =
- {
- "-",
- + "/var/spool/mail", /* virtuozzo */
- "/var/mail", /* hpux */
- "/var/spool/mail", /* aix */
- "/var/spool/mail", /* linux */
- @@ -129,6 +133,7 @@
- static const char *VEXPORTS[HARD_CLASSES_MAX] =
- {
- "-",
- + "/etc/exports", /* virtuozzo */
- "/etc/exports", /* hpux */
- "/etc/exports", /* aix */
- "/etc/exports", /* linux */
- @@ -791,6 +796,11 @@
- Linux_Suse_Version();
- }
- + if (cfstat("/etc/virtuozzo-release", &statbuf) != -1)
- + {
- + Linux_Virtuozzo_Version();
- + }
- +
- # define SLACKWARE_ANCIENT_VERSION_FILENAME "/etc/slackware-release"
- # define SLACKWARE_VERSION_FILENAME "/etc/slackware-version"
- if (cfstat(SLACKWARE_VERSION_FILENAME, &statbuf) != -1)
- @@ -1868,6 +1878,148 @@
- return 0;
- }
- +static int Linux_Virtuozzo_Version(void)
- +{
- +#define VIRTUOZZO_ID "Virtuozzo"
- +
- +/* We are looking for one of the following strings...
- + *
- + * Virtuozzo
- + *
- + */
- +
- +#define VIRTUOZZO_REL_FILENAME "/etc/virtuozzo-release"
- +
- +/* The full string read in from virtuozzo-release */
- + char relstring[CF_MAXVARSIZE];
- + char classbuf[CF_MAXVARSIZE];
- +
- +/* Red Hat, Mandrake */
- + char *vendor = "";
- +
- +/* as (Advanced Server, Enterprise) */
- + char *edition = "";
- +
- +/* Where the numerical release will be found */
- + char *release = NULL;
- + int i;
- + int major = -1;
- + char strmajor[CF_MAXVARSIZE];
- + int minor = -1;
- + char strminor[CF_MAXVARSIZE];
- +
- + CfOut(cf_verbose, "", "This appears to be a Virtuozzo system.\n");
- + HardClass("aaa_virtuozzo");
- +
- +/* Grab the first line from the file and then close it. */
- +
- + if (!ReadLine(VIRTUOZZO_REL_FILENAME, relstring, sizeof(relstring)))
- + {
- + return 1;
- + }
- +
- + CfOut(cf_verbose, "", "Looking for virtuozzo linux info in \"%s\"\n", relstring);
- +
- +/* First, try to grok the vendor and the edition (if any) */
- + if (!strncmp(relstring, VIRTUOZZO_ID, strlen(VIRTUOZZO_ID)))
- + {
- + vendor = "aaa_virtuozzo";
- + }
- +
- + else
- + {
- + CfOut(cf_verbose, "", "Could not identify OS distro from %s\n", VIRTUOZZO_REL_FILENAME);
- + return 2;
- + }
- +
- +/* Now, grok the release. For AS, we neglect the AS at the end of the
- + * numerical release because we already figured out that it *is* AS
- + * from the infomation above. We assume that all the strings will
- + * have the word 'release' before the numerical release.
- + */
- +
- +/* Convert relstring to lowercase so that vendors like
- + Scientific Linux don't fall through the cracks.
- + */
- +
- + for (i = 0; i < strlen(relstring); i++)
- + {
- + relstring[i] = tolower(relstring[i]);
- + }
- +
- + release = strstr(relstring, RELEASE_FLAG);
- + if (release == NULL)
- + {
- + CfOut(cf_verbose, "", "Could not find a numeric OS release in %s\n", VIRTUOZZO_REL_FILENAME);
- + return 2;
- + }
- + else
- + {
- + release += strlen(RELEASE_FLAG);
- + if (sscanf(release, "%d.%d", &major, &minor) == 2)
- + {
- + sprintf(strmajor, "%d", major);
- + sprintf(strminor, "%d", minor);
- + }
- + /* red hat 9 is *not* red hat 9.0.
- + * and same thing with RHEL AS 3
- + */
- + else if (sscanf(release, "%d", &major) == 1)
- + {
- + sprintf(strmajor, "%d", major);
- + minor = -2;
- + }
- + }
- +
- + if (major != -1 && minor != -1 && (strcmp(vendor, "") != 0))
- + {
- + classbuf[0] = '\0';
- + strcat(classbuf, vendor);
- + HardClass(classbuf);
- + strcat(classbuf, "_");
- +
- + if (strcmp(edition, "") != 0)
- + {
- + strcat(classbuf, edition);
- + HardClass(classbuf);
- + strcat(classbuf, "_");
- + }
- +
- + strcat(classbuf, strmajor);
- + HardClass(classbuf);
- +
- + if (minor != -2)
- + {
- + strcat(classbuf, "_");
- + strcat(classbuf, strminor);
- + HardClass(classbuf);
- + }
- + }
- +
- +// Now a version without the edition
- +
- + if (major != -1 && minor != -1 && (strcmp(vendor, "") != 0))
- + {
- + classbuf[0] = '\0';
- + strcat(classbuf, vendor);
- + HardClass(classbuf);
- + strcat(classbuf, "_");
- +
- + strcat(classbuf, strmajor);
- +
- + SetFlavour(classbuf);
- +
- + if (minor != -2)
- + {
- + strcat(classbuf, "_");
- + strcat(classbuf, strminor);
- + HardClass(classbuf);
- + }
- + }
- +
- + return 0;
- +}
- +
- /******************************************************************/
- static int VM_Version(void)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement