~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to services/plugins/guestInfo/guestInfoServer.c

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING);
67
67
#endif
68
68
 
69
 
MY_ASSERTS(GI_SIZE_ASSERTS,
70
 
           ASSERT_ON_COMPILE(GUESTINFO_MAX_VALUE_SIZE >= MAX_VALUE_LEN);
71
 
)
72
 
 
73
69
/**
74
70
 * Default poll interval is 30s (in milliseconds).
75
71
 */
81
77
 * Stores information about all guest information sent to the vmx.
82
78
 */
83
79
 
84
 
typedef struct _GuestInfoCache{
 
80
typedef struct _GuestInfoCache {
85
81
   /* Stores values of all key-value pairs. */
86
 
   char value[INFO_MAX][GUESTINFO_MAX_VALUE_SIZE];
 
82
   char          *value[INFO_MAX];
87
83
   NicInfoV3     *nicInfo;
88
84
   GuestDiskInfo *diskInfo;
89
85
} GuestInfoCache;
232
228
static gboolean
233
229
GuestInfoGather(gpointer data)
234
230
{
235
 
   char name[GUESTINFO_MAX_VALUE_SIZE];
236
 
   char osNameFull[GUESTINFO_MAX_VALUE_SIZE];
237
 
   char osName[GUESTINFO_MAX_VALUE_SIZE];
 
231
   char name[256];  // Size is derived from the SUS2 specification
 
232
                    // "Host names are limited to 255 bytes"
 
233
   char *osString = NULL;
238
234
   gboolean disableQueryDiskInfo;
239
235
   NicInfoV3 *nicInfo = NULL;
240
236
   GuestDiskInfo *diskInfo = NULL;
257
253
   }
258
254
 
259
255
   /* Gather all the relevant guest information. */
260
 
   if (!Hostinfo_GetOSName(sizeof osNameFull, sizeof osName, osNameFull,
261
 
                           osName)) {
262
 
      g_warning("Failed to get OS info.\n");
263
 
   } else {
264
 
      if (!GuestInfoUpdateVmdb(ctx, INFO_OS_NAME_FULL, osNameFull)) {
265
 
         g_warning("Failed to update VMDB\n");
266
 
      }
267
 
      if (!GuestInfoUpdateVmdb(ctx, INFO_OS_NAME, osName)) {
268
 
         g_warning("Failed to update VMDB\n");
269
 
      }
270
 
   }
 
256
   osString = Hostinfo_GetOSName();
 
257
   if (osString == NULL) {
 
258
      g_warning("Failed to get OS info.\n");
 
259
   } else {
 
260
      if (!GuestInfoUpdateVmdb(ctx, INFO_OS_NAME_FULL, osString)) {
 
261
         g_warning("Failed to update VMDB\n");
 
262
      }
 
263
   }
 
264
   free(osString);
 
265
 
 
266
   osString = Hostinfo_GetOSGuestString();
 
267
   if (osString == NULL) {
 
268
      g_warning("Failed to get OS info.\n");
 
269
   } else {
 
270
      if (!GuestInfoUpdateVmdb(ctx, INFO_OS_NAME, osString)) {
 
271
         g_warning("Failed to update VMDB\n");
 
272
      }
 
273
   }
 
274
   free(osString);
271
275
 
272
276
   disableQueryDiskInfo =
273
277
      g_key_file_get_boolean(ctx->config, CONFGROUPNAME_GUESTINFO,
451
455
       * Above fall-through is intentional.
452
456
       */
453
457
 
454
 
      if (strcmp(gInfoCache.value[infoType], (char *)info) == 0) {
 
458
      if (gInfoCache.value[infoType] != NULL &&
 
459
          strcmp(gInfoCache.value[infoType], (char *)info) == 0) {
455
460
         /* The value has not changed */
456
461
         g_debug("Value unchanged for infotype %d.\n", infoType);
457
462
         break;
463
468
      }
464
469
 
465
470
      /* Update the value in the cache as well. */
466
 
      Str_Strcpy(gInfoCache.value[infoType],
467
 
                 (char *)info,
468
 
                 sizeof gInfoCache.value[infoType]);
 
471
      free(gInfoCache.value[infoType]);
 
472
      gInfoCache.value[infoType] = Util_SafeStrdup((char *) info);
469
473
      break;
470
474
 
471
475
   case INFO_IPADDRESS:
914
918
   int i;
915
919
 
916
920
   for (i = 0; i < INFO_MAX; i++) {
917
 
      gInfoCache.value[i][0] = 0;
 
921
      free(gInfoCache.value[i]);
 
922
      gInfoCache.value[i] = NULL;
918
923
   }
919
924
 
920
925
   GuestInfo_FreeDiskInfo(gInfoCache.diskInfo);