}
// first change group
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+ ret = Id_SetREGid(ppw->pw_gid, ppw->pw_gid);
+#elif defined(__APPLE__)
ret = setregid(ppw->pw_gid, ppw->pw_gid);
#else
ret = setresgid(ppw->pw_gid, ppw->pw_gid, root_gid);
Warning("Failed to set gid for user %s\n", user);
return FALSE;
}
+#ifndef USERWORLD
ret = initgroups(ppw->pw_name, ppw->pw_gid);
if (ret < 0) {
Warning("Failed to initgroups() for user %s\n", user);
goto failure;
}
+#endif
// now user
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+ ret = Id_SetREUid(ppw->pw_uid, ppw->pw_uid);
+#elif defined(__APPLE__)
ret = setreuid(ppw->pw_uid, ppw->pw_uid);
#else
ret = setresuid(ppw->pw_uid, ppw->pw_uid, 0);
}
// first change back user
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+ ret = Id_SetREUid(ppw->pw_uid, ppw->pw_uid);
+#elif defined(__APPLE__)
ret = setreuid(ppw->pw_uid, ppw->pw_uid);
#else
ret = setresuid(ppw->pw_uid, ppw->pw_uid, 0);
}
// now group
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+ ret = Id_SetREGid(ppw->pw_gid, ppw->pw_gid);
+#elif defined(__APPLE__)
ret = setregid(ppw->pw_gid, ppw->pw_gid);
#else
ret = setresgid(ppw->pw_gid, ppw->pw_gid, ppw->pw_gid);
Warning("Failed to set gid for root\n");
return FALSE;
}
+#ifndef USERWORLD
ret = initgroups(ppw->pw_name, ppw->pw_gid);
if (ret < 0) {
Warning("Failed to initgroups() for root\n");
return FALSE;
}
+#endif
// set env
setenv("USER", ppw->pw_name, 1);
RpcChannel_New(void)
{
RpcChannel *chan;
-#if defined(linux) || defined(_WIN32)
+#if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)
chan = VSockChannel_New();
#else
chan = BackdoorChannel_New();
#include "vm_basic_types.h"
-#if (defined(_WIN32) || defined(linux)) && defined(VMTOOLS_USE_GLIB)
+#if ((defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)) && \
+ defined(VMTOOLS_USE_GLIB)
#define VMTOOLS_USE_VSOCKET
#else
#undef VMTOOLS_USE_VSOCKET
#include "mntinfo.h"
static SyncFreezeFn gBackends[] = {
-#if defined(linux)
+#if defined(__linux__) && !defined(USERWORLD)
LinuxDriver_Freeze,
VmSync_Freeze,
NullDriver_Freeze,
#include "ifaddrs.h"
#endif
+#ifdef USERWORLD
+#include <vm_basic_types.h>
+#include <vmkuserstatus.h>
+#include <vmkuseruptime.h>
+#endif
+
#include "vm_assert.h"
#include "system.h"
#include "debug.h"
{
uint64 uptime = -1;
-#ifdef __linux__
+#ifdef USERWORLD
+ {
+ VmkuserStatus_Code status;
+ uint64 sysUptime;
+ status = VmkuserUptime_GetUptime(&sysUptime);
+ if (VmkuserStatus_IsOK(status)) {
+ uptime = sysUptime / 10000;
+ }
+ }
+#elif defined(__linux__)
{
FILE *procStream;
char *buf = NULL;
if (reboot) {
#if defined(sun)
cmd = "/usr/sbin/shutdown -g 0 -i 6 -y";
+#elif defined(USERWORLD)
+ cmd = "/bin/reboot";
#else
cmd = "/sbin/shutdown -r now";
#endif
cmd = "/sbin/shutdown -p now";
#elif defined(sun)
cmd = "/usr/sbin/shutdown -g 0 -i 5 -y";
+#elif defined(USERWORLD)
+ cmd = "/bin/halt";
#else
cmd = "/sbin/shutdown -h now";
#endif
# endif
#endif
+#ifdef USERWORLD
+#include <vm_basic_types.h>
+#include <vmkuserstatus.h>
+#include <vmkusertcpip.h>
+#endif
+
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
return FALSE;
}
+ return TRUE;
+#elif defined(USERWORLD)
+ unsigned count;
+ VmkuserTcpip_Interface ifList[NICINFO_MAX_NICS];
+ VmkuserStatus_Code status;
+
+ status = VmkuserTcpip_GetInterfaces(ifList, NICINFO_MAX_NICS, &count);
+ if (VmkuserStatus_IsOK(status)) {
+ unsigned ix;
+ for (ix = 0; ix < count && ix < ARRAYSIZE(ifList); ix++) {
+ GuestNicV3 *nic;
+ char macAddress[NICINFO_MAC_LEN];
+ struct sockaddr_in sin = {
+ .sin_family = AF_INET,
+ .sin_addr = { .s_addr = ifList[ix].ipaddr }
+ };
+ struct sockaddr sa;
+ Str_Sprintf(macAddress, sizeof macAddress,
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ (unsigned)ifList[ix].macaddr[0],
+ (unsigned)ifList[ix].macaddr[1],
+ (unsigned)ifList[ix].macaddr[2],
+ (unsigned)ifList[ix].macaddr[3],
+ (unsigned)ifList[ix].macaddr[4],
+ (unsigned)ifList[ix].macaddr[5]);
+ nic = GuestInfoAddNicEntry(nicInfo, macAddress, NULL, NULL);
+ if (NULL == nic) {
+ /*
+ * We reached maximum number of NICs we can report to the host.
+ */
+ break;
+ }
+ memset(&sa, 0, sizeof sa);
+ memcpy(&sa, &sin, sizeof sin);
+ GuestInfoAddIpAddress(nic, &sa, 0, NULL, NULL);
+ }
+ }
return TRUE;
#else
return FALSE;
char name[256]; // Size is derived from the SUS2 specification
// "Host names are limited to 255 bytes"
char *osString = NULL;
+#if !defined(USERWORLD)
gboolean disableQueryDiskInfo;
- NicInfoV3 *nicInfo = NULL;
GuestDiskInfo *diskInfo = NULL;
-#if defined(_WIN32) || defined(linux)
+#endif
+ NicInfoV3 *nicInfo = NULL;
+#if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)
GuestMemInfo vmStats = {0};
gboolean perfmonEnabled;
#endif
}
free(osString);
+#if !defined(USERWORLD)
disableQueryDiskInfo =
g_key_file_get_boolean(ctx->config, CONFGROUPNAME_GUESTINFO,
CONFNAME_GUESTINFO_DISABLEQUERYDISKINFO, NULL);
}
}
}
+#endif
if (!System_GetNodeName(sizeof name, name)) {
g_warning("Failed to get netbios name.\n");
/* Send the uptime to VMX so that it can detect soft resets. */
SendUptime(ctx);
-#if defined(_WIN32) || defined(linux)
+#if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)
/* Send the vmstats to the VMX. */
perfmonEnabled = !g_key_file_get_boolean(ctx->config,
CONFGROUPNAME_GUESTINFO,
/*
* No support for open-vm-tools.
*/
-#if (defined(_WIN32) || defined(linux)) && !defined(OPEN_VM_TOOLS)
+#if ((defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)) && \
+ !defined(OPEN_VM_TOOLS)
#define SUPPORT_VGAUTH 1
#else
#define SUPPORT_VGAUTH 0
char **result) // OUT
{
VixError err = VIX_OK;
- char *fullResultBuffer;
+ char *fullResultBuffer = NULL;
char *finalResultBuffer = NULL;
size_t fullResultSize = 0;
size_t curPacketLen = 0;