mirror of
https://github.com/nmap/nmap.git
synced 2026-01-02 04:49:02 +00:00
Improve an error message for Zenmap on OS X
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
// Objective-C
|
||||
//
|
||||
// This program attempts to run an applescript script which asks for root
|
||||
// privileges. If the authorization fails or is canceled, Zenmap is run
|
||||
// privileges. If the authorization fails or is canceled, Zenmap is run
|
||||
// without privileges using applescript.
|
||||
//
|
||||
//
|
||||
// This program is the first link in the chain:
|
||||
// zenmap_auth -> zenmap_wrapper.py -> zenmap.bin
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <libgen.h>
|
||||
@@ -19,27 +19,27 @@ int main(int argc, const char * argv[]) {
|
||||
NSString *executable_path;
|
||||
NSString *cwd;
|
||||
size_t len_cwd;
|
||||
|
||||
|
||||
cwd = [[NSBundle mainBundle] bundlePath];
|
||||
len_cwd = [cwd length];
|
||||
executable_path = cwd;
|
||||
executable_path = [NSString stringWithFormat:@"%@/Contents/MacOS/%s", executable_path, EXECUTABLE_NAME];
|
||||
NSLog(@"%@",executable_path);
|
||||
|
||||
|
||||
NSDictionary *error = [NSDictionary new];
|
||||
NSString *script = [NSString stringWithFormat:@"do shell script \"%@ %s\" with administrator privileges", executable_path, (char*)argv];
|
||||
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:script];
|
||||
if ([appleScript executeAndReturnError:&error]) {
|
||||
NSLog(@"success!");
|
||||
} else {
|
||||
NSLog(@"failure!");
|
||||
NSLog(@"Failed to execute applescript with admin privileges, trying without.");
|
||||
NSDictionary *error = [NSDictionary new];
|
||||
NSString *script = [NSString stringWithFormat:@"do shell script \"%@ %s\"", executable_path, (char*)argv];
|
||||
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:script];
|
||||
if ([appleScript executeAndReturnError:&error]) {
|
||||
NSLog(@"success!");
|
||||
} else {
|
||||
NSLog(@"total failure!");
|
||||
NSLog(@"Failed to execute applescript at all.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user