Changeset 33228 in vbox
- Timestamp:
- Oct 19, 2010 1:12:31 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/user_Frontends.xml
r33185 r33228 391 391 Last but not least, you have to configure users and passwords. Here is an example 392 392 for the user "john" with the password "secret": 393 <computeroutput>VBoxManage setextradata "VM name" "VBoxAuthSimple/users/john" "secret"</computeroutput> 394 To specify an empty password, use the special reserved value 395 <computeroutput>[NULL]</computeroutput>. 393 <computeroutput>VBoxManage internalcommands passwordhash "secret"</computeroutput> 394 This will give you the hash value "2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b" 395 which you set using 396 <computeroutput>VBoxManage setextradata "VM name" "VBoxAuthSimple/users/john" 397 "2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b"</computeroutput>. 396 398 </para> 397 399 </listitem> … … 409 411 default "external authentication module with any other module. For this, 410 412 VirtualBox provides a well-defined interface that allows you to write your 411 own authentication module; see <xref 412 linkend="vbox-authenticate-sdk" />for details.</para>413 own authentication module; see <xref linkend="vbox-authenticate-sdk" /> 414 for details.</para> 413 415 </sect2> 414 416 -
trunk/include/iprt/sha.h
r32569 r33228 39 39 #define RTSHA1_HASH_SIZE 20 40 40 /** The length of a SHA-1 digest string. The terminator is not included. */ 41 #define RTSHA1_ DIGEST_LEN (40)41 #define RTSHA1_STRING_LEN (40) 42 42 43 43 /** … … 142 142 #define RTSHA256_HASH_SIZE 32 143 143 /** The length of a SHA-256 digest string. The terminator is not included. */ 144 #define RTSHA256_ DIGEST_LEN 64144 #define RTSHA256_STRING_LEN 64 145 145 146 146 /** -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r33082 r33228 43 43 #include <iprt/string.h> 44 44 #include <iprt/uuid.h> 45 45 #include <iprt/sha.h> 46 46 47 47 #include "VBoxManage.h" … … 137 137 "Commands:\n" 138 138 "\n" 139 "%s%s%s%s%s%s%s%s%s%s%s%s "139 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s" 140 140 "WARNING: This is a development tool and shall only be used to analyse\n" 141 141 " problems. It is completely unsupported and will change in\n" … … 238 238 " Controls debug logging.\n" 239 239 "\n" 240 : "" 240 : "", 241 (u64Cmd & USAGE_PASSWORDHASH) 242 ? " passwordhash <passsword>\n" 243 " Generates a password hash.\n" 244 "\n" 245 : 246 "" 241 247 ); 242 248 } … … 2007 2013 2008 2014 /** 2015 * Generate a SHA-256 password hash 2016 */ 2017 int CmdGeneratePasswordHash(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 2018 { 2019 /* one parameter, the password to hash */ 2020 if (argc != 1) 2021 return errorSyntax(USAGE_PASSWORDHASH, "password to hash required"); 2022 2023 uint8_t abDigest[RTSHA256_HASH_SIZE]; 2024 RTSha256(argv[0], strlen(argv[0]), abDigest); 2025 char pszDigest[RTSHA256_STRING_LEN + 1]; 2026 RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest)); 2027 RTPrintf("Password hash: %s\n", pszDigest); 2028 2029 return 0; 2030 } 2031 2032 /** 2009 2033 * Wrapper for handling internal commands 2010 2034 */ … … 2045 2069 if (!strcmp(pszCmd, "debuglog")) 2046 2070 return CmdDebugLog(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2071 if (!strcmp(pszCmd, "passwordhash")) 2072 return CmdGeneratePasswordHash(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2047 2073 2048 2074 /* default: */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r32712 r33228 97 97 #define USAGE_DEBUGLOG RT_BIT_64(52) 98 98 #define USAGE_SETHDPARENTUUID RT_BIT_64(53) 99 #define USAGE_PASSWORDHASH RT_BIT_64(54) 99 100 #define USAGE_ALL (~(uint64_t)0) 100 101 /** @} */ -
trunk/src/VBox/HostServices/auth/simple/VBoxAuthSimple.cpp
r33185 r33228 24 24 #include <iprt/cdefs.h> 25 25 #include <iprt/uuid.h> 26 #include <iprt/sha.h> 26 27 27 28 #include <VBox/VRDPAuth.h> … … 85 86 user = (char*)szUser; 86 87 87 dprintf("VRDPAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user, szPassword); 88 89 #if 0 90 /* this is crude stuff, but let's keep it there as a sample */ 91 if (getenv("VBOX_VRDP_AUTH_USER") && getenv("VBOX_VRDP_AUTH_PASSWORD")) 92 { 93 94 if ( !strcmp(getenv("VBOX_VRDP_AUTH_USER"), user) 95 && !strcmp(getenv("VBOX_VRDP_AUTH_PASSWORD"), szPassword)) 96 { 97 result = VRDPAuthAccessGranted; 98 } 99 } 100 #endif 88 dprintf("VBoxAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user, szPassword); 101 89 102 90 ComPtr<IVirtualBox> virtualBox; … … 106 94 if (SUCCEEDED(rc)) 107 95 { 108 Bstr key = BstrFmt("V RDPAuthSimple/users/%s", user);96 Bstr key = BstrFmt("VBoxAuthSimple/users/%s", user); 109 97 Bstr password; 110 98 … … 120 108 virtualBox->GetExtraData(key.raw(), password.asOutParam()); 121 109 122 /* we compare the password or check for special NULL marker */ 123 if ( (!password.isEmpty() && (password == szPassword)) 124 || ((password == "[NULL]") && (!szPassword || (*szPassword == '\0')))) 110 if (!password.isEmpty()) 125 111 { 126 result = VRDPAuthAccessGranted; 112 /* calculate hash */ 113 uint8_t abDigest[RTSHA256_HASH_SIZE]; 114 RTSha256(szPassword, strlen(szPassword), abDigest); 115 char pszDigest[RTSHA256_STRING_LEN + 1]; 116 RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest)); 117 118 if (password == pszDigest) 119 result = VRDPAuthAccessGranted; 127 120 } 128 121 }
Note:
See TracChangeset
for help on using the changeset viewer.