diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-08-24 22:43:43 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-08-25 00:29:19 +0300 |
commit | 70a05c8ee8129941c801bb0e6bc93ea8e42bc254 (patch) | |
tree | d96fc73a45b883c799325e098ef69c94a1720232 /ucb | |
parent | fa9ef668fb8b0abfdf85d641048580fa7c2fee3e (diff) |
Avoid OS X sandbox messages when just checking if a pathname is a directory
Calling stat() on an arbitrary directory doesn't cause any sandbox
violation, it seems, even if the process has no access to that
directory. Calling opendir() on it is a sandbox violation.
Change-Id: I776c04653cbeeb511a4a1e455fcc2b10ed4a0e5c
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/file/shell.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx index b9c0390551ed..a9cd7e44ad81 100644 --- a/ucb/source/ucp/file/shell.cxx +++ b/ucb/source/ucp/file/shell.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_features.h> + +#include <sys/stat.h> + #include <stack> #include "osl/diagnose.h" #include <rtl/uri.hxx> @@ -2074,6 +2078,23 @@ sal_Bool SAL_CALL shell::ensuredir( sal_Int32 CommandId, else aPath = rUnqPath; +#if HAVE_FEATURE_MACOSX_SANDBOX + + // Avoid annoying sandbox messages in the system.log from the + // below aDirectory.open(), which ends up calling opendir(). + // Surely it is easier to just call stat()? Calling stat() on an + // arbitrary (?) directory does not seem to cause any sandbox + // violation, while opendir() does. (Sorry I could not be bothered + // to use some complex cross-platform abstraction over stat() here + // in this OS X specific code block.) + + OUString aDirName; + struct stat s; + if( osl::FileBase::getSystemPathFromFileURL( aPath, aDirName ) == osl::FileBase::E_None && + stat(OUStringToOString( aDirName, RTL_TEXTENCODING_UTF8).getStr(), &s ) == 0 && + S_ISDIR( s.st_mode ) ) + return sal_True; +#endif // HACK: create directory on a mount point with nobrowse option // returns ENOSYS in any case !! |