Skip to content

Commit

Permalink
Fix relaunch
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyuzhao committed Dec 19, 2021
1 parent 14f64ae commit 5be46c6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions SwiftConnect/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
}

func testPrivilege() -> Bool {
return run("sudo", "echo", "test").succeeded;
return getuid() == 0;
}

func relaunch() {
let bin = Bundle.main.executablePath!;
print("Relaunch: sudo \(bin)");
let _ = runAsync("osascript", "-e", """
do shell script \"sudo \(bin) &\" with prompt \"Start OpenConnect on privileged mode\" with administrator privileges
let _ = try! runAndPrint(bash: """
osascript -e "do shell script \\"sudo '\(bin)' &\\" with prompt \\"Start OpenConnect on privileged mode\\" with administrator privileges"&
""");
NSApp.terminate(nil)
}
Expand Down

0 comments on commit 5be46c6

Please sign in to comment.