Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -135,10 +135,11 @@ #ifndef OF_WINDOWS void (*_Nullable _SIGHUPHandler)(id, SEL); void (*_Nullable _SIGUSR1Handler)(id, SEL); void (*_Nullable _SIGUSR2Handler)(id, SEL); #endif + OFSandbox *_Nullable _activeSandbox; } #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nullable, nonatomic) OFApplication *sharedApplication; @@ -169,10 +170,15 @@ * @brief The delegate of the application. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id delegate; +/*! + * @brief The sandbox currently active for this application. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFSandbox *activeSandbox; + /*! * @brief Returns the only OFApplication instance in the application. * * @return The only OFApplication instance in the application */ Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -145,11 +145,11 @@ return 0; } @implementation OFApplication @synthesize programName = _programName, arguments = _arguments; -@synthesize environment = _environment; +@synthesize environment = _environment, activeSandbox = _activeSandbox; + (OFApplication *)sharedApplication { return app; } @@ -570,16 +570,21 @@ { # ifdef OF_HAVE_PLEDGE void *pool = objc_autoreleasePoolPush(); const char *promises = [[sandbox pledgeString] cStringWithEncoding: [OFLocalization encoding]]; + OFSandbox *oldSandbox; if (pledge(promises, NULL) != 0) @throw [OFSandboxActivationFailedException exceptionWithSandbox: sandbox errNo: errno]; objc_autoreleasePoolPop(pool); + + oldSandbox = _activeSandbox; + _activeSandbox = [sandbox retain]; + [oldSandbox release]; # endif } #endif @end