vbox的更動 63197 路徑 trunk/src/VBox/HostServices
- 時間撮記:
- 2016-8-9 上午09:14:21 (8 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostServices/auth/simple/VBoxAuthSimple.cpp
r60063 r63197 1 /* $Id$ */ 1 2 /** @file 2 * 3 * VirtualBox External Authentication Library: 4 * Simple Authentication. 3 * VirtualBox External Authentication Library - Simple Authentication. 5 4 */ 6 5 … … 38 37 39 38 40 static void dprintf(const char * fmt, ...)39 static void dprintf(const char *pszFormat, ...) 41 40 { 42 41 #ifdef AUTH_DEBUG_FILE_NAME 43 va_list va;44 45 va_start(va, fmt);46 47 char buffer[1024];48 49 vsnprintf(buffer, sizeof(buffer), fmt, va);50 51 42 FILE *f = fopen(AUTH_DEBUG_FILE_NAME, "ab"); 52 43 if (f) 53 44 { 54 fprintf(f, "%s", buffer); 45 va_list va; 46 va_start(va, pszFormat); 47 vfprintf(f, pszFormat, va); 48 va_end(va); 55 49 fclose(f); 56 50 } 57 58 va_end (va);51 #else 52 RT_NOREF(pszFormat); 59 53 #endif 60 54 } 61 55 62 56 RT_C_DECLS_BEGIN 63 DECLEXPORT(AuthResult) AUTHCALL AuthEntry(const char *szCaller, 57 DECLEXPORT(FNAUTHENTRY3) AuthEntry; 58 RT_C_DECLS_END 59 60 DECLEXPORT(AuthResult) AUTHCALL AuthEntry(const char *pszCaller, 64 61 PAUTHUUID pUuid, 65 62 AuthGuestJudgement guestJudgement, 66 const char * szUser,67 const char * szPassword,68 const char * szDomain,63 const char *pszUser, 64 const char *pszPassword, 65 const char *pszDomain, 69 66 int fLogon, 70 67 unsigned clientId) 71 68 { 69 RT_NOREF(pszCaller, guestJudgement, pszDomain, clientId); 70 72 71 /* default is failed */ 73 72 AuthResult result = AuthResultAccessDenied; … … 83 82 84 83 /* the user might contain a domain name, split it */ 85 c har *user = strchr((char*)szUser, '\\');84 const char *user = strchr(pszUser, '\\'); 86 85 if (user) 87 86 user++; 88 87 else 89 user = (char*) szUser;88 user = (char*)pszUser; 90 89 91 dprintf("VBoxAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user,szPassword);90 dprintf("VBoxAuth: uuid: %s, user: %s, pszPassword: %s\n", uuid, user, pszPassword); 92 91 93 92 ComPtr<IVirtualBoxClient> virtualBoxClient; … … 97 96 rc = virtualBoxClient.createInprocObject(CLSID_VirtualBoxClient); 98 97 if (SUCCEEDED(rc)) 98 { 99 99 rc = virtualBoxClient->COMGETTER(VirtualBox)(virtualBox.asOutParam()); 100 if (SUCCEEDED(rc))101 {102 Bstr key = BstrFmt("VBoxAuthSimple/users/%s", user);103 Bstr password;100 if (SUCCEEDED(rc)) 101 { 102 Bstr key = BstrFmt("VBoxAuthSimple/users/%s", user); 103 Bstr password; 104 104 105 /* lookup in VM's extra data? */ 106 if (pUuid) 107 { 108 ComPtr<IMachine> machine; 109 virtualBox->FindMachine(Bstr(uuid).raw(), machine.asOutParam()); 110 if (machine) 111 machine->GetExtraData(key.raw(), password.asOutParam()); 112 } else 113 /* lookup global extra data */ 114 virtualBox->GetExtraData(key.raw(), password.asOutParam()); 105 /* lookup in VM's extra data? */ 106 if (pUuid) 107 { 108 ComPtr<IMachine> machine; 109 virtualBox->FindMachine(Bstr(uuid).raw(), machine.asOutParam()); 110 if (machine) 111 machine->GetExtraData(key.raw(), password.asOutParam()); 112 } 113 else 114 /* lookup global extra data */ 115 virtualBox->GetExtraData(key.raw(), password.asOutParam()); 115 116 116 if (!password.isEmpty())117 {118 /* calculate hash */119 uint8_t abDigest[RTSHA256_HASH_SIZE];120 RTSha256(szPassword, strlen(szPassword), abDigest);121 char pszDigest[RTSHA256_DIGEST_LEN + 1];122 RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest));117 if (!password.isEmpty()) 118 { 119 /* calculate hash */ 120 uint8_t abDigest[RTSHA256_HASH_SIZE]; 121 RTSha256(pszPassword, strlen(pszPassword), abDigest); 122 char pszDigest[RTSHA256_DIGEST_LEN + 1]; 123 RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest)); 123 124 124 if (password == pszDigest) 125 result = AuthResultAccessGranted; 125 if (password == pszDigest) 126 result = AuthResultAccessGranted; 127 } 126 128 } 129 else 130 dprintf("VBoxAuth: failed to get VirtualBox object reference: %#x\n", rc); 127 131 } 128 132 else 129 dprintf("VBoxAuth: failed to get VirtualBox object reference: %Rhrc\n", rc);133 dprintf("VBoxAuth: failed to get VirtualBoxClient object reference: %#x\n", rc); 130 134 131 135 return result; 132 136 } 133 RT_C_DECLS_END134 137 135 /* Verify the function prototype. */136 static PAUTHENTRY3 gpfnAuthEntry = AuthEntry;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器