blob: 5bd6a7a6f5f6e12dd296894fef052674e8e55e5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#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);
}
|