- Timestamp:
- Jun 7, 2010 6:35:37 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r30013 r30048 156 156 * Errors are ignored. 157 157 */ 158 static void VBoxServiceVMInfoWriteFixedProperties(void)158 static void vboxserviceVMInfoWriteFixedProperties(void) 159 159 { 160 160 /* … … 213 213 * Provide information about active users. 214 214 */ 215 int VBoxServiceVMInfoWriteUsers()215 static int vboxserviceVMInfoWriteUsers(void) 216 216 { 217 217 int rc; … … 222 222 # ifndef TARGET_NT4 223 223 rc = VBoxServiceVMInfoWinWriteUsers(&pszUserList, &cUsersInList); 224 # endif /* TARGET_NT4 */ 224 # else 225 rc = VERR_NOT_IMPLEMENTED; 226 # endif 225 227 #elif defined(RT_OS_FREEBSD) 226 /** @todo FreeBSD: Port logged on user info retrival. */ 228 /** @todo FreeBSD: Port logged on user info retrival. */ 229 rc = VERR_NOT_IMPLEMENTED; 227 230 #elif defined(RT_OS_OS2) 228 /** @todo OS/2: Port logged on (LAN/local/whatever) user info retrival. */ 231 /** @todo OS/2: Port logged on (LAN/local/whatever) user info retrival. */ 232 rc = VERR_NOT_IMPLEMENTED; 229 233 #else 230 234 rc = utmpname(UTMP_FILE); … … 236 240 { 237 241 VBoxServiceError("VMInfo/Users: Could not set UTMP file! Error: %ld\n", errno); 238 } 242 rc = VERR_GENERAL_FAILURE; 243 } 244 else 245 rc = VINF_SUCCESS; 239 246 setutent(); 240 247 utmp *ut_user; … … 250 257 { 251 258 rc = RTStrAAppend(&pszUserList, ","); 252 AssertRC Return(rc, rc);259 AssertRCBreakStmt(rc, RTStrFree(pszUserList)); 253 260 } 254 261 rc = RTStrAAppend(&pszUserList, ut_user->ut_user); 255 AssertRC Return(rc, rc);262 AssertRCBreakStmt(rc, RTStrFree(pszUserList)); 256 263 cUsersInList++; 257 264 } 258 265 } 259 266 endutent(); 260 #endif /* !RT_OS_WINDOWS */ 267 #endif 268 Assert(RT_FAILURE(rc) || cUsersInList == 0 || (pszUserList && *pszUserList)); 269 if (RT_FAILURE(rc)) 270 cUsersInList = 0; 261 271 262 272 if (pszUserList && cUsersInList > 0) … … 267 277 if (g_cVMInfoLoggedInUsers != cUsersInList) 268 278 { 269 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", cUsersInList == 0 ? "true" : "false"); 279 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", 280 cUsersInList == 0 ? "true" : "false"); 270 281 g_cVMInfoLoggedInUsers = cUsersInList; 271 282 } 272 if ( pszUserList)283 if (RT_SUCCESS(rc) && pszUserList) 273 284 RTStrFree(pszUserList); 274 285 return VINF_SUCCESS; … … 279 290 * Provide information about the guest network. 280 291 */ 281 int VBoxServiceVMInfoWriteNetwork()282 { 283 int cIfacesReport = 0;284 char szPropPath [FILENAME_MAX];292 static int vboxserviceVMInfoWriteNetwork(void) 293 { 294 int cIfacesReport = 0; 295 char szPropPath[256]; 285 296 286 297 #ifdef RT_OS_WINDOWS … … 289 300 # ifndef TARGET_NT4 290 301 ULONG cbAdpInfo = sizeof(*pAdpInfo); 291 pAdpInfo = (IP_ADAPTER_INFO *)RTMemAlloc(cbAdpInfo);302 pAdpInfo = (IP_ADAPTER_INFO *)RTMemAlloc(cbAdpInfo); 292 303 if (!pAdpInfo) 293 304 { … … 521 532 return RTErrConvertFromErrno(errno); 522 533 } 523 #if defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)534 # if defined(RT_OS_OS2) || defined(RT_OS_SOLARIS) 524 535 pAddress = (sockaddr_in *)&ifrequest[i].ifr_addr; 525 #else536 # else 526 537 pAddress = (sockaddr_in *)&ifrequest[i].ifr_netmask; 527 #endif538 # endif 528 539 529 540 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Netmask", cIfacesReport); 530 541 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr)); 531 542 532 #if defined(RT_OS_SOLARIS)543 # if defined(RT_OS_SOLARIS) 533 544 if (ioctl(sd, SIOCGENADDR, &ifrequest[i]) < 0) 534 #else545 # else 535 546 if (ioctl(sd, SIOCGIFHWADDR, &ifrequest[i]) < 0) 536 #endif547 # endif 537 548 { 538 549 VBoxServiceError("VMInfo/Network: Failed to ioctl(SIOCGIFHWADDR) on socket: Error %d\n", errno); … … 542 553 543 554 char szMac[32]; 544 #if defined(RT_OS_SOLARIS)555 # if defined(RT_OS_SOLARIS) 545 556 uint8_t *pu8Mac = (uint8_t*)&ifrequest[i].ifr_enaddr[0]; 546 #else557 # else 547 558 uint8_t *pu8Mac = (uint8_t*)&ifrequest[i].ifr_hwaddr.sa_data[0]; 548 #endif559 # endif 549 560 RTStrPrintf(szMac, sizeof(szMac), "%02X%02X%02X%02X%02X%02X", 550 561 pu8Mac[0], pu8Mac[1], pu8Mac[2], pu8Mac[3], pu8Mac[4], pu8Mac[5]); … … 591 602 WSADATA wsaData; 592 603 if (WSAStartup(MAKEWORD(2, 2), &wsaData)) 593 VBoxServiceError("VMInfo/ Users: WSAStartup failed! Error: %Rrc\n", RTErrConvertFromWin32(WSAGetLastError()));604 VBoxServiceError("VMInfo/Network: WSAStartup failed! Error: %Rrc\n", RTErrConvertFromWin32(WSAGetLastError())); 594 605 #endif /* RT_OS_WINDOWS */ 595 606 … … 597 608 * Write the fixed properties first. 598 609 */ 599 VBoxServiceVMInfoWriteFixedProperties();610 vboxserviceVMInfoWriteFixedProperties(); 600 611 601 612 /* … … 604 615 for (;;) 605 616 { 606 rc = VBoxServiceVMInfoWriteUsers();617 rc = vboxserviceVMInfoWriteUsers(); 607 618 if (RT_FAILURE(rc)) 608 619 break; 609 620 610 rc = VBoxServiceVMInfoWriteNetwork();621 rc = vboxserviceVMInfoWriteNetwork(); 611 622 if (RT_FAILURE(rc)) 612 623 break;
Note:
See TracChangeset
for help on using the changeset viewer.