mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-22 14:22:23 +00:00
25 lines
586 B
Plaintext
25 lines
586 B
Plaintext
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#include "mac_doprivileged.h"
|
|
|
|
#undef slots
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
bool macExecutePrivilegedShellCommand(const char *commandAndArgs)
|
|
{
|
|
char tmp[32768];
|
|
|
|
snprintf(tmp,sizeof(tmp),"do shell script \"%s\" with administrator privileges\n",commandAndArgs);
|
|
tmp[32767] = (char)0;
|
|
|
|
NSString *scriptApple = [[NSString alloc] initWithUTF8String:tmp];
|
|
NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
|
|
NSDictionary *err = nil;
|
|
[as executeAndReturnError:&err];
|
|
[as release];
|
|
[scriptApple release];
|
|
|
|
return (err == nil);
|
|
}
|