ObjFW
OFSandbox.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFObject.h"
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
24 @class OFArray OF_GENERIC(ObjectType);
25 @class OFMutableArray OF_GENERIC(ObjectType);
26 @class OFPair OF_GENERIC(FirstType, SecondType);
27 
28 typedef OFPair OF_GENERIC(OFString *, OFString *) *OFSandboxUnveilPath;
29 
30 OF_SUBCLASSING_RESTRICTED
31 @interface OFSandbox: OFObject <OFCopying>
32 {
33  unsigned int _allowsStdIO: 1;
34  unsigned int _allowsReadingFiles: 1;
35  unsigned int _allowsWritingFiles: 1;
36  unsigned int _allowsCreatingFiles: 1;
37  unsigned int _allowsCreatingSpecialFiles: 1;
38  unsigned int _allowsTemporaryFiles: 1;
39  unsigned int _allowsIPSockets: 1;
40  unsigned int _allowsMulticastSockets: 1;
41  unsigned int _allowsChangingFileAttributes: 1;
42  unsigned int _allowsFileOwnerChanges: 1;
43  unsigned int _allowsFileLocks: 1;
44  unsigned int _allowsUNIXSockets: 1;
45  unsigned int _allowsDNS: 1;
46  unsigned int _allowsUserDatabaseReading: 1;
47  unsigned int _allowsFileDescriptorSending: 1;
48  unsigned int _allowsFileDescriptorReceiving: 1;
49  unsigned int _allowsTape: 1;
50  unsigned int _allowsTTY: 1;
51  unsigned int _allowsProcessOperations: 1;
52  unsigned int _allowsExec: 1;
53  unsigned int _allowsProtExec: 1;
54  unsigned int _allowsSetTime: 1;
55  unsigned int _allowsPS: 1;
56  unsigned int _allowsVMInfo: 1;
57  unsigned int _allowsChangingProcessRights: 1;
58  unsigned int _allowsPF: 1;
59  unsigned int _allowsAudio: 1;
60  unsigned int _allowsBPF: 1;
61  unsigned int _allowsUnveil: 1;
62  unsigned int _returnsErrors: 1;
63  OFMutableArray OF_GENERIC(OFSandboxUnveilPath) *_unveiledPaths;
64 @public
65  size_t _unveiledPathsIndex;
66 }
67 
68 @property (nonatomic) bool allowsStdIO;
69 @property (nonatomic) bool allowsReadingFiles;
70 @property (nonatomic) bool allowsWritingFiles;
71 @property (nonatomic) bool allowsCreatingFiles;
72 @property (nonatomic) bool allowsCreatingSpecialFiles;
73 @property (nonatomic) bool allowsTemporaryFiles;
74 @property (nonatomic) bool allowsIPSockets;
75 @property (nonatomic) bool allowsMulticastSockets;
76 @property (nonatomic) bool allowsChangingFileAttributes;
77 @property (nonatomic) bool allowsFileOwnerChanges;
78 @property (nonatomic) bool allowsFileLocks;
79 @property (nonatomic) bool allowsUNIXSockets;
80 @property (nonatomic) bool allowsDNS;
81 @property (nonatomic) bool allowsUserDatabaseReading;
82 @property (nonatomic) bool allowsFileDescriptorSending;
83 @property (nonatomic) bool allowsFileDescriptorReceiving;
84 @property (nonatomic) bool allowsTape;
85 @property (nonatomic) bool allowsTTY;
86 @property (nonatomic) bool allowsProcessOperations;
87 @property (nonatomic) bool allowsExec;
88 @property (nonatomic) bool allowsProtExec;
89 @property (nonatomic) bool allowsSetTime;
90 @property (nonatomic) bool allowsPS;
91 @property (nonatomic) bool allowsVMInfo;
92 @property (nonatomic) bool allowsChangingProcessRights;
93 @property (nonatomic) bool allowsPF;
94 @property (nonatomic) bool allowsAudio;
95 @property (nonatomic) bool allowsBPF;
96 @property (nonatomic) bool allowsUnveil;
97 @property (nonatomic) bool returnsErrors;
98 #ifdef OF_HAVE_PLEDGE
99 @property (readonly, nonatomic) OFString *pledgeString;
100 #endif
101 @property (readonly, nonatomic)
102  OFArray OF_GENERIC(OFSandboxUnveilPath) *unveiledPaths;
103 
104 + (instancetype)sandbox;
105 - (void)unveilPath: (OFString *)path permissions: (OFString *)permissions;
106 @end
107 
108 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:107
The root class for all other classes inside ObjFW.
Definition: OFObject.h:690
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:47
A class for storing a pair of two objects.
Definition: OFPair.h:29
A class for handling strings.
Definition: OFString.h:142
A protocol for the creation of copies.
Definition: OFObject.h:1350