Skip to content

Commit

Permalink
Fix deployment target
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Jan 21, 2022
1 parent b83cb88 commit 31de5e1
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 41 deletions.
8 changes: 8 additions & 0 deletions OCLP-Helper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
AE0677542771742F00097354 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AE0677532771742F00097354 /* main.m */; };
AE06775C2771743700097354 /* STPrivilegedTask.m in Sources */ = {isa = PBXBuildFile; fileRef = AE06775B2771743700097354 /* STPrivilegedTask.m */; };
AEC3ACD62798F84D005F5192 /* Handler.m in Sources */ = {isa = PBXBuildFile; fileRef = AEC3ACD52798F84D005F5192 /* Handler.m */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -28,6 +29,8 @@
AE0677532771742F00097354 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
AE06775A2771743700097354 /* STPrivilegedTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STPrivilegedTask.h; sourceTree = "<group>"; };
AE06775B2771743700097354 /* STPrivilegedTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPrivilegedTask.m; sourceTree = "<group>"; };
AEC3ACD52798F84D005F5192 /* Handler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Handler.m; sourceTree = "<group>"; };
AEC3ACD72798F853005F5192 /* Handler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Handler.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -63,6 +66,8 @@
AE0677532771742F00097354 /* main.m */,
AE06775A2771743700097354 /* STPrivilegedTask.h */,
AE06775B2771743700097354 /* STPrivilegedTask.m */,
AEC3ACD52798F84D005F5192 /* Handler.m */,
AEC3ACD72798F853005F5192 /* Handler.h */,
);
path = "OCLP-Helper";
sourceTree = "<group>";
Expand Down Expand Up @@ -124,6 +129,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AEC3ACD62798F84D005F5192 /* Handler.m in Sources */,
AE06775C2771743700097354 /* STPrivilegedTask.m in Sources */,
AE0677542771742F00097354 /* main.m in Sources */,
);
Expand Down Expand Up @@ -247,6 +253,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -255,6 +262,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
Binary file not shown.
13 changes: 13 additions & 0 deletions OCLP-Helper/Handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Handler.h
// MacStreamingPlayer
//
// Created by Collin Mistr on 1/19/22.
//
//

#import <Cocoa/Cocoa.h>

@interface Handler : NSObject <NSApplicationDelegate>

@end
59 changes: 59 additions & 0 deletions OCLP-Helper/Handler.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Handler.m
// MacStreamingPlayer
//
// Created by Collin Mistr on 1/19/22.
//
//

#import "Handler.h"
#import "STPrivilegedTask.h"


@implementation Handler

-(void)applicationDidFinishLaunching:(NSNotification *)notification {
[self performSelectorInBackground:@selector(runProcess) withObject:nil];
}

-(void)runProcess {
int exitCode = 0;
NSLog(@"Starting...");

STPrivilegedTask *privilegedTask = [[STPrivilegedTask alloc] init];
NSArray *components = [[NSProcessInfo processInfo] arguments];
NSMutableArray *arguments = [NSMutableArray arrayWithArray:components];


NSString *launchPath = arguments[1];
[arguments removeObjectAtIndex:0]; // Remove Binary Path
[arguments removeObjectAtIndex:0]; // Remove Launch Path

[privilegedTask setLaunchPath:launchPath];
[privilegedTask setArguments:arguments];
[privilegedTask setCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];

OSStatus err = [privilegedTask launch];
if (err != errAuthorizationSuccess) {
if (err == errAuthorizationCanceled) {
NSLog(@"User cancelled");
exit(1);
} else {
NSLog(@"Something went wrong: %d", (int)err);
// For error codes, see http://www.opensource.apple.com/source/libsecurity_authorization/libsecurity_authorization-36329/lib/Authorization.h
}
}

// Success! Now, read the output file handle for data
NSFileHandle *readHandle = [privilegedTask outputFileHandle];
NSData *outputData = [readHandle readDataToEndOfFile]; // Blocking call
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];

printf("%s", [outputString UTF8String]);

exitCode = privilegedTask.terminationStatus;
NSLog(@"Done");
exit(exitCode);
}

@end
51 changes: 10 additions & 41 deletions OCLP-Helper/main.m
Original file line number Diff line number Diff line change
@@ -1,51 +1,20 @@
//
// main.m
// OCLP-Helper
// Test
//
// Created by Collin Mistr on 1/19/22.
//
// Created by Mykola Grymalyuk on 2021-12-20.
//

#import <Foundation/Foundation.h>
#import "STPrivilegedTask.h"
#import <Cocoa/Cocoa.h>
#import "Handler.h"

int main(int argc, const char * argv[]) {
@autoreleasepool {
printf("Starting OCLP-Helper\n");
}

STPrivilegedTask *privilegedTask = [[STPrivilegedTask alloc] init];

NSArray *components = [[NSProcessInfo processInfo] arguments];
NSMutableArray *arguments = [NSMutableArray arrayWithArray:components];


NSString *launchPath = arguments[1];
[arguments removeObjectAtIndex:0]; // Remove Binary Path
[arguments removeObjectAtIndex:0]; // Remove Launch Path

[privilegedTask setLaunchPath:launchPath];
[privilegedTask setArguments:arguments];
[privilegedTask setCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];

OSStatus err = [privilegedTask launch];
if (err != errAuthorizationSuccess) {
if (err == errAuthorizationCanceled) {
NSLog(@"User cancelled");
return 1;
} else {
NSLog(@"Something went wrong: %d", (int)err);
// For error codes, see http://www.opensource.apple.com/source/libsecurity_authorization/libsecurity_authorization-36329/lib/Authorization.h
}
NSApplication * app = [NSApplication sharedApplication];
Handler *h = [[Handler alloc] init];
[app setDelegate:h];
[app run];
}

[privilegedTask waitUntilExit];

// Success! Now, read the output file handle for data
NSFileHandle *readHandle = [privilegedTask outputFileHandle];
NSData *outputData = [readHandle readDataToEndOfFile]; // Blocking call
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];

printf("%s", [outputString UTF8String]);

return privilegedTask.terminationStatus;
return 0;
}

0 comments on commit 31de5e1

Please sign in to comment.