From: VMware, Inc <> Date: Thu, 24 Feb 2011 21:25:21 +0000 (-0800) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2011.02.23-368700~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd22234abf8255cac6db95fe8358d3fef3035930;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . VIX: properly check file permissions before overwriting. . changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/include/vm_basic_asm_x86_64.h b/open-vm-tools/lib/include/vm_basic_asm_x86_64.h index 194ae3e78..64d95122c 100644 --- a/open-vm-tools/lib/include/vm_basic_asm_x86_64.h +++ b/open-vm-tools/lib/include/vm_basic_asm_x86_64.h @@ -71,6 +71,25 @@ uint64 __shiftright128(uint64 lowPart, uint64 highPart, uint8 shift); #endif // _MSC_VER +/* + * GET_CURRENT_RIP + * + * Return an approximation of the current instruction pointer. For example for a + * function call + * foo.c + * L123: Foo(GET_CURRENT_RIP()) + * + * The return value from GET_CURRENT_RIP will point a debugger to L123. + */ +#if defined(__GNUC__) +#define GET_CURRENT_RIP() ({ \ + void *__rip; \ + asm("lea 0(%%rip), %0;\n\t" \ + : "=r" (__rip)); \ + __rip; \ +}) +#endif + /* * FXSAVE/FXRSTOR * save/restore SIMD/MMX fpu state diff --git a/open-vm-tools/modules/linux/shared/compat_netdevice.h b/open-vm-tools/modules/linux/shared/compat_netdevice.h index d29fcbdef..7a563048d 100644 --- a/open-vm-tools/modules/linux/shared/compat_netdevice.h +++ b/open-vm-tools/modules/linux/shared/compat_netdevice.h @@ -340,4 +340,10 @@ static inline int compat_unregister_netdevice_notifier(struct notifier_block *nb # define compat_netif_tx_unlock(dev) do {} while (0) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +# define COMPAT_VLAN_GROUP_ARRAY_LEN VLAN_N_VID +#else +# define COMPAT_VLAN_GROUP_ARRAY_LEN VLAN_GROUP_ARRAY_LEN +#endif + #endif /* __COMPAT_NETDEVICE_H__ */ diff --git a/open-vm-tools/modules/shared/vmxnet/vmnet_def.h b/open-vm-tools/modules/shared/vmxnet/vmnet_def.h index 376b73223..6e44aea2b 100644 --- a/open-vm-tools/modules/shared/vmxnet/vmnet_def.h +++ b/open-vm-tools/modules/shared/vmxnet/vmnet_def.h @@ -49,6 +49,8 @@ #include "includeCheck.h" #define VMNET_NAME_BUFFER_LEN 128 /* Increased for i18n. */ +#define VMNET_COAL_SCHEME_NAME_LEN 16 + /* * capabilities - not all of these are implemented in the virtual HW diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c index 837dbb923..6dff451c8 100644 --- a/open-vm-tools/services/plugins/vix/vixTools.c +++ b/open-vm-tools/services/plugins/vix/vixTools.c @@ -1368,6 +1368,11 @@ VixToolsStartProgramImpl(const char *requestName, // IN #endif GSource *timer; + /* + * Initialize this here so we can call free on its member variables in abort + */ + memset(&procArgs, 0, sizeof procArgs); + if (NULL != pid) { *pid = (int64) -1; } @@ -1479,7 +1484,6 @@ VixToolsStartProgramImpl(const char *requestName, // IN */ asyncState = Util_SafeCalloc(1, sizeof *asyncState); - memset(&procArgs, 0, sizeof procArgs); #if defined(_WIN32) if (NULL != envVars) { err = VixToolsEnvironToEnvBlock(envVars, &envBlock); @@ -4029,9 +4033,9 @@ VixToolsInitiateFileTransferToGuest(VixCommandRequestHeader *requestMsg) // IN #if defined(_WIN32) int fd = -1; char *tempFilePath = NULL; -#else - FileIOResult res; + static char *tempFileBaseName = "vmware"; #endif + FileIOResult res; VixCommandInitiateFileTransferToGuestRequest *commandRequest; VMAutomationRequestParser parser; @@ -4099,11 +4103,29 @@ VixToolsInitiateFileTransferToGuest(VixCommandRequestHeader *requestMsg) // IN if (File_Exists(guestPathName)) { if (File_IsDirectory(guestPathName)) { err = VIX_E_NOT_A_FILE; - goto abort; } else if (!overwrite) { err = VIX_E_FILE_ALREADY_EXISTS; - goto abort; + } else { + /* + * If the file exists and overwrite flag is true, then check + * if the file is writable. If not, return a proper error. + */ + res = FileIO_Access(guestPathName, FILEIO_ACCESS_WRITE); + if (FILEIO_SUCCESS != res) { + /* + * On Linux guests, FileIO_Access sets the proper errno + * on failure. On Windows guests, last errno is not + * set when FileIO_Access fails. So, we cannot use + * FoundryToolsDaemon_TranslateSystemErr() to translate the + * error. To maintain consistency for all the guests, + * return an explicit VIX_E_FILE_ACCESS_ERROR. + */ + err = VIX_E_FILE_ACCESS_ERROR; + Debug("Unable to get access permissions for the file: %s\n", + guestPathName); + } } + goto abort; } File_GetPathName(guestPathName, &dirName, &baseName); @@ -4145,10 +4167,11 @@ VixToolsInitiateFileTransferToGuest(VixCommandRequestHeader *requestMsg) // IN * create the temporary file with the exact specified filename. Any name * would be fine. */ - fd = File_MakeTempEx(dirName, baseName, &tempFilePath); + fd = File_MakeTempEx(dirName, tempFileBaseName, &tempFilePath); if (fd > 0) { close(fd); + File_UnlinkNoFollow(tempFilePath); } else { /* * File_MakeTempEx() function internally uses Posix variant @@ -4172,7 +4195,15 @@ VixToolsInitiateFileTransferToGuest(VixCommandRequestHeader *requestMsg) // IN res = FileIO_Access(dirName, FILEIO_ACCESS_WRITE); if (FILEIO_SUCCESS != res) { - err = FoundryToolsDaemon_TranslateSystemErr(); + /* + * On Linux guests, FileIO_Access sets the proper errno + * on failure. On Windows guests, last errno is not + * set when FileIO_Access fails. So, we cannot use + * FoundryToolsDaemon_TranslateSystemErr() to translate the + * error. To maintain consistency for all the guests, + * return an explicit VIX_E_FILE_ACCESS_ERROR. + */ + err = VIX_E_FILE_ACCESS_ERROR; Debug("Unable to get access permissions for the directory: %s\n", dirName); goto abort;