ObjFW
OFSandbox.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
20 @class OFArray OF_GENERIC(ObjectType);
21 @class OFMutableArray OF_GENERIC(ObjectType);
22 @class OFPair OF_GENERIC(FirstType, SecondType);
23 
24 typedef OFPair OF_GENERIC(OFString *, OFString *) *OFSandboxUnveilPath;
25 
26 OF_SUBCLASSING_RESTRICTED
27 @interface OFSandbox: OFObject <OFCopying>
28 {
29  unsigned int _allowsStdIO: 1;
30  unsigned int _allowsReadingFiles: 1;
31  unsigned int _allowsWritingFiles: 1;
32  unsigned int _allowsCreatingFiles: 1;
33  unsigned int _allowsCreatingSpecialFiles: 1;
34  unsigned int _allowsTemporaryFiles: 1;
35  unsigned int _allowsIPSockets: 1;
36  unsigned int _allowsMulticastSockets: 1;
37  unsigned int _allowsChangingFileAttributes: 1;
38  unsigned int _allowsFileOwnerChanges: 1;
39  unsigned int _allowsFileLocks: 1;
40  unsigned int _allowsUNIXSockets: 1;
41  unsigned int _allowsDNS: 1;
42  unsigned int _allowsUserDatabaseReading: 1;
43  unsigned int _allowsFileDescriptorSending: 1;
44  unsigned int _allowsFileDescriptorReceiving: 1;
45  unsigned int _allowsTape: 1;
46  unsigned int _allowsTTY: 1;
47  unsigned int _allowsProcessOperations: 1;
48  unsigned int _allowsExec: 1;
49  unsigned int _allowsProtExec: 1;
50  unsigned int _allowsSetTime: 1;
51  unsigned int _allowsPS: 1;
52  unsigned int _allowsVMInfo: 1;
53  unsigned int _allowsChangingProcessRights: 1;
54  unsigned int _allowsPF: 1;
55  unsigned int _allowsAudio: 1;
56  unsigned int _allowsBPF: 1;
57  unsigned int _allowsUnveil: 1;
58  unsigned int _returnsErrors: 1;
59  OFMutableArray OF_GENERIC(OFSandboxUnveilPath) *_unveiledPaths;
60 @public
61  size_t _unveiledPathsIndex;
62 }
63 
64 @property (nonatomic) bool allowsStdIO;
65 @property (nonatomic) bool allowsReadingFiles;
66 @property (nonatomic) bool allowsWritingFiles;
67 @property (nonatomic) bool allowsCreatingFiles;
68 @property (nonatomic) bool allowsCreatingSpecialFiles;
69 @property (nonatomic) bool allowsTemporaryFiles;
70 @property (nonatomic) bool allowsIPSockets;
71 @property (nonatomic) bool allowsMulticastSockets;
72 @property (nonatomic) bool allowsChangingFileAttributes;
73 @property (nonatomic) bool allowsFileOwnerChanges;
74 @property (nonatomic) bool allowsFileLocks;
75 @property (nonatomic) bool allowsUNIXSockets;
76 @property (nonatomic) bool allowsDNS;
77 @property (nonatomic) bool allowsUserDatabaseReading;
78 @property (nonatomic) bool allowsFileDescriptorSending;
79 @property (nonatomic) bool allowsFileDescriptorReceiving;
80 @property (nonatomic) bool allowsTape;
81 @property (nonatomic) bool allowsTTY;
82 @property (nonatomic) bool allowsProcessOperations;
83 @property (nonatomic) bool allowsExec;
84 @property (nonatomic) bool allowsProtExec;
85 @property (nonatomic) bool allowsSetTime;
86 @property (nonatomic) bool allowsPS;
87 @property (nonatomic) bool allowsVMInfo;
88 @property (nonatomic) bool allowsChangingProcessRights;
89 @property (nonatomic) bool allowsPF;
90 @property (nonatomic) bool allowsAudio;
91 @property (nonatomic) bool allowsBPF;
92 @property (nonatomic) bool allowsUnveil;
93 @property (nonatomic) bool returnsErrors;
94 #ifdef OF_HAVE_PLEDGE
95 @property (readonly, nonatomic) OFString *pledgeString;
96 #endif
97 @property (readonly, nonatomic)
98  OFArray OF_GENERIC(OFSandboxUnveilPath) *unveiledPaths;
99 
100 + (instancetype)sandbox;
101 - (void)unveilPath: (OFString *)path permissions: (OFString *)permissions;
102 @end
103 
104 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:103
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:43
A class for storing a pair of two objects.
Definition: OFPair.h:25
A class for handling strings.
Definition: OFString.h:134
A protocol for the creation of copies.
Definition: OFObject.h:1346