VirtualBox

Changeset 83033 in vbox


Ignore:
Timestamp:
Feb 10, 2020 1:40:54 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136055
Message:

/Config.kmk,/Makefile.kmk,Installer/darwin,FE/QT,SUPHard: Eliminated the symlinks under Resources/VirtualBoxVM.app to avoid confusing codesign and notarization. bugref:9466
Note! Best to do a clean build on mac (or at a minimum rm -Rf out/darwin.amd64/*/dist/VirtualBox.app/Contents/Frameworks/ out/darwin.amd64/*/dist/VirtualBox.app/Contents/plugins/).

  • SUPHard: Added new location SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP (darwin only) for indicating a helper application and that hardened dylib and the rest of VirtualBox isn't in the executable directory.
  • SUPHard: Added a corresponding internal path ID kSupID_AppMacHelper (darwin only) for finding VirtualBoxVM for verification now that it is no longer in the main app binary directory.
  • /Config.kmk: Run install_name_tool after linking Qt binaries on darwin fix the Qt import paths (@executable_path/../Frameworks/ doesn't work for VirtualBoxVM any more).
  • /Makefile.kmk: Run install_name_tool during installation of Qt frameworks and plugins to use @rpath in non-hardened builds and the absolute paths in hardened ones (latter done by Installer/darwin/Makefile.kmk previously).
  • FE/Qt,Installer/darwin: Adjustments and path hacks.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r82997 r83033  
    67586758 endif # not darwin, os2 or win
    67596759
     6760 ifeq ($(KBUILD_TARGET),darwin)
     6761  TEMPLATE_VBOXQTGUIEXE_POST_CMDS = $(QUIET)install_name_tool $(foreach qtmod, $(VBOX_QT_MOD_NAMES), \
     6762        $(foreach prefix, @executable_path/../Frameworks/ $(VBOX_PATH_QT)/Frameworks/ $(PATH_SDK_QT)/, \
     6763                -change "$(prefix)$(qtmod).framework/Versions/5/$(qtmod)" \
     6764                        "$(if $(VBOX_WITH_HARDENING),/Applications/VirtualBox.app/Contents/Frameworks,@rpath)/$(qtmod).framework/Versions/5/$(qtmod)" ) ) "$(out)"
     6765 endif
    67606766
    67616767 #
  • trunk/Makefile.kmk

    r82968 r83033  
    179179        Frameworks/$(qtmod).framework/$(qtmod)=>Versions/5/$(qtmod) \
    180180        Frameworks/$(qtmod).framework/Resources=>Versions/5/Resources)
     181 qt5-bin_INSTALLER = $(INSTALL) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) $(if $(mode),-m $(mode)) $(4) -- \
     182                        "$(1)" "$(2)" $(if-expr "$(source_type_prefix)" == "EXEC_" \
     183                        ,$(NLTAB)install_name_tool \
     184                        $(if-expr "$(suffix $2)" == "", -id "$(if $(VBOX_WITH_HARDENING),/Applications/VirtualBox.app/Contents/Framework,@rpath)/$(notdir $(2)).framework/Version/5/$(notdir $(2))",) \
     185                        $(foreach qtmod, $(VBOX_QT_MOD_NAMES), \
     186                                $(foreach prefix, @executable_path/../Frameworks/ $(VBOX_PATH_QT)/Frameworks/ $(PATH_SDK_QT)/, \
     187                                -change "$(prefix)$(qtmod).framework/Versions/5/$(qtmod)" \
     188                                        "$(if $(VBOX_WITH_HARDENING),/Applications/VirtualBox.app/Contents/Frameworks,@rpath)/$(qtmod).framework/Versions/5/$(qtmod)" ) ) \
     189                        "$(2)",) # HACK ALERT! Using $(source_type_prefix) to detect EXEC_SOURCES.
    181190else # win x11
    182191 if1of ($(KBUILD_TARGET), linux solaris)
  • trunk/include/VBox/sup.h

    r82968 r83033  
    11841184/** The hardened DLL has a "TrustedError" function (see FNSUPTRUSTEDERROR). */
    11851185#define SUPSECMAIN_FLAGS_TRUSTED_ERROR      RT_BIT_32(1)
    1186 /** Hack for making VirtualBoxVM use VirtualBox.dylib on Mac OS X. */
     1186/** Hack for making VirtualBoxVM use VirtualBox.dylib on Mac OS X.
     1187 * @note Not used since 6.0  */
    11871188#define SUPSECMAIN_FLAGS_OSX_VM_APP         RT_BIT_32(2)
    11881189/** Program binary location mask. */
    1189 #define SUPSECMAIN_FLAGS_LOC_MASK           UINT32_C(0x00000010)
     1190#define SUPSECMAIN_FLAGS_LOC_MASK           UINT32_C(0x00000030)
    11901191/** Default binary location is the application binary directory.  Does
    11911192 * not need to be given explicitly (it's 0).  */
     
    11941195 * default application binary directory. */
    11951196#define SUPSECMAIN_FLAGS_LOC_TESTCASE       UINT32_C(0x00000010)
    1196 /** The first process. */
    1197 #define SUPSECMAIN_FLAGS_FIRST_PROCESS      UINT32_C(0x00000020)
     1197/** The binary is located in a nested application bundle under Resources/ in the
     1198 * main Mac OS X application (think Resources/VirtualBoxVM.app).  */
     1199#define SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP    UINT32_C(0x00000020)
     1200/** The first process.
     1201 * @internal  */
     1202#define SUPSECMAIN_FLAGS_FIRST_PROCESS      UINT32_C(0x00000100)
    11981203/** @} */
    11991204
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r83008 r83033  
    5555ifdef VBOX_WITH_HARDENING
    5656VirtualBoxHardenedVM_TEMPLATE = VBOXR3HARDENEDEXE
     57VirtualBoxHardenedVM_INST.darwin = $(INST_VIRTUALBOX)Contents/Resources/VirtualBoxVM.app/Contents/MacOS/
     58VirtualBoxHardenedVM_NAME = VirtualBoxVM
    5759VirtualBoxHardenedVM_SOURCES = src/hardenedmain.cpp
    58 VirtualBoxHardenedVM_NAME = VirtualBoxVM
    5960VirtualBoxHardenedVM_LDFLAGS.win = /SUBSYSTEM:$(if-expr "$(KBUILD_TYPE)" != "release",console,windows)
    6061$(call VBOX_SET_VER_INFO_EXE,VirtualBoxHardenedVM,VirtualBox Virtual Machine,$(VBOX_WINDOWS_ICON_FILE))
     
    161162VirtualBoxVM_TEMPLATE       := $(if $(VBOX_WITH_HARDENING),VBOXQTGUI,VBOXQTGUIEXE)
    162163VirtualBoxVM_NAME           = VirtualBoxVM
     164ifndef VBOX_WITH_HARDENING
     165VirtualBoxVM_INST.darwin    = $(INST_VIRTUALBOX)Contents/Resources/VirtualBoxVM.app/Contents/MacOS/
     166endif
    163167VirtualBoxVM_DEPS           = $(UICommon_0_OUTDIR)/include/COMWrappers
    164168VirtualBoxVM_SDKS.win       = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK)
     
    388392
    389393VirtualBox_LDFLAGS.darwin = \
     394        $(if $(VBOX_WITH_HARDENING),,-rpath @executable_path/../MacOS -rpath @executable_path/../Frameworks) \
    390395        -framework AppKit -framework Carbon -framework IOKit
    391396
     
    422427
    423428VirtualBoxVM_LDFLAGS.darwin = \
     429        $(if $(VBOX_WITH_HARDENING)\
     430        ,-install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VirtualBoxVM.dylib \
     431        ,-rpath @executable_path/../../../../MacOS \
     432        -rpath @executable_path/../../../../Frameworks) \
    424433        -framework AppKit -framework Carbon -framework IOKit \
    425         $(if $(VBOX_WITH_HARDENING),-install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VirtualBoxVM.dylib)
    426434
    427435if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_GUI_USE_QGL)
     
    447455
    448456UICommon_LDFLAGS.darwin = \
    449         -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/UICommon.dylib \
     457        -install_name "$(VBOX_DYLD_EXECUTABLE_PATH)/UICommon.dylib" \
    450458        -framework AppKit \
    451459        -framework Carbon \
     
    17781786        $(VirtualBoxVM.app_0_OUTDIR)/VM-Info.plist=>Info.plist \
    17791787        $(foreach mysrc,$(VirtualBox.app_SOURCES),$(if-expr $(pos =>Resources/,$(mysrc)) > 0,$(mysrc),))
    1780  VirtualBoxVM.app_SYMLINKS = \
    1781         MacOS=>../../../MacOS/ \
    1782         plugins=>../../../plugins/ \
    1783         Frameworks=>../../../Frameworks/
    17841788
    17851789 $$(VirtualBoxVM.app_0_OUTDIR)/VM-Info.plist: $(PATH_SUB_CURRENT)/src/platform/darwin/VM-Info.plist $(VBOX_VERSION_MK) | $$(@D)/
  • trunk/src/VBox/Frontends/VirtualBox/src/hardenedmain.cpp

    r82968 r83033  
    6464
    6565    uint32_t fFlags = (fStartVM && !fSeparateProcess) ? 0 : SUPSECMAIN_FLAGS_DONT_OPEN_DEV;
     66#ifdef RT_OS_DARWIN
     67    fFlags |= SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP;
     68#endif
    6669
    6770    return SUPR3HardenedMain("VirtualBoxVM",
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r82968 r83033  
    5454# include <iprt/ctype.h>
    5555#endif
     56#if defined(VBOX_RUNTIME_UI) && defined(VBOX_WS_MAC)
     57# include <iprt/path.h>
     58#endif
    5659
    5760/* Other includes: */
     
    5962# include <dlfcn.h>
    6063# include <sys/mman.h>
     64# ifdef VBOX_RUNTIME_UI
     65//# include <mach-o/dyld.h>
     66extern "C" const char *_dyld_get_image_name(uint32_t);
     67# endif
    6168#endif /* VBOX_WS_MAC */
    6269#ifdef VBOX_WS_X11
     
    702709        /* Instantiate own NSApplication before QApplication do it for us: */
    703710        UICocoaApplication::instance();
     711
     712# ifdef VBOX_RUNTIME_UI
     713        /* If we're a helper app inside Resources in the main application bundle,
     714           we need to amend the library path so the platform plugin can be found.
     715           Note! This builds on the initIprtForDarwinHelperApp() hack. */
     716        {
     717            char szExecDir[RTPATH_MAX];
     718            int vrc = RTPathExecDir(szExecDir, sizeof(szExecDir));
     719            AssertRC(vrc);
     720            RTPathStripTrailingSlash(szExecDir); /* .../Contents/MacOS */
     721            RTPathStripFilename(szExecDir);      /* .../Contents */
     722            RTPathAppend(szExecDir, sizeof(szExecDir), "plugins");      /* .../Contents/plugins */
     723            QCoreApplication::addLibraryPath(QString::fromUtf8(szExecDir));
     724        }
     725# endif
    704726#endif /* VBOX_WS_MAC */
    705727
     
    842864
    843865#if !defined(VBOX_WITH_HARDENING) || !defined(VBOX_RUNTIME_UI)
     866
     867# if defined(RT_OS_DARWIN) && defined(VBOX_RUNTIME_UI)
     868/** Init runtime with the executable path pointing into the
     869 * VirtualBox.app/Contents/MacOS/ rather than
     870 * VirtualBox.app/Contents/Resource/VirtualBoxVM.app/Contents/MacOS/.
     871 *
     872 * This is a HACK to make codesign and friends happy on OS X.   The idea is to
     873 * improve and eliminate this over time.
     874 */
     875DECL_NO_INLINE(static, int) initIprtForDarwinHelperApp(int cArgs, char ***ppapszArgs, uint32_t fFlags)
     876{
     877    const char *pszImageName = _dyld_get_image_name(0);
     878    AssertReturn(pszImageName, VERR_INTERNAL_ERROR);
     879
     880    char szTmpPath[PATH_MAX + 1];
     881    const char *psz = realpath(pszImageName, szTmpPath);
     882    int rc;
     883    if (psz)
     884    {
     885        char *pszFilename = RTPathFilename(szTmpPath);
     886        if (pszFilename)
     887        {
     888            char const chSavedFilename0 = *pszFilename;
     889            *pszFilename = '\0';
     890            RTPathStripTrailingSlash(szTmpPath); /* VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS */
     891            RTPathStripFilename(szTmpPath);      /* VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/ */
     892            RTPathStripFilename(szTmpPath);      /* VirtualBox.app/Contents/Resources/VirtualBoxVM.app */
     893            RTPathStripFilename(szTmpPath);      /* VirtualBox.app/Contents/Resources */
     894            RTPathStripFilename(szTmpPath);      /* VirtualBox.app/Contents */
     895            char *pszDst = strchr(szTmpPath, '\0');
     896            pszDst = (char *)memcpy(pszDst, RT_STR_TUPLE("/MacOS/")) + sizeof("/MacOS/") - 1; /** @todo where is mempcpy? */
     897            *pszFilename = chSavedFilename0;
     898            memmove(pszDst, pszFilename, strlen(pszFilename) + 1);
     899
     900            return RTR3InitEx(RTR3INIT_VER_CUR, fFlags, cArgs, ppapszArgs, szTmpPath);
     901        }
     902        rc = VERR_INVALID_NAME;
     903    }
     904    else
     905        rc = RTErrConvertFromErrno(errno);
     906    AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhxs\n", rc, pszImageName, strlen(pszImageName), pszImageName), rc);
     907    return rc;
     908}
     909# endif
     910
    844911
    845912int main(int argc, char **argv, char **envp)
     
    871938
    872939    uint32_t fFlags = fStartVM && !fSeparateProcess ? RTR3INIT_FLAGS_SUPLIB : 0;
     940# ifdef RT_OS_DARWIN
     941    int rc = initIprtForDarwinHelperApp(argc, &argv, fFlags);
    873942# else
    874     uint32_t fFlags = 0;
    875 # endif
    876943    int rc = RTR3InitExe(argc, &argv, fFlags);
     944# endif
     945# else
     946    int rc = RTR3InitExe(argc, &argv, 0 /*fFlags*/);
     947# endif
    877948
    878949    /* Initialization failed: */
  • trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h

    r82968 r83033  
    185185    kSupID_AppPrivNoArch,
    186186    kSupID_Testcase,
     187#ifdef RT_OS_DARWIN
     188    kSupID_AppMacHelper,
     189#endif
    187190    kSupID_End
    188191} SUPINSTDIR;
     
    448451
    449452DECLHIDDEN(int)     supR3HardenedVerifyAll(bool fFatal, const char *pszProgName, const char *pszExePath, uint32_t fMainFlags);
    450 DECLHIDDEN(int)     supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal);
     453DECLHIDDEN(int)     supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal, PCSUPINSTFILE pFile);
    451454DECLHIDDEN(int)     supR3HardenedVerifyFixedFile(const char *pszFilename, bool fFatal);
    452455DECLHIDDEN(int)     supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r82968 r83033  
    452452#include <iprt/initterm.h>
    453453#include <iprt/param.h>
     454#include <iprt/path.h>
    454455
    455456#include "SUPLibInternal.h"
     
    542543/** The application bin directory path. */
    543544static char             g_szSupLibHardenedAppBinPath[RTPATH_MAX];
     545/** The offset into g_szSupLibHardenedExePath of the executable name. */
     546static size_t           g_offSupLibHardenedExecName;
     547/** The length of the executable name in g_szSupLibHardenedExePath. */
     548static size_t           g_cchSupLibHardenedExecName;
    544549
    545550/** The program name. */
     
    13451350    suplibHardenedPathStripFilename(g_szSupLibHardenedAppBinPath);
    13461351
     1352    g_offSupLibHardenedExecName = suplibHardenedStrLen(g_szSupLibHardenedAppBinPath);
     1353    while (RTPATH_IS_SEP(g_szSupLibHardenedExePath[g_offSupLibHardenedExecName]))
     1354           g_offSupLibHardenedExecName++;
     1355    g_cchSupLibHardenedExecName = suplibHardenedStrLen(&g_szSupLibHardenedExePath[g_offSupLibHardenedExecName]);
     1356
    13471357    if (g_enmSupR3HardenedMainState < SUPR3HARDENEDMAINSTATE_HARDENED_MAIN_CALLED)
    13481358        supR3HardenedFatal("supR3HardenedExecDir: Called before SUPR3HardenedMain! (%d)\n", g_enmSupR3HardenedMainState);
     
    13541364            suplibHardenedPathStripFilename(g_szSupLibHardenedAppBinPath);
    13551365            break;
     1366#ifdef RT_OS_DARWIN
     1367        case SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP:
     1368        {
     1369            /* We must ascend to the parent bundle's Contents directory then decend into its MacOS: */
     1370            static const RTSTRTUPLE s_aComponentsToSkip[] =
     1371            { { RT_STR_TUPLE("MacOS") }, { RT_STR_TUPLE("Contents") }, { NULL /*some.app*/, 0 }, { RT_STR_TUPLE("Resources") } };
     1372            size_t cchPath = suplibHardenedStrLen(g_szSupLibHardenedAppBinPath);
     1373            for (uintptr_t i = 0; i < RT_ELEMENTS(s_aComponentsToSkip); i++)
     1374            {
     1375                while (cchPath > 1 && g_szSupLibHardenedAppBinPath[cchPath - 1] == '/')
     1376                    cchPath--;
     1377                size_t const cchMatch = s_aComponentsToSkip[i].cch;
     1378                if (cchMatch > 0)
     1379                {
     1380                    if (   cchPath >= cchMatch + sizeof("VirtualBox.app/Contents")
     1381                        && g_szSupLibHardenedAppBinPath[cchPath - cchMatch - 1] == '/'
     1382                        && suplibHardenedMemComp(&g_szSupLibHardenedAppBinPath[cchPath - cchMatch],
     1383                                                 s_aComponentsToSkip[i].psz, cchMatch) == 0)
     1384                        cchPath -= cchMatch;
     1385                    else
     1386                        supR3HardenedFatal("supR3HardenedExecDir: Bad helper app path (tail component #%u '%s'): %s\n",
     1387                                           i, s_aComponentsToSkip[i].psz, g_szSupLibHardenedAppBinPath);
     1388                }
     1389                else if (   cchPath > g_cchSupLibHardenedExecName  + sizeof("VirtualBox.app/Contents/Resources/.app")
     1390                         && suplibHardenedMemComp(&g_szSupLibHardenedAppBinPath[cchPath - 4], ".app", 4) == 0
     1391                         && suplibHardenedMemComp(&g_szSupLibHardenedAppBinPath[cchPath - 4 - g_cchSupLibHardenedExecName],
     1392                                                  &g_szSupLibHardenedExePath[g_offSupLibHardenedExecName],
     1393                                                  g_cchSupLibHardenedExecName) == 0)
     1394                    cchPath -= g_cchSupLibHardenedExecName + 4;
     1395                else
     1396                    supR3HardenedFatal("supR3HardenedExecDir: Bad helper app path (tail component #%u '%s.app'): %s\n",
     1397                                       i, &g_szSupLibHardenedExePath[g_offSupLibHardenedExecName], g_szSupLibHardenedAppBinPath);
     1398            }
     1399            suplibHardenedMemCopy(&g_szSupLibHardenedAppBinPath[cchPath], "MacOS", sizeof("MacOS"));
     1400            break;
     1401        }
     1402#endif /* RT_OS_DARWIN */
    13561403        default:
    13571404            supR3HardenedFatal("supR3HardenedExecDir: Unknown program binary location: %#x\n", g_fSupHardenedMain);
     
    23262373    {
    23272374        case SUPSECMAIN_FLAGS_LOC_APP_BIN:
     2375#ifdef RT_OS_DARWIN
     2376        case SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP:
     2377#endif
    23282378            pszSubDirSlash = "/";
    23292379            break;
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp

    r82968 r83033  
    195195//#ifdef VBOX_WITH_QTGUI
    196196    {   kSupIFT_Exe,  kSupID_AppBin,             true, "VirtualBox" SUPLIB_EXE_SUFF },
     197# ifdef RT_OS_DARWIN
     198    {   kSupIFT_Exe,  kSupID_AppMacHelper,       true, "VirtualBoxVM" SUPLIB_EXE_SUFF },
     199# else
    197200    {   kSupIFT_Exe,  kSupID_AppBin,             true, "VirtualBoxVM" SUPLIB_EXE_SUFF },
     201# endif
    198202    {   kSupIFT_Dll,  kSupID_AppPrivArch,        true, "VirtualBoxVM" SUPLIB_DLL_SUFF },
    199203    {   kSupIFT_Dll,  kSupID_AppPrivArch,        true, "UICommon" SUPLIB_DLL_SUFF },
     
    267271 * @param   cchDst              The size of the buffer.
    268272 * @param   fFatal              Whether failures should be treated as fatal (true) or not (false).
    269  */
    270 static int supR3HardenedMakePath(SUPINSTDIR enmDir, char *pszDst, size_t cchDst, bool fFatal)
     273 * @param   pFile               The file (for darwin helper app paths).
     274 */
     275static int supR3HardenedMakePath(SUPINSTDIR enmDir, char *pszDst, size_t cchDst, bool fFatal, PCSUPINSTFILE pFile)
    271276{
    272277    int rc;
     
    307312            }
    308313            break;
     314#ifdef RT_OS_DARWIN
     315        case kSupID_AppMacHelper:
     316            rc = supR3HardenedPathAppBin(pszDst, cchDst);
     317            if (RT_SUCCESS(rc))
     318            {
     319                /* Up one level from the VirtualBox.app/Contents/MacOS directory: */
     320                size_t offDst = suplibHardenedStrLen(pszDst);
     321                while (offDst > 1 && pszDst[offDst - 1] == '/')
     322                    offDst--;
     323                while (offDst > 1 && pszDst[offDst - 1] != '/')
     324                    offDst--;
     325
     326                /* Construct the path to the helper application's Contents/MacOS directory: */
     327                size_t cchFile = suplibHardenedStrLen(pFile->pszFile);
     328                if (offDst + cchFile + sizeof("Resources/.app/Contents/MacOS") <= cchDst)
     329                {
     330                    suplibHardenedMemCopy(&pszDst[offDst], RT_STR_TUPLE("Resources/"));
     331                    offDst += sizeof("Resources/") - 1;
     332                    suplibHardenedMemCopy(&pszDst[offDst], pFile->pszFile, cchFile);
     333                    offDst += cchFile;
     334                    suplibHardenedMemCopy(&pszDst[offDst], RT_STR_TUPLE(".app/Contents/MacOS") + 1);
     335                }
     336                else
     337                    rc = VERR_BUFFER_OVERFLOW;
     338            }
     339            break;
     340#endif
    309341        default:
    310342            return supR3HardenedError(VERR_INTERNAL_ERROR, fFatal,
     
    314346        supR3HardenedError(rc, fFatal,
    315347                           "supR3HardenedMakePath: enmDir=%d rc=%d\n", enmDir, rc);
     348    NOREF(pFile);
    316349    return rc;
    317350}
     
    336369     * Combine supR3HardenedMakePath and the filename.
    337370     */
    338     int rc = supR3HardenedMakePath(pFile->enmDir, pszDst, cchDst, fFatal);
     371    int rc = supR3HardenedMakePath(pFile->enmDir, pszDst, cchDst, fFatal, pFile);
    339372    if (RT_SUCCESS(rc) && fWithFilename)
    340373    {
     
    363396 * @param   fFatal              Whether validation failures should be treated as
    364397 *                              fatal (true) or not (false).
    365  */
    366 DECLHIDDEN(int) supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal)
     398 * @param   pFile               The file (for darwin helper app paths).
     399 */
     400DECLHIDDEN(int) supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal, PCSUPINSTFILE pFile)
    367401{
    368402    /*
     
    391425     */
    392426    char szPath[RTPATH_MAX];
    393     int rc = supR3HardenedMakePath(enmDir, szPath, sizeof(szPath), fFatal);
     427    int rc = supR3HardenedMakePath(enmDir, szPath, sizeof(szPath), fFatal, pFile);
    394428    if (RT_SUCCESS(rc))
    395429    {
     
    676710     *  use openat if we wish.)
    677711     */
    678     int rc = supR3HardenedVerifyFixedDir(pFile->enmDir, fFatal);
     712    int rc = supR3HardenedVerifyFixedDir(pFile->enmDir, fFatal, pFile);
    679713    if (RT_SUCCESS(rc))
    680714    {
  • trunk/src/VBox/Installer/darwin/Makefile.kmk

    r82996 r83033  
    361361
    362362VBOX_DI_VBAPP_PROGS_HARDENED = \
    363         MacOS/VirtualBoxVM \
     363        Resources/VirtualBoxVM.app/Contents/MacOS/VirtualBoxVM \
    364364        MacOS/VBoxHeadless \
    365365        MacOS/VBoxNetDHCP \
     
    414414endif
    415415ifdef VBOX_WITH_HARDENING
    416  VBOX_DI_VBAPP_DYLIBS += $(addsuffix .dylib,$(VBOX_DI_VBAPP_PROGS_HARDENED))
     416 VBOX_DI_VBAPP_DYLIBS += $(addprefix MacOS/,$(addsuffix .dylib,$(notdir $(VBOX_DI_VBAPP_PROGS_HARDENED))))
    417417endif
    418418ifdef VBOX_WITH_HDDPARALLELS_INSTALL
     
    522522
    523523VBOX_DI_VBAPP_SYMLINKS = \
    524         Resources/VirtualBoxVM.app/Contents/MacOS=>../../../MacOS/ \
    525         Resources/VirtualBoxVM.app/Contents/plugins=>../../../plugins/ \
    526         Resources/VirtualBoxVM.app/Contents/Frameworks=>../../../Frameworks/ \
    527524        Resources/vmstarter.app/Contents/MacOS=>../../../MacOS/ \
    528525        $(foreach qtmod, $(VBOX_QT_MOD_NAMES) \
     
    684681        $(foreach prog, $(VBOX_DI_VBAPP_PROGS) $(VBOX_DI_VBAPP_PROGS_HARDENED) \
    685682                ,$(INSTALL) -m 0755 $(VBOX_PATH_DIST)/VirtualBox.app/Contents/$(prog)           $(VBOX_PATH_VBOX_APP_TMP)/Contents/$(prog)$(NLTAB))
    686 #ifdef VBOX_WITH_HARDENING - disabled temporarily
    687 if 1
    688         @# We cannot use @executable_path together with setuid binaries, dyld gets upset about it. So, fix Qt libs and users.
    689         $(foreach qtmod, $(VBOX_QT_MOD_NAMES) \
    690                 ,install_name_tool -id /Applications/VirtualBox.app/Contents/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    691                         $(VBOX_PATH_VBOX_APP_TMP)/Contents/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod)$(NLTAB) )
    692         $(foreach f, \
    693                 $(VBOX_DI_VBAPP_DYLIBS) \
    694                 $(VBOX_DI_VBAPP_DYLIBS.$(KBUILD_TARGET_ARCH)) \
    695                 $(VBOX_DI_VBAPP_PROGS) \
    696                 $(VBOX_DI_VBAPP_PROGS_HARDENED) \
    697                 ,install_name_tool \
    698                         $(foreach qtmod, $(VBOX_QT_MOD_NAMES), \
    699                                 -change           @executable_path/../Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    700                                 /Applications/VirtualBox.app/Contents/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    701                                 -change               $(VBOX_PATH_QT)/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    702                                 /Applications/VirtualBox.app/Contents/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    703                                 -change                           $(PATH_SDK_QT)/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    704                                 /Applications/VirtualBox.app/Contents/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    705                                 -change                                          $(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    706                                 /Applications/VirtualBox.app/Contents/Frameworks/$(qtmod).framework/Versions/$(VBOX_QT_VERSION_MAJOR)/$(qtmod) \
    707                                 ) \
    708                         $(VBOX_PATH_VBOX_APP_TMP)/Contents/$(f)$(NLTAB) )
    709 endif
    710683ifdef VBOX_UNATTENDED_TEMPLATES
    711684# Unattended installation template scripts.
     
    780753        sudo chmod u+s $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/VBoxNetAdpCtl
    781754ifdef VBOX_WITH_HARDENING
    782         sudo chmod u+s \
    783                 $(foreach bin,VBoxHeadless VirtualBoxVM VBoxNetDHCP VBoxNetNAT,\
    784                         $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/$(bin))
     755        sudo chmod u+s $(foreach bin,$(VBOX_DI_VBAPP_PROGS_HARDENED),$(VBOX_PATH_VBOX_APP_TMP)/Contents/$(bin))
     756endif
     757if 0 # Handy for testing the app bundle w/o having to reinstall all the time (just untar it into -C /Applications/)
     758        $(RM) -f -- "$(PATH_OUT)/VirtualBox.app.tar.gz"
     759        tar -czf "$(PATH_OUT)/VirtualBox.app.tar.gz" -C "$(VBOX_PATH_VBOX_APP_TMP)/.." VirtualBox.app
    785760endif
    786761        @# Do keyword replacement in the package info and description files.
Note: See TracChangeset for help on using the changeset viewer.

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