Changeset 66185 in vbox
- Timestamp:
- Mar 21, 2017 5:24:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r66157 r66185 38 38 #include <VBox/err.h> 39 39 #include <iprt/file.h> 40 #include <iprt/sha.h> 40 41 #include <iprt/initterm.h> 41 42 #include <iprt/param.h> … … 1127 1128 static const RTGETOPTDEF s_aInstallOptions[] = 1128 1129 { 1129 { "--replace", 'r', RTGETOPT_REQ_NOTHING }, 1130 { "--replace", 'r', RTGETOPT_REQ_NOTHING }, 1131 { "--accept-license", 'a', RTGETOPT_REQ_STRING }, 1130 1132 }; 1131 1133 1134 RTCList<RTCString> lstLicenseHashes; 1132 1135 RTGetOptInit(&GetState, a->argc, a->argv, s_aInstallOptions, RT_ELEMENTS(s_aInstallOptions), 1, 0 /*fFlags*/); 1133 1136 while ((ch = RTGetOpt(&GetState, &ValueUnion))) … … 1137 1140 case 'r': 1138 1141 fReplace = true; 1142 break; 1143 1144 case 'a': 1145 lstLicenseHashes.append(ValueUnion.psz); 1139 1146 break; 1140 1147 … … 1172 1179 Bstr("txt").raw() /* Format */, 1173 1180 bstrLicense.asOutParam()), RTEXITCODE_FAILURE); 1174 RTPrintf("%ls\n", bstrLicense.raw()); 1175 RTPrintf("Do you agree to these license terms and conditions (y/n)? " ); 1176 ch = RTStrmGetCh(g_pStdIn); 1177 RTPrintf("\n"); 1178 if (ch != 'y' && ch != 'Y') 1179 { 1180 RTPrintf("Installation of \"%ls\" aborted.\n", bstrName.raw()); 1181 return RTEXITCODE_SUCCESS; 1181 Utf8Str strLicense(bstrLicense); 1182 uint8_t abHash[RTSHA256_HASH_SIZE]; 1183 RTSha256(strLicense.c_str(), strLicense.length(), abHash); 1184 char *pszDigest = NULL; 1185 vrc = RTStrAllocEx(&pszDigest, RTSHA256_DIGEST_LEN + 1); 1186 if (RT_SUCCESS(vrc)) 1187 RTSha256ToString(abHash, pszDigest, RTSHA256_DIGEST_LEN + 1); 1188 if ( pszDigest 1189 && lstLicenseHashes.contains(pszDigest)) 1190 RTPrintf("License accepted.\n"); 1191 else 1192 { 1193 RTPrintf("%ls\n", bstrLicense.raw()); 1194 RTPrintf("Do you agree to these license terms and conditions (y/n)? " ); 1195 ch = RTStrmGetCh(g_pStdIn); 1196 RTPrintf("\n"); 1197 if (ch != 'y' && ch != 'Y') 1198 { 1199 RTPrintf("Installation of \"%ls\" aborted.\n", bstrName.raw()); 1200 if (pszDigest) 1201 RTStrFree(pszDigest); 1202 return RTEXITCODE_SUCCESS; 1203 } 1204 if (pszDigest) 1205 RTPrintf("License accepted. For batch installaltion add \n" 1206 " --accept-license=%s\n" 1207 "to the VBoxManage command line.\n\n", pszDigest); 1182 1208 } 1183 1209 }
Note:
See TracChangeset
for help on using the changeset viewer.