Title: [198930] trunk/Tools
Revision
198930
Author
[email protected]
Date
2016-03-31 16:45:54 -0700 (Thu, 31 Mar 2016)

Log Message

run-webkit-tests fails to create user's cache directory when System Integrity Protection is enabled
https://bugs.webkit.org/show_bug.cgi?id=156071
<rdar://problem/25467827>

Reviewed by Brent Fulgham.

Fixes an issue where run-webkit-tests will fail to create the suffixed user's cache directory
on non-Apple Internal machines with System Integrity Protection enabled because the OS only
honors the suffix, specified by the environment variable DIRHELPER_USER_DIR_SUFFIX, in
privileged processes. And python(1) does not have sufficient privileges. As a workaround for
systems that have System Integrity Protection enabled we compute the path to the suffixed
user's cache directory by hand.

Additionally, fix an issue where the user's cache directory created by run-webkit-test was
never deleted on cessation of the test run.

* Scripts/webkitpy/port/driver.py:
(Driver._start): Actually store the path to the user's cache directory in self._driver_user_cache_directory
so that we can delete this directory on cessation of the test run.
* Scripts/webkitpy/port/mac.py:
(MacPort):
(MacPort._path_to_user_cache_directory): Unset the environment variable DIRHELPER_USER_DIR_SUFFIX (if set),
query the OS for the path to the user's cache directory and concatenate this path with the
specified suffix.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (198929 => 198930)


--- trunk/Tools/ChangeLog	2016-03-31 23:33:56 UTC (rev 198929)
+++ trunk/Tools/ChangeLog	2016-03-31 23:45:54 UTC (rev 198930)
@@ -1,3 +1,30 @@
+2016-03-31  Daniel Bates  <[email protected]>
+
+        run-webkit-tests fails to create user's cache directory when System Integrity Protection is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=156071
+        <rdar://problem/25467827>
+
+        Reviewed by Brent Fulgham.
+
+        Fixes an issue where run-webkit-tests will fail to create the suffixed user's cache directory
+        on non-Apple Internal machines with System Integrity Protection enabled because the OS only
+        honors the suffix, specified by the environment variable DIRHELPER_USER_DIR_SUFFIX, in
+        privileged processes. And python(1) does not have sufficient privileges. As a workaround for
+        systems that have System Integrity Protection enabled we compute the path to the suffixed
+        user's cache directory by hand.
+
+        Additionally, fix an issue where the user's cache directory created by run-webkit-test was
+        never deleted on cessation of the test run.
+
+        * Scripts/webkitpy/port/driver.py:
+        (Driver._start): Actually store the path to the user's cache directory in self._driver_user_cache_directory
+        so that we can delete this directory on cessation of the test run.
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort):
+        (MacPort._path_to_user_cache_directory): Unset the environment variable DIRHELPER_USER_DIR_SUFFIX (if set),
+        query the OS for the path to the user's cache directory and concatenate this path with the
+        specified suffix.
+
 2016-03-31  Jiewen Tan  <[email protected]>
 
         WebKit should set Original URL of a download request correctly

Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (198929 => 198930)


--- trunk/Tools/Scripts/webkitpy/port/driver.py	2016-03-31 23:33:56 UTC (rev 198929)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py	2016-03-31 23:45:54 UTC (rev 198930)
@@ -350,7 +350,8 @@
         self._driver_user_directory_suffix = os.path.basename(str(self._driver_tempdir))
         user_cache_directory = self._port._path_to_user_cache_directory(self._driver_user_directory_suffix)
         if user_cache_directory:
-            self._driver_user_cache_directory = self._port._filesystem.maybe_make_directory(user_cache_directory)
+            self._port._filesystem.maybe_make_directory(user_cache_directory)
+            self._driver_user_cache_directory = user_cache_directory
         server_name = self._port.driver_name()
         environment = self._port.setup_environ_for_server(server_name)
         environment = self._setup_environ_for_driver(environment)

Modified: trunk/Tools/Scripts/webkitpy/port/mac.py (198929 => 198930)


--- trunk/Tools/Scripts/webkitpy/port/mac.py	2016-03-31 23:33:56 UTC (rev 198929)
+++ trunk/Tools/Scripts/webkitpy/port/mac.py	2016-03-31 23:45:54 UTC (rev 198930)
@@ -118,12 +118,19 @@
         self._filesystem.rmtree(os.path.expanduser('~/Library/WebKit/' + self.driver_name()))
 
     def _path_to_user_cache_directory(self, suffix=None):
-        DIRHELPER_USER_DIR_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX"
+        DIRHELPER_USER_DIR_SUFFIX = 'DIRHELPER_USER_DIR_SUFFIX'
+        CS_DARWIN_USER_CACHE_DIR = 65538
+
+        # The environment variable DIRHELPER_USER_DIR_SUFFIX is only honored on systems with
+        # System Integrity Protection disabled or with an Apple-Internal OS. To make this code
+        # work for all system configurations we compute the path with respect to the suffix
+        # by hand and temporarily unset the environment variable DIRHELPER_USER_DIR_SUFFIX (if set)
+        # to avoid it influencing confstr() on systems that honor DIRHELPER_USER_DIR_SUFFIX.
         saved_suffix = None
-        if suffix is not None:
-            saved_suffix = os.environ.get(DIRHELPER_USER_DIR_SUFFIX)
-            os.environ[DIRHELPER_USER_DIR_SUFFIX] = suffix
-        result = os.confstr(65538)  # _CS_DARWIN_USER_CACHE_DIR
+        if DIRHELPER_USER_DIR_SUFFIX in os.environ:
+            saved_suffix = os.environ[DIRHELPER_USER_DIR_SUFFIX]
+            del os.environ[DIRHELPER_USER_DIR_SUFFIX]
+        result = os.path.join(os.confstr(CS_DARWIN_USER_CACHE_DIR), suffix or '')
         if saved_suffix is not None:
             os.environ[DIRHELPER_USER_DIR_SUFFIX] = saved_suffix
         return result
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to