1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-10 23:46:34 +00:00

Fix auth wrapper: args not supported. Add error reporting

This commit is contained in:
dmiller
2023-03-18 20:26:54 +00:00
parent 37ac2f482e
commit 851bc83dfb

View File

@@ -27,19 +27,21 @@ int main(int argc, const char * argv[]) {
NSLog(@"%@",executable_path);
NSDictionary *error = [NSDictionary new];
NSString *script = [NSString stringWithFormat:@"do shell script \"%@ %s\" with administrator privileges", executable_path, (char*)argv];
NSString *script = [NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", executable_path];
NSLog(@"Executing: >>%@<<", script);
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:script];
if ([appleScript executeAndReturnError:&error]) {
NSLog(@"success!");
} else {
NSLog(@"Failed to execute applescript with admin privileges, trying without.");
NSLog(@"Failed to execute applescript with admin privileges: %@", error[@"NSAppleScriptErrorMessage"]);
NSDictionary *error = [NSDictionary new];
NSString *script = [NSString stringWithFormat:@"do shell script \"%@ %s\"", executable_path, (char*)argv];
NSString *script = [NSString stringWithFormat:@"do shell script \"%@\"", executable_path];
NSLog(@"Executing: >>%@<<", script);
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:script];
if ([appleScript executeAndReturnError:&error]) {
NSLog(@"success!");
} else {
NSLog(@"Failed to execute applescript at all.");
NSLog(@"Failed to execute applescript: %@", error[@"NSAppleScriptErrorMessage"]);
}
}
}