Changeset 271417 in webkit


Ignore:
Timestamp:
Jan 12, 2021 2:47:15 PM (3 years ago)
Author:
pvollan@apple.com
Message:

[macOS] Reset user directory suffix before getting sandbox directory
https://bugs.webkit.org/show_bug.cgi?id=220358
<rdar://problem/57616019>

Reviewed by Alexey Proskuryakov.

Source/WebCore/PAL:

Declare functions to get and set user directory suffix.

  • pal/spi/cocoa/CoreServicesSPI.h:

Source/WebKit:

Reset the user directory suffix before getting the sandbox data vault directory with confstr. We do not want to include the user
directory suffix, since the sandbox data vault will then end up inside the host process' cache folder, which is undesirable.
Also, creating the data vault directory with confstr can fail under some circumstances if the user directory suffix is not empty.
This patch also changes how we next set the user directory suffix for the process. Instead of setting the environment variable
DIRHELPER_USER_DIR_SUFFIX, we can use the SPI _set_user_dir_suffix. The behavior should be identical, but I believe it is better
to use SPI for this.

  • Shared/mac/AuxiliaryProcessMac.mm:

(WebKit::initializeSandboxParameters):
(WebKit::AuxiliaryProcess::initializeSandbox):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/PAL/ChangeLog

    r271405 r271417  
     12021-01-12  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [macOS] Reset user directory suffix before getting sandbox directory
     4        https://bugs.webkit.org/show_bug.cgi?id=220358
     5        <rdar://problem/57616019>
     6
     7        Reviewed by Alexey Proskuryakov.
     8
     9        Declare functions to get and set user directory suffix.
     10
     11        * pal/spi/cocoa/CoreServicesSPI.h:
     12
    1132021-01-12  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreServicesSPI.h

    r271333 r271417  
    2626#pragma once
    2727
    28 extern "C" void _CSCheckFixDisable();
    29 extern "C" CFArrayRef _UTCopyDeclaredTypeIdentifiers(void);
     28WTF_EXTERN_C_BEGIN
    3029
     30void _CSCheckFixDisable();
     31CFArrayRef _UTCopyDeclaredTypeIdentifiers(void);
     32
     33char *_get_user_dir_suffix();
     34bool _set_user_dir_suffix(const char *user_dir_suffix);
     35
     36WTF_EXTERN_C_END
  • trunk/Source/WebKit/ChangeLog

    r271415 r271417  
     12021-01-12  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [macOS] Reset user directory suffix before getting sandbox directory
     4        https://bugs.webkit.org/show_bug.cgi?id=220358
     5        <rdar://problem/57616019>
     6
     7        Reviewed by Alexey Proskuryakov.
     8
     9        Reset the user directory suffix before getting the sandbox data vault directory with confstr. We do not want to include the user
     10        directory suffix, since the sandbox data vault will then end up inside the host process' cache folder, which is undesirable.
     11        Also, creating the data vault directory with confstr can fail under some circumstances if the user directory suffix is not empty.
     12        This patch also changes how we next set the user directory suffix for the process. Instead of setting the environment variable
     13        DIRHELPER_USER_DIR_SUFFIX, we can use the SPI _set_user_dir_suffix. The behavior should be identical, but I believe it is better
     14        to use SPI for this.
     15
     16        * Shared/mac/AuxiliaryProcessMac.mm:
     17        (WebKit::initializeSandboxParameters):
     18        (WebKit::AuxiliaryProcess::initializeSandbox):
     19
    1202021-01-12  Don Olmstead  <don.olmstead@sony.com>
    221
  • trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm

    r271333 r271417  
    656656
    657657    // Use private temporary and cache directories.
    658     setenv("DIRHELPER_USER_DIR_SUFFIX", FileSystem::fileSystemRepresentation(sandboxParameters.userDirectorySuffix()).data(), 1);
     658    _set_user_dir_suffix(FileSystem::fileSystemRepresentation(sandboxParameters.userDirectorySuffix()).data());
    659659    char temporaryDirectory[PATH_MAX];
    660660    if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
     
    700700    // This must be called before initializeSandboxParameters so that the path does not include the user directory suffix.
    701701    // We don't want the user directory suffix because we want all processes of the same type to use the same cache directory.
     702    // First, make sure the user directory suffix is empty at this point. This is normally already the case, but some host
     703    // processes are setting the user directory suffix, which we will inherit, and our sandbox datavault will then end up
     704    // inside the host process' cache folder, which is undesirable.
     705    _set_user_dir_suffix(nullptr);
    702706    String dataVaultParentDirectory { sandboxDataVaultParentDirectory() };
    703707#else
Note: See TracChangeset for help on using the changeset viewer.