Changeset 24311 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Nov 4, 2009 10:44:03 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibCredentials.cpp
r24270 r24311 1 /* $Id :*/1 /* $Id$ */ 2 2 /** @file 3 3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, user credentials. … … 34 34 * 35 35 * @returns true if credentials are available, false if not (or error occured). 36 *37 36 */ 38 37 VBGLR3DECL(bool) VbglR3CredentialsAreAvailable(void) 39 38 { 40 int rc; 41 VMMDevCredentials vmmreqCredentials; 39 VMMDevCredentials Req; 40 RT_ZERO(Req); 41 vmmdevInitRequest((VMMDevRequestHeader*)&Req, VMMDevReq_QueryCredentials); 42 Req.u32Flags |= VMMDEV_CREDENTIALS_QUERYPRESENCE; 42 43 43 memset(&vmmreqCredentials, 0, sizeof(vmmreqCredentials)); 44 45 vmmdevInitRequest((VMMDevRequestHeader*)&vmmreqCredentials, VMMDevReq_QueryCredentials); 46 vmmreqCredentials.u32Flags |= VMMDEV_CREDENTIALS_QUERYPRESENCE; 47 rc = vbglR3GRPerform(&vmmreqCredentials.header); 48 49 bool fAvailable = false; 50 if ( RT_SUCCESS(rc) 51 && ((vmmreqCredentials.u32Flags & VMMDEV_CREDENTIALS_PRESENT) != 0)) 52 { 53 fAvailable = true; 54 } 55 return fAvailable; 44 int rc = vbglR3GRPerform(&Req.header); 45 return RT_SUCCESS(rc) 46 && (Req.u32Flags & VMMDEV_CREDENTIALS_PRESENT) != 0; 56 47 } 57 48 58 49 59 50 /** 60 * Retrieves user credentials to log into aguest OS.51 * Retrieves and clears the user credentials for logging into the guest OS. 61 52 * 62 53 * @returns IPRT status value 63 * @param ppszUser Receives pointer of allocated user name string. NULL is accepted.54 * @param ppszUser Receives pointer of allocated user name string. 64 55 * The returned pointer must be freed using RTStrFree(). 65 * @param ppszPassword Receives pointer of allocated user password string. NULL is accepted.56 * @param ppszPassword Receives pointer of allocated user password string. 66 57 * The returned pointer must be freed using RTStrFree(). 67 * @param ppszDomain Receives pointer of allocated domain name string. NULL is accepted.58 * @param ppszDomain Receives pointer of allocated domain name string. 68 59 * The returned pointer must be freed using RTStrFree(). 69 60 */ 70 61 VBGLR3DECL(int) VbglR3CredentialsRetrieve(char **ppszUser, char **ppszPassword, char **ppszDomain) 71 62 { 72 int rc; 73 VMMDevCredentials vmmreqCredentials; 63 VMMDevCredentials Req; 64 RT_ZERO(Req); 65 vmmdevInitRequest((VMMDevRequestHeader*)&Req, VMMDevReq_QueryCredentials); 66 Req.u32Flags |= VMMDEV_CREDENTIALS_READ | VMMDEV_CREDENTIALS_CLEAR; 74 67 75 memset(&vmmreqCredentials, 0, sizeof(vmmreqCredentials)); 76 77 vmmdevInitRequest((VMMDevRequestHeader*)&vmmreqCredentials, VMMDevReq_QueryCredentials); 78 vmmreqCredentials.u32Flags |= VMMDEV_CREDENTIALS_READ; 79 vmmreqCredentials.u32Flags |= VMMDEV_CREDENTIALS_CLEAR; 80 rc = vbglR3GRPerform(&vmmreqCredentials.header); 81 68 int rc = vbglR3GRPerform(&Req.header); 82 69 if (RT_SUCCESS(rc)) 83 70 { 84 /** @todo error checking */ 85 rc = RTStrDupEx(ppszUser, vmmreqCredentials.szUserName); 86 rc = RTStrDupEx(ppszPassword, vmmreqCredentials.szPassword); 87 rc = RTStrDupEx(ppszDomain, vmmreqCredentials.szDomain); 71 rc = RTStrDupEx(ppszUser, Req.szUserName); 72 if (RT_SUCCESS(rc)) 73 { 74 rc = RTStrDupEx(ppszPassword, Req.szPassword); 75 if (RT_SUCCESS(rc)) 76 { 77 rc = RTStrDupEx(ppszDomain, Req.szDomain); 78 if (RT_SUCCESS(rc)) 79 return VINF_SUCCESS; 80 81 RTStrFree(*ppszPassword); 82 } 83 RTStrFree(*ppszUser); 84 } 88 85 } 89 86 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.