ObjFW  Diff

Differences From Artifact [db83d4326f]:

To Artifact [e8c3d87532]:


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44








45

46
47
48
49
50
51
52

#include <errno.h>
#include <signal.h>

#include "unistd_wrapper.h"

#import "OFApplication.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFLocale.h"
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFThread.h"
#import "OFThread+Private.h"
#import "OFSandbox.h"
#ifdef OF_AMIGAOS
# import "OFFile.h"
# import "OFFileManager.h"
#endif










#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFSandboxActivationFailedException.h"

#if defined(OF_MACOS)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)







<


<
<
<
<
<
<




>
>
>
>
>
>
>
>

>







25
26
27
28
29
30
31

32
33






34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

#include <errno.h>
#include <signal.h>

#include "unistd_wrapper.h"

#import "OFApplication.h"

#import "OFArray.h"
#import "OFDictionary.h"






#ifdef OF_AMIGAOS
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFLocale.h"
#import "OFPair.h"
#import "OFRunLoop+Private.h"
#import "OFRunLoop.h"
#import "OFSandbox.h"
#import "OFString.h"
#import "OFThread+Private.h"
#import "OFThread.h"

#import "OFInvalidArgumentException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFSandboxActivationFailedException.h"

#if defined(OF_MACOS)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
152
153
154
155
156
157
158
159




160
161
162
163
164
165
166
	[delegate release];

	return 0;
}

@implementation OFApplication
@synthesize programName = _programName, arguments = _arguments;
@synthesize environment = _environment, activeSandbox = _activeSandbox;





+ (OFApplication *)sharedApplication
{
	return app;
}

+ (OFString *)programName







|
>
>
>
>







154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
	[delegate release];

	return 0;
}

@implementation OFApplication
@synthesize programName = _programName, arguments = _arguments;
@synthesize environment = _environment;
#ifdef OF_HAVE_SANDBOX
@synthesize activeSandbox = _activeSandbox;
@synthesize activeExecSandbox = _activeExecSandbox;
#endif

+ (OFApplication *)sharedApplication
{
	return app;
}

+ (OFString *)programName
199
200
201
202
203
204
205





206
207
208
209
210
211
212
}

#ifdef OF_HAVE_SANDBOX
+ (void)activateSandbox: (OFSandbox *)sandbox
{
	[app activateSandbox: sandbox];
}





#endif

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}








>
>
>
>
>







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
}

#ifdef OF_HAVE_SANDBOX
+ (void)activateSandbox: (OFSandbox *)sandbox
{
	[app activateSandbox: sandbox];
}

+ (void)activateSandboxForExecdProcesses: (OFSandbox *)sandbox
{
	[app activateSandboxForExecdProcesses: sandbox];
}
#endif

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

579
580
581
582
583
584
585

586
587
588











589
590
591
592
593
594
595
596
597
598
599
600
601
























602
603
}

#ifdef OF_HAVE_SANDBOX
- (void)activateSandbox: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
	void *pool = objc_autoreleasePoolPush();

	const char *promises = [[sandbox pledgeString]
	    cStringWithEncoding: [OFLocale 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







>

|

>
>
>
>
>
>
>
>
>
>
>













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
}

#ifdef OF_HAVE_SANDBOX
- (void)activateSandbox: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
	void *pool = objc_autoreleasePoolPush();
	of_string_encoding_t encoding = [OFLocale encoding];
	const char *promises = [[sandbox pledgeString]
	    cStringWithEncoding: encoding];
	OFSandbox *oldSandbox;

	for (of_sandbox_unveil_path_t unveiledPath in [sandbox unveiledPaths]) {
		OFString *path = [unveiledPath firstObject];
		OFString *permissions = [unveiledPath secondObject];

		if (path == nil || permissions == nil)
			@throw [OFInvalidArgumentException exception];

		unveil([path cStringWithEncoding: encoding],
		    [permissions cStringWithEncoding: encoding]);
	}

	if (pledge(promises, NULL) != 0)
		@throw [OFSandboxActivationFailedException
		    exceptionWithSandbox: sandbox
				   errNo: errno];

	objc_autoreleasePoolPop(pool);

	oldSandbox = _activeSandbox;
	_activeSandbox = [sandbox retain];
	[oldSandbox release];
# endif
}

- (void)activateSandboxForExecdProcesses: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
	void *pool = objc_autoreleasePoolPush();
	const char *promises = [[sandbox pledgeString]
	    cStringWithEncoding: [OFLocale encoding]];
	OFSandbox *oldSandbox;

	if ([[sandbox unveiledPaths] count] != 0)
		@throw [OFInvalidArgumentException exception];

	if (pledge(NULL, promises) != 0)
		@throw [OFSandboxActivationFailedException
		    exceptionWithSandbox: sandbox
				   errNo: errno];

	objc_autoreleasePoolPop(pool);

	oldSandbox = _activeExecSandbox;
	_activeExecSandbox = [sandbox retain];
	[oldSandbox release];
# endif
}
#endif
@end