Changeset 34418 in vbox
- Timestamp:
- Nov 26, 2010 5:25:58 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 68189
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r34380 r34418 457 457 #define VERR_NOT_IMPLEMENTED (-12) 458 458 459 /** Not equal. */ 460 #define VERR_NOT_EQUAL (-18) 459 461 /** The specified path does not point at a symbolic link. */ 460 462 #define VERR_NOT_SYMLINK (-19) -
trunk/include/iprt/manifest.h
r34391 r34418 96 96 * Compares two manifests for equality. 97 97 * 98 * @returns true if equals, false if not. 98 * @returns IPRT status code. 99 * @retval VINF_SUCCESS if equal. 100 * @retval VERR_NOT_EQUAL if not equal. 101 * 99 102 * @param hManifest1 The first manifest. 100 103 * @param hManifest2 The second manifest. 101 104 * @param papszIgnoreEntries Entries to ignore. Ends with a NULL entry. 102 105 * @param papszIgnoreAttrs Attributes to ignore. Ends with a NULL entry. 106 * @param pszEntry Where to store the name of the mismatching 107 * entry, or as much of the name as there is room 108 * for. This is always set. Optional. 109 * @param cbEntry The size of the buffer pointed to by @a 110 * pszEntry. 103 111 */ 104 112 RTDECL(int) RTManifestEqualsEx(RTMANIFEST hManifest1, RTMANIFEST hManifest2, const char * const *papszIgnoreEntries, 105 const char * const *papszIgnoreAttr );113 const char * const *papszIgnoreAttr, char *pszEntry, size_t cbEntry); 106 114 107 115 /** 108 116 * Compares two manifests for equality. 109 117 * 110 * @returns true if equals, false if not. 118 * @returns IPRT status code. 119 * @retval VINF_SUCCESS if equal. 120 * @retval VERR_NOT_EQUAL if not equal. 121 * 111 122 * @param hManifest1 The first manifest. 112 123 * @param hManifest2 The second manifest. -
trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp
r34391 r34418 236 236 237 237 /** 238 * Verifies the manifest and its signature. 239 * 240 * @returns Program exit code, failure with message. 241 * @param hOurManifest The manifest we compiled. 242 * @param hManifestFile The manifest file in the extension pack. 243 * @param hSignatureFile The manifest signature file. 244 */ 245 static RTEXITCODE VerifyManifestAndSignature(RTMANIFEST hOurManifest, RTVFSFILE hManifestFile, RTVFSFILE hSignatureFile) 246 { 247 /* 248 * Read the manifest from the extension pack. 249 */ 250 RTMANIFEST hTheirManifest; 251 int rc = RTManifestCreate(0 /*fFlags*/, &hTheirManifest); 252 if (RT_FAILURE(rc)) 253 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTManifestCreate failed: %Rrc", rc); 254 255 RTEXITCODE rcExit; 256 RTVFSIOSTREAM hVfsIos = RTVfsFileToIoStream(hManifestFile); 257 rc = RTManifestReadStandard(hTheirManifest, hVfsIos); 258 RTVfsIoStrmRelease(hVfsIos); 259 if (RT_SUCCESS(rc)) 260 { 261 /* 262 * Compare the manifests. 263 */ 264 static const char *s_apszIgnoreEntries[] = 265 { 266 VBOX_EXTPACK_MANIFEST_NAME, 267 VBOX_EXTPACK_SIGNATURE_NAME, 268 "./" VBOX_EXTPACK_MANIFEST_NAME, 269 "./" VBOX_EXTPACK_SIGNATURE_NAME, 270 NULL 271 }; 272 char szEntry[RTPATH_MAX]; 273 rc = RTManifestEqualsEx(hOurManifest, hTheirManifest, &s_apszIgnoreEntries[0], NULL, szEntry, sizeof(szEntry)); 274 if (RT_SUCCESS(rc)) 275 { 276 /* 277 * Validate the manifest file signature. 278 */ 279 /** @todo implement signature stuff */ 280 281 } 282 else if (rc == VERR_NOT_EQUAL && szEntry[0]) 283 RTMsgError("Manifest mismatch: '%s'", szEntry); 284 else 285 RTMsgError("RTManifestEqualsEx failed: %Rrc", rc); 286 } 287 else 288 RTMsgError("Error parsing '%s': %Rrc", VBOX_EXTPACK_MANIFEST_NAME); 289 290 RTManifestRelease(hTheirManifest); 291 return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 292 } 293 294 295 /** 238 296 * Validates a name in an extension pack. 239 297 * … … 440 498 return rcExit; 441 499 442 RTMANIFEST h Manifest;443 int rc = RTManifestCreate(0 /*fFlags*/, &h Manifest);500 RTMANIFEST hOurManifest; 501 int rc = RTManifestCreate(0 /*fFlags*/, &hOurManifest); 444 502 if (RT_SUCCESS(rc)) 445 503 { 446 504 /* 447 * Process the tarball .505 * Process the tarball (would be nice to move this to a function). 448 506 */ 449 507 RTVFSFILE hXmlFile = NIL_RTVFSFILE; 450 508 RTVFSFILE hManifestFile = NIL_RTVFSFILE; 451 RTVFSFILE hSign File= NIL_RTVFSFILE;509 RTVFSFILE hSignatureFile= NIL_RTVFSFILE; 452 510 for (;;) 453 511 { … … 482 540 phVfsFile = &hManifestFile; 483 541 else if (!strcmp(pszAdjName, VBOX_EXTPACK_SIGNATURE_NAME)) 484 phVfsFile = &hSign File;542 phVfsFile = &hSignatureFile; 485 543 else 486 544 phVfsFile = NULL; … … 542 600 { 543 601 RTVFSIOSTREAM hVfsIos = RTVfsObjToIoStream(hVfsObj); 544 rc = RTManifestEntryAddIoStream(h Manifest, hVfsIos, pszName, RTMANIFEST_ATTR_SIZE | RTMANIFEST_ATTR_SHA256);602 rc = RTManifestEntryAddIoStream(hOurManifest, hVfsIos, pszName, RTMANIFEST_ATTR_SIZE | RTMANIFEST_ATTR_SHA256); 545 603 if (RT_FAILURE(rc)) 546 604 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTManifestEntryAddIoStream failed on '%s': %Rrc", pszName, rc); … … 567 625 if (hManifestFile == NIL_RTVFSFILE) 568 626 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Mandator file '%s' is missing", VBOX_EXTPACK_MANIFEST_NAME); 569 if (hSign File == NIL_RTVFSFILE)627 if (hSignatureFile == NIL_RTVFSFILE) 570 628 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Mandator file '%s' is missing", VBOX_EXTPACK_SIGNATURE_NAME); 571 629 } 572 630 573 574 575 RTManifestRelease(hManifest); /** @todo return this and use it during unpacking */ 631 /* 632 * Check the manifest and it's signature. 633 */ 634 if (rcExit == RTEXITCODE_SUCCESS) 635 rcExit = VerifyManifestAndSignature(hOurManifest, hManifestFile, hSignatureFile); 636 637 RTManifestRelease(hOurManifest); /** @todo return this and use it during unpacking */ 638 639 RTVfsFileRelease(hXmlFile); 640 RTVfsFileRelease(hManifestFile); 641 RTVfsFileRelease(hSignatureFile); 576 642 } 577 643 RTVfsFsStrmRelease(hTarFss); -
trunk/src/VBox/Runtime/common/checksum/manifest2.cpp
r34385 r34418 222 222 223 223 224 /**225 * Compares two manifests for equality.226 *227 * @returns true if equals, false if not.228 * @param hManifest1 The first manifest.229 * @param hManifest2 The second manifest.230 * @param papszIgnoreEntries Entries to ignore. Ends with a NULL entry.231 * @param papszIgnoreAttrs Attributes to ignore. Ends with a NULL entry.232 */233 224 RTDECL(int) RTManifestEqualsEx(RTMANIFEST hManifest1, RTMANIFEST hManifest2, const char * const *papszIgnoreEntries, 234 const char * const *papszIgnoreAttr) 235 { 225 const char * const *papszIgnoreAttr, char *pszEntry, size_t cbEntry) 226 { 227 /* 228 * Validate input. 229 */ 230 AssertPtrNullReturn(pszEntry, VERR_INVALID_POINTER); 231 if (pszEntry && cbEntry) 232 *pszEntry = '\0'; 236 233 RTMANIFESTINT *pThis1 = hManifest1; 237 234 RTMANIFESTINT *pThis2 = hManifest1; 238 235 if (pThis1 != NIL_RTMANIFEST) 239 236 { 240 AssertPtrReturn(pThis1, false);241 AssertReturn(pThis1->u32Magic == RTMANIFEST_MAGIC, false);237 AssertPtrReturn(pThis1, VERR_INVALID_HANDLE); 238 AssertReturn(pThis1->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE); 242 239 } 243 240 if (pThis2 != NIL_RTMANIFEST) 244 241 { 245 AssertPtrReturn(pThis2, false);246 AssertReturn(pThis2->u32Magic == RTMANIFEST_MAGIC, false);242 AssertPtrReturn(pThis2, VERR_INVALID_HANDLE); 243 AssertReturn(pThis2->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE); 247 244 } 248 245 … … 251 248 */ 252 249 if (pThis1 == pThis2) 253 return true;250 return VINF_SUCCESS; 254 251 if (pThis1 == NIL_RTMANIFEST || pThis2 == NIL_RTMANIFEST) 255 return false;252 return VERR_NOT_EQUAL; 256 253 257 254 /* … … 266 263 267 264 268 /**269 * Compares two manifests for equality.270 *271 * @returns true if equals, false if not.272 * @param hManifest1 The first manifest.273 * @param hManifest2 The second manifest.274 */275 265 RTDECL(int) RTManifestEquals(RTMANIFEST hManifest1, RTMANIFEST hManifest2) 276 266 { 277 return RTManifestEqualsEx(hManifest1, hManifest2, NULL /*papszIgnoreEntries*/, NULL /*papszIgnoreAttrs*/ );267 return RTManifestEqualsEx(hManifest1, hManifest2, NULL /*papszIgnoreEntries*/, NULL /*papszIgnoreAttrs*/, NULL, 0); 278 268 } 279 269
Note:
See TracChangeset
for help on using the changeset viewer.