Changeset 34442 in vbox
- Timestamp:
- Nov 29, 2010 12:25:17 AM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp
r34437 r34442 86 86 "Usage: %s <command> [options]\n" 87 87 "Commands:\n" 88 " install --base-dir <dir> --cert ificate-dir <dir> --name <name> \\\n"88 " install --base-dir <dir> --cert-dir <dir> --name <name> \\\n" 89 89 " --tarball <tarball> --tarball-fd <fd>\n" 90 90 " uninstall --base-dir <dir> --name <name>\n" … … 231 231 static RTEXITCODE SetExtPackPermissions(const char *pszDir) 232 232 { 233 RTMsgInfo("Setting permissions..."); 233 234 #if !defined(RT_OS_WINDOWS) 234 235 int rc = RTPathSetMode(pszDir, 0755); … … 239 240 #endif 240 241 242 return RTEXITCODE_SUCCESS; 243 } 244 245 246 /** 247 * Verifies the manifest and its signature. 248 * 249 * @returns Program exit code, failure with message. 250 * @param hManifestFile The xml from the extension pack. 251 * @param pszExtPackName The expected extension pack name. 252 */ 253 static RTEXITCODE VerifyXml(RTVFSFILE hXmlFile, const char *pszExtPackName) 254 { 255 /** @todo implement XML verification. */ 241 256 return RTEXITCODE_SUCCESS; 242 257 } … … 294 309 } 295 310 else 296 RTMsgError("Error parsing '%s': %Rrc", VBOX_EXTPACK_MANIFEST_NAME );311 RTMsgError("Error parsing '%s': %Rrc", VBOX_EXTPACK_MANIFEST_NAME, rc); 297 312 298 313 RTManifestRelease(hTheirManifest); … … 356 371 break; 357 372 } 373 374 /* advance */ 375 psz++; 358 376 } 359 377 … … 450 468 * Operations performed: 451 469 * - Hardening checks. 452 * - XML validity check.453 * - Name check (against XML).454 470 * 455 471 * @returns The program exit code. 456 472 * @param pszDir The directory where the extension pack has been 457 473 * unpacked. 458 * @param psz NameThe expected extension pack name.474 * @param pszExtPackName The expected extension pack name. 459 475 * @param pszTarball The name of the tarball in case we have to 460 476 * complain about something. 461 477 */ 462 static RTEXITCODE ValidateUnpackedExtPack(const char *pszDir, const char *pszTarball, const char *pszName) 463 { 464 /** @todo */ 478 static RTEXITCODE ValidateUnpackedExtPack(const char *pszDir, const char *pszTarball, const char *pszExtPackName) 479 { 480 RTMsgInfo("Validating unpacked extension pack..."); 481 482 char szErr[4096+1024]; 483 int rc = SUPR3HardenedVerifyDir(pszDir, true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr)); 484 if (RT_FAILURE(rc)) 485 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Hardening check failed with %Rrc: %s", rc, szErr); 486 return RTEXITCODE_SUCCESS; 487 } 488 489 490 /** 491 * Unpacks a directory from an extension pack tarball. 492 * 493 * @returns Program exit code, failure with message. 494 * @param pszDstDirName The name of the unpacked directory. 495 * @param hVfsObj The source object for the directory. 496 */ 497 static RTEXITCODE UnpackExtPackDir(const char *pszDstDirName, RTVFSOBJ hVfsObj) 498 { 499 int rc = RTDirCreate(pszDstDirName, 0755); 500 if (RT_FAILURE(rc)) 501 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to create directory '%s': %Rrc", pszDstDirName, rc); 502 /** @todo Ownership tricks on windows? */ 465 503 return RTEXITCODE_SUCCESS; 466 504 } … … 564 602 * @param hTarballFile The tarball to unpack. 565 603 * @param pszDirDst Where to unpack it. 604 * @param hValidManifest The manifest we've validated. 566 605 * @param pszTarball The name of the tarball in case we have to 567 606 * complain about something. 568 * @todo Needs to take the previous verified manifest as input. 569 */ 570 static RTEXITCODE UnpackExtPack(RTFILE hTarballFile, const char *pszDirDst, const char *pszTarball) 571 { 607 */ 608 static RTEXITCODE UnpackExtPack(RTFILE hTarballFile, const char *pszDirDst, RTMANIFEST hValidManifest, 609 const char *pszTarball) 610 { 611 RTMsgInfo("Unpacking extension pack into '%s'...", pszDirDst); 612 572 613 /* 573 614 * Set up the destination path and directory. … … 634 675 } 635 676 else 636 { 637 rc = RTDirCreate(szDstPath, 0755); 638 if (RT_FAILURE(rc)) 639 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to create directory '%s': %Rrc", pszName, rc); 640 } 677 rcExit = UnpackExtPackDir(szDstPath, hVfsObj); 641 678 } 642 679 else … … 657 694 * manifest. 658 695 */ 659 //if (rcExit == RTEXITCODE_SUCCESS) 660 /// @todo 696 if (rcExit == RTEXITCODE_SUCCESS) 697 { 698 char szEntry[RTPATH_MAX]; 699 rc = RTManifestEqualsEx(hUnpackManifest, hValidManifest, NULL /*papszIgnoreEntries*/, NULL /*papszIgnoreAttr*/, 700 szEntry, sizeof(szEntry)); 701 if (RT_SUCCESS(rc)) 702 rc = RTEXITCODE_SUCCESS; 703 else if (rc == VERR_NOT_EQUAL && szEntry[0]) 704 RTMsgError("Manifest mismatch: '%s'", szEntry); 705 else 706 RTMsgError("RTManifestEqualsEx failed: %Rrc", rc); 707 } 661 708 662 709 RTManifestRelease(hUnpackManifest); … … 668 715 669 716 717 670 718 /** 671 719 * Validates the extension pack tarball prior to unpacking. 672 720 * 673 721 * Operations performed: 722 * - Mandatory files. 674 723 * - Manifest check. 675 724 * - Manifest seal check. 676 * - Mandatory files.725 * - XML check, match name. 677 726 * 678 727 * @returns The program exit code. 679 728 * @param hTarballFile The handle to open the @a pszTarball file. 729 * @param pszExtPackName The name of the extension pack name. 680 730 * @param pszTarball The name of the tarball in case we have to 681 731 * complain about something. 682 * 683 * @todo Should validate the XML and name. 684 * @todo Needs to return a manifest. 685 */ 686 static RTEXITCODE ValidateExtPackTarball(RTFILE hTarballFile, const char *pszTarball) 687 { 732 * @param phValidManifest Where to return the handle to fully validated 733 * the manifest for the extension pack. This 734 * includes all files. 735 * 736 * @todo This function is a bit too long and should be split up if possible. 737 */ 738 static RTEXITCODE ValidateExtPackTarball(RTFILE hTarballFile, const char *pszExtPackName, const char *pszTarball, 739 PRTMANIFEST phValidManifest) 740 { 741 *phValidManifest = NIL_RTMANIFEST; 742 RTMsgInfo("Validating extension pack '%s' ('%s')...", pszTarball, pszExtPackName); 743 688 744 /* 689 745 * Open the tar.gz filesystem stream and set up an manifest in-memory file. … … 831 887 rcExit = VerifyManifestAndSignature(hOurManifest, hManifestFile, hSignatureFile); 832 888 833 RTManifestRelease(hOurManifest); /** @todo return this and use it during unpacking */ 889 /* 890 * Check the XML. 891 */ 892 if (rcExit == RTEXITCODE_SUCCESS) 893 rcExit = VerifyXml(hXmlFile, pszExtPackName); 894 895 /* 896 * Release objects and stuff. 897 */ 898 if (rcExit == RTEXITCODE_SUCCESS) 899 *phValidManifest = hOurManifest; 900 else 901 RTManifestRelease(hOurManifest); 834 902 835 903 RTVfsFileRelease(hXmlFile); … … 923 991 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to create temporary directory: %Rrc ('%s')", rc, szTmpPath); 924 992 925 RTEXITCODE rcExit = ValidateExtPackTarball(hTarballFile, pszTarball); 993 RTMANIFEST hValidManifest = NIL_RTMANIFEST; 994 RTEXITCODE rcExit = ValidateExtPackTarball(hTarballFile, pszName, pszTarball, &hValidManifest); 926 995 if (rcExit == RTEXITCODE_SUCCESS) 927 rcExit = UnpackExtPack(hTarballFile, szTmpPath, pszTarball);996 rcExit = UnpackExtPack(hTarballFile, szTmpPath, hValidManifest, pszTarball); 928 997 if (rcExit == RTEXITCODE_SUCCESS) 929 998 rcExit = ValidateUnpackedExtPack(szTmpPath, pszTarball, pszName); 930 999 if (rcExit == RTEXITCODE_SUCCESS) 931 1000 rcExit = SetExtPackPermissions(szTmpPath); 1001 RTManifestRelease(hValidManifest); 1002 932 1003 if (rcExit == RTEXITCODE_SUCCESS) 933 1004 { -
trunk/src/VBox/Runtime/common/checksum/manifest2.cpp
r34418 r34442 676 676 677 677 678 #if 0 679 static int rtManifestReadLine(RTVFSIOSTREAM hVfsIos, char *pszLine, size_t cbLine) 680 { 681 /* This is horribly slow right now, but it's not a biggy as the input is 682 usually cached in memory somewhere... */ 683 *pszLine = '\0'; 684 while (cbLine > 1) 685 { 686 int rc = RTVfsIoStrmRead(hVfsIos, pszLine, 1, true /*fBLocking*/, NULL); 687 if (RT_FAILURE(rc)) 688 { 689 *pszLine = '\0'; 690 return rc == VERR_EOF ? VINF_EOF : rc; 691 } 692 } 693 return rc; 694 } 695 #endif 696 697 678 698 /** 679 699 * Reads in a "standard" manifest.
Note:
See TracChangeset
for help on using the changeset viewer.