VirtualBox

Ignore:
Timestamp:
Jul 13, 2022 11:07:00 PM (2 years ago)
Author:
vboxsync
Message:

RTSignTool: Made sign-exe work for unsigned files. bugref:8691

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/tools/RTSignTool.cpp

    r95632 r95633  
    645645
    646646/**
    647  * Reads and decodes PKCS\#7 signature from the given executable.
     647 * Reads and decodes PKCS\#7 signature from the given executable, if it has one.
    648648 *
    649649 * @returns RTEXITCODE_SUCCESS on success, RTEXITCODE_FAILURE with error message
     
    653653 * @param   cVerbosity          The verbosity.
    654654 * @param   enmLdrArch          For FAT binaries.
     655 * @param   fAllowUnsigned      Whether to allow unsigned binaries.
    655656 */
    656 static RTEXITCODE SignToolPkcs7Exe_InitFromFile(PSIGNTOOLPKCS7EXE pThis, const char *pszFilename,
    657                                                 unsigned cVerbosity, RTLDRARCH enmLdrArch = RTLDRARCH_WHATEVER)
     657static RTEXITCODE SignToolPkcs7Exe_InitFromFile(PSIGNTOOLPKCS7EXE pThis, const char *pszFilename, unsigned cVerbosity,
     658                                                RTLDRARCH enmLdrArch = RTLDRARCH_WHATEVER, bool fAllowUnsigned = false)
    658659{
    659660    /*
     
    722723        }
    723724        else if (RT_SUCCESS(rc))
    724             RTMsgInfo("'%s': not signed\n", pszFilename);
     725        {
     726            if (!fAllowUnsigned || cVerbosity >= 2)
     727                RTMsgInfo("'%s': not signed\n", pszFilename);
     728            if (fAllowUnsigned)
     729                return RTEXITCODE_SUCCESS;
     730        }
    725731        else
    726732            RTMsgError("RTLdrQueryProp/RTLDRPROP_IS_SIGNED failed on '%s': %Rrc\n", pszFilename, rc);
     
    851857                                RTMsgError("Error truncating file to %#x bytes: %Rrc", pSecDir->VirtualAddress, rc);
    852858                        }
    853                         else
     859                        else if (pSecDir->Size != 0 && pSecDir->VirtualAddress == 0)
    854860                            rc = RTMsgErrorRc(VERR_BAD_EXE_FORMAT, "Bad security directory entry: VA=%#x Size=%#x",
    855861                                              pSecDir->VirtualAddress, pSecDir->Size);
     
    24052411                    /* Do the work: */
    24062412                    SIGNTOOLPKCS7EXE Exe;
    2407                     /** @todo will fail if not already signed. */
    2408                     rcExit2 = SignToolPkcs7Exe_InitFromFile(&Exe, ValueUnion.psz, cVerbosity);
     2413                    rcExit2 = SignToolPkcs7Exe_InitFromFile(&Exe, ValueUnion.psz, cVerbosity,
     2414                                                            RTLDRARCH_WHATEVER, true /*fAllowUnsigned*/);
    24092415                    if (rcExit2 == RTEXITCODE_SUCCESS)
    24102416                    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette