Skip to content

Commit

Permalink
Updated README, updated podspec to require ARC, bumped to version 1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinbjornt committed Mar 15, 2020
1 parent 3956766 commit 456225c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# STPrivilegedTask - Objective C class
# STPrivilegedTask - Objective-C class

An NSTask-like wrapper around [AuthorizationExecuteWithPrivileges()](https://developer.apple.com/library/mac/documentation/Security/Reference/authorization_ref/#//apple_ref/c/func/AuthorizationExecuteWithPrivileges) in the Security API to run shell commands with root privileges in Mac OS X.
An NSTask-like wrapper class around [AuthorizationExecuteWithPrivileges()](https://developer.apple.com/library/mac/documentation/Security/Reference/authorization_ref/#//apple_ref/c/func/AuthorizationExecuteWithPrivileges) in the macOS Security API to run shell commands with root privileges.

STPrivilegedTask was created a long time ago. It has now been updated to support ARC and is available via <a href="https://cocoapods.org">CocoaPods</a>.
STPrivilegedTask was created a long time ago. It has now been updated over the years to work with the latest versions of macOS and is available via <a href="https://cocoapods.org">CocoaPods</a>.

## Examples

Expand Down Expand Up @@ -45,7 +45,7 @@ OSStatus err = [STPrivilegedTask launchedPrivilegedTaskWithLaunchPath:@"/bin/sh"
### Getting task output

```objective-c
// ... launch task
// ... Launch task

[privilegedTask waitUntilExit];

Expand All @@ -59,7 +59,7 @@ NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUT
```objective-c
// ... launch task
// ... Launch task
NSFileHandle *readHandle = [privilegedTask outputFileHandle];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getOutputData:) name:NSFileHandleReadCompletionNotification object:readHandle];
Expand All @@ -68,19 +68,19 @@ NSFileHandle *readHandle = [privilegedTask outputFileHandle];
// ...
- (void)getOutputData:(NSNotification *)aNotification {
//get data from notification
// Get data from notification
NSData *data = [[aNotification userInfo] objectForKey:NSFileHandleNotificationDataItem];
//make sure there's actual data
// Make sure there's actual data
if ([data length]) {
// do something with the data
// Do something with the data
NSString *outputString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(outputString);
// go read more data in the background
// Go read more data in the background
[[aNotification object] readInBackgroundAndNotify];
} else {
// do something else
// Do something else
}
}
```
Expand All @@ -93,11 +93,11 @@ You can observe STPrivilegedTaskDidTerminateNotification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(privilegedTaskFinished:) name:STPrivilegedTaskDidTerminateNotification object:nil];

- (void)privilegedTaskFinished:(NSNotification *)aNotification {
// do something
// Do something
}
```
Or alternately, set a termination handler:
Or alternatively, set a termination handler:
```objective-c
privilegedTask.terminationHandler = ^(STPrivilegedTask *privilegedTask) {
Expand Down Expand Up @@ -164,7 +164,7 @@ It then presents the output of the script in a window, along with the exit code.

## BSD License

Copyright (c) Sveinbjorn Thordarson &lt;sveinbjorn@sveinbjorn.org&gt;
Copyright (c) 2008-2020 Sveinbjorn Thordarson &lt;sveinbjorn@sveinbjorn.org&gt;
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
10 changes: 5 additions & 5 deletions STPrivilegedTask.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Pod::Spec.new do |s|
s.name = "STPrivilegedTask"
s.version = "1.0.7"
s.summary = "An NSTask-like wrapper around Mac OS X Security Framework's AuthorizationExecuteWithPrivileges()"
s.description = "An NSTask-like wrapper around AuthorizationExecuteWithPrivileges() in the Security API to run shell commands with root privileges in Mac OS X."
s.version = "1.0.8"
s.summary = "An NSTask-like wrapper around the macOS Security Framework's AuthorizationExecuteWithPrivileges()"
s.description = "An NSTask-like wrapper around AuthorizationExecuteWithPrivileges() in the Security API to run shell commands with root privileges on macOS."
s.homepage = "http://github.com/sveinbjornt/STPrivilegedTask"
s.license = { :type => 'BSD' }
s.author = { "Sveinbjorn Thordarson" => "sveinbjorn@sveinbjorn.org" }
s.osx.deployment_target = "10.8"
s.source = { :git => "https://github.com/sveinbjornt/STPrivilegedTask.git", :tag => "1.0.7" }
s.source = { :git => "https://github.com/sveinbjornt/STPrivilegedTask.git", :tag => "1.0.8" }
s.source_files = "STPrivilegedTask.{h,m}"
s.exclude_files = "PrivilegedTaskExample"
s.public_header_files = "STPrivilegedTask.h"
s.framework = "Security"
s.requires_arc = false
s.requires_arc = true
end

0 comments on commit 456225c

Please sign in to comment.