@@ -23,10 +23,11 @@ #import "OFFile.h" #import "OFFileManager.h" #import "OFOptionsParser.h" #import "OFStdIOStream.h" #import "OFLocalization.h" +#import "OFSandbox.h" #import "OFZIP.h" #import "GZIPArchive.h" #import "TarArchive.h" #import "ZIPArchive.h" @@ -131,18 +132,33 @@ { 't', @"type", 1, NULL, &type }, { 'v', @"verbose", 0, NULL, NULL }, { 'x', @"extract", 0, NULL, NULL }, { '\0', nil, 0, NULL, NULL } }; - OFOptionsParser *optionsParser = - [OFOptionsParser parserWithOptions: options]; + OFOptionsParser *optionsParser; of_unichar_t option, mode = '\0'; OFArray OF_GENERIC(OFString*) *remainingArguments, *files; id archive; + +#ifdef OF_HAVE_SANDBOX + OFSandbox *sandbox = [[OFSandbox alloc] init]; + @try { + [sandbox setAllowsStdIO: true]; + [sandbox setAllowsReadingFiles: true]; + [sandbox setAllowsWritingFiles: true]; + [sandbox setAllowsCreatingFiles: true]; + [sandbox setAllowsChangingFileAttributes: true]; + + [OFApplication activateSandbox: sandbox]; + } @finally { + [sandbox release]; + } +#endif [OFLocalization addLanguageDirectory: @LANGUAGE_DIR]; + optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'f': if (_overwrite < 0) mutuallyExclusiveError(