summaryrefslogtreecommitdiff
path: root/sal/osl/unx/file.cxx
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-08-24 16:07:22 +0300
committerTor Lillqvist <tml@iki.fi>2013-08-25 00:29:17 +0300
commitfcdfc62f760b7e33025973a460f90023b59bad8f (patch)
tree1beb55664e00e5e29fe4a174ff92d560acfa38b1 /sal/osl/unx/file.cxx
parentf8ed55b38c41a4fba3bbafaf03a39cf4718259e0 (diff)
Do more syscalls using a security scope bookmark on OS X when sandboxed
Move the handling of the bookmarks to the wrappers in uunxapi.cxx, and add wrappers for open() and utime(). Change-Id: I92f9941152b567545eea60f2aaae6a3b8d35e792
Diffstat (limited to 'sal/osl/unx/file.cxx')
-rw-r--r--sal/osl/unx/file.cxx51
1 files changed, 4 insertions, 47 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index cf9e49132d05..debccf93b3c1 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -29,6 +29,7 @@
#include "createfilehandlefromfd.hxx"
#include "file_error_transl.h"
#include "file_url.h"
+#include "uunxapi.h"
#include <algorithm>
#include <limits>
@@ -43,7 +44,7 @@
#include <sys/mount.h>
#define HAVE_O_EXLOCK
-#include <Foundation/Foundation.h>
+#include <CoreFoundation/CoreFoundation.h>
#endif /* MACOSX */
@@ -842,17 +843,6 @@ SAL_CALL osl_openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandl
#define OPEN_CREATE_FLAGS ( O_CREAT | O_RDWR )
#endif
-#if defined(MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX
-
-static NSUserDefaults *userDefaults = NULL;
-
-static void get_user_defaults()
-{
- userDefaults = [NSUserDefaults standardUserDefaults];
-}
-
-#endif
-
oslFileError
SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags )
{
@@ -916,41 +906,8 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u
flags = osl_file_adjustLockFlags (cpFilePath, flags);
}
-#if defined(MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX
- static pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once(&once, &get_user_defaults);
- NSURL *fileURL = NULL;
- NSData *data = NULL;
- NSURL *scopeURL = NULL;
- BOOL stale;
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (userDefaults != NULL)
- fileURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:cpFilePath]];
-
- if (fileURL != NULL)
- data = [userDefaults dataForKey:[@"bookmarkFor:" stringByAppendingString:[fileURL absoluteString]]];
-
- if (data != NULL)
- scopeURL = [NSURL URLByResolvingBookmarkData:data
- options:NSURLBookmarkResolutionWithSecurityScope
- relativeToURL:nil
- bookmarkDataIsStale:&stale
- error:nil];
- if (scopeURL != NULL)
- [scopeURL startAccessingSecurityScopedResource];
-#endif
-
/* open the file */
- int fd = open( cpFilePath, flags, mode );
-
-
-#if defined(MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX
- if (scopeURL != NULL)
- [scopeURL stopAccessingSecurityScopedResource];
- [pool release];
-#endif
+ int fd = open_c( cpFilePath, flags, mode );
#ifdef IOS
/* Horrible hack: If opening for RDWR and getting EPERM, just try
@@ -961,7 +918,7 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u
if (-1 == fd && (flags & O_RDWR) && EPERM == errno)
{
int rdonly_flags = (flags & ~O_ACCMODE) | O_RDONLY;
- fd = open( cpFilePath, rdonly_flags, mode );
+ fd = open_c( cpFilePath, rdonly_flags, mode );
}
#endif
if (-1 == fd)