Differences From Artifact [edd8dd6d33]:
- File
utils/ofarc/OFArc.m
— part of check-in
[510628432f]
at
2020-12-22 13:16:28
on branch 1.0
— Make OFSandbox private
It is unclear whether the same API can be applied to other sandboxing
frameworks. (user: js, size: 21234) [annotate] [blame] [check-ins using]
To Artifact [e174e86e3a]:
- File utils/ofarc/OFArc.m — part of check-in [564d6d6b6f] at 2021-03-30 21:23:18 on branch 1.0 — Merge trunk into 1.0 branch (user: js, size: 21107) [annotate] [blame] [check-ins using] [more...]
1 | /* | < < | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
322 323 324 325 326 327 328 | #ifdef OF_HAVE_SANDBOX if (![remainingArguments.firstObject isEqual: @"-"]) [sandbox unveilPath: remainingArguments.firstObject permissions: (mode == 'a' ? @"rwc" : @"wc")]; for (OFString *path in files) | | < | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | #ifdef OF_HAVE_SANDBOX if (![remainingArguments.firstObject isEqual: @"-"]) [sandbox unveilPath: remainingArguments.firstObject permissions: (mode == 'a' ? @"rwc" : @"wc")]; for (OFString *path in files) [sandbox unveilPath: path permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif archive = [self openArchiveWithPath: remainingArguments.firstObject |
︙ | ︙ | |||
396 397 398 399 400 401 402 | #ifdef OF_HAVE_SANDBOX if (![remainingArguments.firstObject isEqual: @"-"]) [sandbox unveilPath: remainingArguments.firstObject permissions: @"r"]; if (files.count > 0) for (OFString *path in files) | | < | < | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | #ifdef OF_HAVE_SANDBOX if (![remainingArguments.firstObject isEqual: @"-"]) [sandbox unveilPath: remainingArguments.firstObject permissions: @"r"]; if (files.count > 0) for (OFString *path in files) [sandbox unveilPath: path permissions: @"wc"]; else { OFString *path = (outputDir != nil ? outputDir : OF_PATH_CURRENT_DIRECTORY); /* We need 'r' to change the directory to it. */ [sandbox unveilPath: path permissions: @"rwc"]; } sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif archive = [self |
︙ | ︙ | |||
510 511 512 513 514 515 516 | file = of_stdin; break; default: @throw [OFInvalidArgumentException exception]; } } else { @try { | | < | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | file = of_stdin; break; default: @throw [OFInvalidArgumentException exception]; } } else { @try { file = [OFFile fileWithPath: path mode: fileModeString]; } @catch (OFOpenItemFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; [of_stderr writeString: @"\r"]; [of_stderr writeLine: OF_LOCALIZED( @"failed_to_open_file", |
︙ | ︙ | |||
689 690 691 692 693 694 695 | toStream: (OFStream *)output fileName: (OFString *)fileName { char buffer[BUFFER_SIZE]; size_t length; @try { | | < | < | 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | toStream: (OFStream *)output fileName: (OFString *)fileName { char buffer[BUFFER_SIZE]; size_t length; @try { length = [input readIntoBuffer: buffer length: BUFFER_SIZE]; } @catch (OFReadFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; [of_stdout writeString: @"\r"]; [of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file", @"Failed to read file %[file]: %[error]", @"file", fileName, @"error", error)]; return -1; } @try { [output writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; [of_stdout writeString: @"\r"]; [of_stderr writeLine: OF_LOCALIZED(@"failed_to_write_file", @"Failed to write file %[file]: %[error]", |
︙ | ︙ |