Advertisement
Guest User

cfengine_3_4_0_virtuozzo

a guest
Nov 28th, 2012
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.51 KB | None | 0 0
  1. diff -Naur cfengine-3.4.0.ls/src/cf3.defs.h cfengine-3.4.0/src/cf3.defs.h
  2. --- cfengine-3.4.0.ls/src/cf3.defs.h    2012-11-26 11:13:20.000000000 +0000
  3. +++ cfengine-3.4.0/src/cf3.defs.h       2012-11-28 14:23:04.000000000 +0000
  4. @@ -322,6 +322,7 @@
  5.  enum classes
  6.  {
  7.      hard_class_unknown,
  8. +    aaa_virtuozzo,
  9.      hp,
  10.      aix,
  11.      linuxx,
  12. diff -Naur cfengine-3.4.0.ls/src/classes.c cfengine-3.4.0/src/classes.c
  13. --- cfengine-3.4.0.ls/src/classes.c     2012-11-26 11:13:20.000000000 +0000
  14. +++ cfengine-3.4.0/src/classes.c        2012-11-28 14:24:57.000000000 +0000
  15. @@ -27,6 +27,7 @@
  16.  const char *CLASSTEXT[HARD_CLASSES_MAX] =
  17.  {
  18.      "<unknown>",
  19. +    "aaa_virtuozzo",
  20.      "hpux",
  21.      "aix",
  22.      "linux",
  23. @@ -48,6 +49,7 @@
  24.  const char *VPSCOMM[HARD_CLASSES_MAX] =
  25.  {
  26.      "",
  27. +    "/bin/vzps -E 0",           /* virtuozzo */
  28.      "/bin/ps",                  /* hpux */
  29.      "/bin/ps",                  /* aix */
  30.      "/bin/ps",                  /* linux */
  31. @@ -72,6 +74,7 @@
  32.  const char *VPSOPTS[HARD_CLASSES_MAX] =
  33.  {
  34.      "",
  35. +    "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args",   /* virtuozzo */
  36.      "-ef",                      /* hpux */
  37.      "-N -eo user,pid,ppid,pgid,pcpu,pmem,vsz,ni,stat,st=STIME,time,args",  /* aix */
  38.      "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args",        /* linux */
  39. @@ -93,6 +96,7 @@
  40.  const char *VFSTAB[HARD_CLASSES_MAX] =
  41.  {
  42.      "-",
  43. +    "/etc/fstab",               /* virtuozzo */
  44.      "/etc/fstab",               /* hpux */
  45.      "/etc/filesystems",         /* aix */
  46.      "/etc/fstab",               /* linux */
  47. diff -Naur cfengine-3.4.0.ls/src/sysinfo.c cfengine-3.4.0/src/sysinfo.c
  48. --- cfengine-3.4.0.ls/src/sysinfo.c     2012-11-26 11:13:20.000000000 +0000
  49. +++ cfengine-3.4.0/src/sysinfo.c        2012-11-28 14:22:29.000000000 +0000
  50. @@ -49,6 +49,7 @@
  51.  static int Linux_Mandrake_Version(void);
  52.  static int Linux_Mandriva_Version(void);
  53.  static int Linux_Mandriva_Version_Real(char *filename, char *relstring, char *vendor);
  54. +static int Linux_Virtuozzo_Version(void);
  55.  static int VM_Version(void);
  56.  static int Xen_Domain(void);
  57.  
  58. @@ -66,6 +67,7 @@
  59.  static const char *CLASSATTRIBUTES[HARD_CLASSES_MAX][3] =
  60.  {
  61.      {"-", "-", "-"},            /* as appear here are matched. The fields are sysname and machine */
  62. +    {"aaa_virtuozzo", ".*", ".*"}, /* virtuozzo */
  63.      {"hp-ux", ".*", ".*"},      /* hpux */
  64.      {"aix", ".*", ".*"},        /* aix */
  65.      {"linux", ".*", ".*"},      /* linux */
  66. @@ -87,6 +89,7 @@
  67.  static const char *VRESOLVCONF[HARD_CLASSES_MAX] =
  68.  {
  69.      "-",
  70. +    "/etc/resolv.conf",         /* virtuozzo */
  71.      "/etc/resolv.conf",         /* hpux */
  72.      "/etc/resolv.conf",         /* aix */
  73.      "/etc/resolv.conf",         /* linux */
  74. @@ -108,6 +111,7 @@
  75.  static const char *VMAILDIR[HARD_CLASSES_MAX] =
  76.  {
  77.      "-",
  78. +    "/var/spool/mail",          /* virtuozzo */
  79.      "/var/mail",                /* hpux */
  80.      "/var/spool/mail",          /* aix */
  81.      "/var/spool/mail",          /* linux */
  82. @@ -129,6 +133,7 @@
  83.  static const char *VEXPORTS[HARD_CLASSES_MAX] =
  84.  {
  85.      "-",
  86. +    "/etc/exports",             /* virtuozzo */
  87.      "/etc/exports",             /* hpux */
  88.      "/etc/exports",             /* aix */
  89.      "/etc/exports",             /* linux */
  90. @@ -791,6 +796,11 @@
  91.          Linux_Suse_Version();
  92.      }
  93.  
  94. +    if (cfstat("/etc/virtuozzo-release", &statbuf) != -1)
  95. +    {
  96. +        Linux_Virtuozzo_Version();
  97. +    }
  98. +
  99.  # define SLACKWARE_ANCIENT_VERSION_FILENAME "/etc/slackware-release"
  100.  # define SLACKWARE_VERSION_FILENAME "/etc/slackware-version"
  101.      if (cfstat(SLACKWARE_VERSION_FILENAME, &statbuf) != -1)
  102. @@ -1868,6 +1878,148 @@
  103.      return 0;
  104.  }
  105.  
  106. +static int Linux_Virtuozzo_Version(void)
  107. +{
  108. +#define VIRTUOZZO_ID "Virtuozzo"
  109. +
  110. +/* We are looking for one of the following strings...
  111. + *
  112. + * Virtuozzo
  113. + *
  114. + */
  115. +
  116. +#define VIRTUOZZO_REL_FILENAME "/etc/virtuozzo-release"
  117. +
  118. +/* The full string read in from virtuozzo-release */
  119. +    char relstring[CF_MAXVARSIZE];
  120. +    char classbuf[CF_MAXVARSIZE];
  121. +
  122. +/* Red Hat, Mandrake */
  123. +    char *vendor = "";
  124. +
  125. +/* as (Advanced Server, Enterprise) */
  126. +    char *edition = "";
  127. +
  128. +/* Where the numerical release will be found */
  129. +    char *release = NULL;
  130. +    int i;
  131. +    int major = -1;
  132. +    char strmajor[CF_MAXVARSIZE];
  133. +    int minor = -1;
  134. +    char strminor[CF_MAXVARSIZE];
  135. +
  136. +    CfOut(cf_verbose, "", "This appears to be a Virtuozzo system.\n");
  137. +    HardClass("aaa_virtuozzo");
  138. +
  139. +/* Grab the first line from the file and then close it. */
  140. +
  141. +    if (!ReadLine(VIRTUOZZO_REL_FILENAME, relstring, sizeof(relstring)))
  142. +    {
  143. +        return 1;
  144. +    }
  145. +
  146. +    CfOut(cf_verbose, "", "Looking for virtuozzo linux info in \"%s\"\n", relstring);
  147. +
  148. +/* First, try to grok the vendor and the edition (if any) */
  149. +    if (!strncmp(relstring, VIRTUOZZO_ID, strlen(VIRTUOZZO_ID)))
  150. +    {
  151. +        vendor = "aaa_virtuozzo";
  152. +    }
  153. +
  154. +    else
  155. +    {
  156. +        CfOut(cf_verbose, "", "Could not identify OS distro from %s\n", VIRTUOZZO_REL_FILENAME);
  157. +        return 2;
  158. +    }
  159. +
  160. +/* Now, grok the release.  For AS, we neglect the AS at the end of the
  161. + * numerical release because we already figured out that it *is* AS
  162. + * from the infomation above.  We assume that all the strings will
  163. + * have the word 'release' before the numerical release.
  164. + */
  165. +
  166. +/* Convert relstring to lowercase so that vendors like
  167. +   Scientific Linux don't fall through the cracks.
  168. +   */
  169. +
  170. +    for (i = 0; i < strlen(relstring); i++)
  171. +    {
  172. +        relstring[i] = tolower(relstring[i]);
  173. +    }
  174. +
  175. +    release = strstr(relstring, RELEASE_FLAG);
  176. +    if (release == NULL)
  177. +    {
  178. +        CfOut(cf_verbose, "", "Could not find a numeric OS release in %s\n", VIRTUOZZO_REL_FILENAME);
  179. +        return 2;
  180. +    }
  181. +    else
  182. +    {
  183. +        release += strlen(RELEASE_FLAG);
  184. +        if (sscanf(release, "%d.%d", &major, &minor) == 2)
  185. +        {
  186. +            sprintf(strmajor, "%d", major);
  187. +            sprintf(strminor, "%d", minor);
  188. +        }
  189. +        /* red hat 9 is *not* red hat 9.0.
  190. +         * and same thing with RHEL AS 3
  191. +         */
  192. +        else if (sscanf(release, "%d", &major) == 1)
  193. +        {
  194. +            sprintf(strmajor, "%d", major);
  195. +            minor = -2;
  196. +        }
  197. +    }
  198. +
  199. +    if (major != -1 && minor != -1 && (strcmp(vendor, "") != 0))
  200. +    {
  201. +        classbuf[0] = '\0';
  202. +        strcat(classbuf, vendor);
  203. +        HardClass(classbuf);
  204. +        strcat(classbuf, "_");
  205. +
  206. +        if (strcmp(edition, "") != 0)
  207. +        {
  208. +            strcat(classbuf, edition);
  209. +            HardClass(classbuf);
  210. +            strcat(classbuf, "_");
  211. +        }
  212. +
  213. +        strcat(classbuf, strmajor);
  214. +        HardClass(classbuf);
  215. +
  216. +        if (minor != -2)
  217. +        {
  218. +            strcat(classbuf, "_");
  219. +            strcat(classbuf, strminor);
  220. +            HardClass(classbuf);
  221. +        }
  222. +    }
  223. +
  224. +// Now a version without the edition
  225. +
  226. +    if (major != -1 && minor != -1 && (strcmp(vendor, "") != 0))
  227. +    {
  228. +        classbuf[0] = '\0';
  229. +        strcat(classbuf, vendor);
  230. +        HardClass(classbuf);
  231. +        strcat(classbuf, "_");
  232. +
  233. +        strcat(classbuf, strmajor);
  234. +
  235. +        SetFlavour(classbuf);
  236. +
  237. +        if (minor != -2)
  238. +        {
  239. +            strcat(classbuf, "_");
  240. +            strcat(classbuf, strminor);
  241. +            HardClass(classbuf);
  242. +        }
  243. +    }
  244. +
  245. +    return 0;
  246. +}
  247. +
  248.  /******************************************************************/
  249.  
  250.  static int VM_Version(void)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement