mirror of
https://github.com/munki/munki.git
synced 2026-01-05 22:20:00 -06:00
Resolves issues with blocking apps, authrestartd communication, and display of various alerts
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
<outlet property="updatesMenuItem" destination="HOZ-SU-4Sm" id="UdT-3I-JpJ"/>
|
||||
<outlet property="updatesToolbarButton" destination="Rwi-cJ-59c" id="MRY-by-5VU"/>
|
||||
<outlet property="webView" destination="Wo1-qU-xAa" id="TPC-3I-M45"/>
|
||||
<outlet property="window" destination="EeR-uP-dFY" id="FfQ-Q4-xUU"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
|
||||
@@ -256,7 +257,7 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" id="tqD-vb-lE4">
|
||||
<rect key="frame" x="0.0" y="0.0" width="514" height="325"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" autosaveColumns="NO" typeSelect="NO" id="rzT-c7-fSM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="514" height="325"/>
|
||||
@@ -509,6 +510,9 @@
|
||||
<toolbarItem reference="XOq-vH-sPs"/>
|
||||
</defaultToolbarItems>
|
||||
</toolbar>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="XGW-R4-ybE" id="4N2-bF-JRb"/>
|
||||
</connections>
|
||||
</window>
|
||||
<customView id="qxW-KU-9S3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="317" height="22"/>
|
||||
|
||||
@@ -414,8 +414,10 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WebPolicyDeleg
|
||||
// warn about blocking applications, etc...
|
||||
// then start an update session
|
||||
if updatesRequireRestart() || updatesRequireLogout() {
|
||||
// switch to updates view
|
||||
loadUpdatesPage(self)
|
||||
if !currentPageIsUpdatesPage() {
|
||||
// switch to updates view
|
||||
loadUpdatesPage(self)
|
||||
}
|
||||
// warn about need to logout or restart
|
||||
alert_controller.confirmUpdatesAndInstall()
|
||||
} else {
|
||||
|
||||
@@ -1115,16 +1115,18 @@ func updatesRequireLogout() -> Bool {
|
||||
if installRequiresLogout() {
|
||||
return true
|
||||
}
|
||||
return getUpdateList().filter(
|
||||
{ ($0["RestartAction"] as? String ?? "").hasPrefix("Logout") }
|
||||
).count > 0
|
||||
let requiresLogout = getUpdateList().filter(
|
||||
{ ($0["RestartAction"] as? String ?? "").hasSuffix("Logout") }
|
||||
).count > 0
|
||||
return requiresLogout
|
||||
}
|
||||
|
||||
func updatesRequireRestart() -> Bool {
|
||||
// Return true if any item in the update list requires a restart
|
||||
return getUpdateList().filter(
|
||||
{ ($0["RestartAction"] as? String ?? "").hasPrefix("Restart") }
|
||||
).count > 0
|
||||
let requiresRestart = getUpdateList().filter(
|
||||
{ ($0["RestartAction"] as? String ?? "").hasSuffix("Restart") }
|
||||
).count > 0
|
||||
return requiresRestart
|
||||
}
|
||||
|
||||
func updatesContainNonUserSelectedItems() -> Bool {
|
||||
|
||||
@@ -107,6 +107,49 @@ class UNIXDomainSocketClient {
|
||||
}
|
||||
}
|
||||
|
||||
private func fdSet(_ fd: Int32, set: inout fd_set) {
|
||||
/// Replacement for FD_SET macro
|
||||
let intOffset = Int(fd / 32)
|
||||
let bitOffset = fd % 32
|
||||
let mask = Int32(1 << bitOffset)
|
||||
set.fds_bits[0] = set.fds_bits[0] | mask
|
||||
switch intOffset {
|
||||
case 0: set.fds_bits.0 = set.fds_bits.0 | mask
|
||||
case 1: set.fds_bits.1 = set.fds_bits.1 | mask
|
||||
case 2: set.fds_bits.2 = set.fds_bits.2 | mask
|
||||
case 3: set.fds_bits.3 = set.fds_bits.3 | mask
|
||||
case 4: set.fds_bits.4 = set.fds_bits.4 | mask
|
||||
case 5: set.fds_bits.5 = set.fds_bits.5 | mask
|
||||
case 6: set.fds_bits.6 = set.fds_bits.6 | mask
|
||||
case 7: set.fds_bits.7 = set.fds_bits.7 | mask
|
||||
case 8: set.fds_bits.8 = set.fds_bits.8 | mask
|
||||
case 9: set.fds_bits.9 = set.fds_bits.9 | mask
|
||||
case 10: set.fds_bits.10 = set.fds_bits.10 | mask
|
||||
case 11: set.fds_bits.11 = set.fds_bits.11 | mask
|
||||
case 12: set.fds_bits.12 = set.fds_bits.12 | mask
|
||||
case 13: set.fds_bits.13 = set.fds_bits.13 | mask
|
||||
case 14: set.fds_bits.14 = set.fds_bits.14 | mask
|
||||
case 15: set.fds_bits.15 = set.fds_bits.15 | mask
|
||||
case 16: set.fds_bits.16 = set.fds_bits.16 | mask
|
||||
case 17: set.fds_bits.17 = set.fds_bits.17 | mask
|
||||
case 18: set.fds_bits.18 = set.fds_bits.18 | mask
|
||||
case 19: set.fds_bits.19 = set.fds_bits.19 | mask
|
||||
case 20: set.fds_bits.20 = set.fds_bits.20 | mask
|
||||
case 21: set.fds_bits.21 = set.fds_bits.21 | mask
|
||||
case 22: set.fds_bits.22 = set.fds_bits.22 | mask
|
||||
case 23: set.fds_bits.23 = set.fds_bits.23 | mask
|
||||
case 24: set.fds_bits.24 = set.fds_bits.24 | mask
|
||||
case 25: set.fds_bits.25 = set.fds_bits.25 | mask
|
||||
case 26: set.fds_bits.26 = set.fds_bits.26 | mask
|
||||
case 27: set.fds_bits.27 = set.fds_bits.27 | mask
|
||||
case 28: set.fds_bits.28 = set.fds_bits.28 | mask
|
||||
case 29: set.fds_bits.29 = set.fds_bits.29 | mask
|
||||
case 30: set.fds_bits.30 = set.fds_bits.30 | mask
|
||||
case 31: set.fds_bits.31 = set.fds_bits.31 | mask
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
private func dataAvailable(timeout: Int = 10) -> Bool {
|
||||
// uses POSIX select() to wait for data to be available on the socket
|
||||
//
|
||||
@@ -118,10 +161,13 @@ class UNIXDomainSocketClient {
|
||||
var timer = timeval()
|
||||
timer.tv_sec = timeout
|
||||
timer.tv_usec = 0
|
||||
var readfds = fd_set(fds_bits: (CFSocketGetNative(socket), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
|
||||
return select(1, &readfds, nil, nil, &timer) > 0
|
||||
let socket_fd = CFSocketGetNative(socket)
|
||||
var readfds = fd_set(fds_bits: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
|
||||
fdSet(socket_fd, set: &readfds)
|
||||
let result = select(socket_fd + 1, &readfds, nil, nil, &timer)
|
||||
return result > 0
|
||||
}
|
||||
|
||||
|
||||
func read(maxsize: Int = 1024, timeout: Int = 10) -> String {
|
||||
// read a message from our socket
|
||||
// there's no CFSocketRead method, use BSD socket recv method instead
|
||||
|
||||
@@ -36,7 +36,7 @@ class AuthRestartClient {
|
||||
throw AuthRestartClientError.socketError(code: socket.errCode,
|
||||
description: "Failed to write to \(AUTHRESTARTD_SOCKET)")
|
||||
}
|
||||
let reply = socket.read()
|
||||
let reply = socket.read(timeout: 1)
|
||||
if reply.isEmpty {
|
||||
return "ERROR:No reply"
|
||||
}
|
||||
@@ -114,6 +114,7 @@ func fvIsActive() -> Bool {
|
||||
do {
|
||||
return try AuthRestartClient().fvIsActive()
|
||||
} catch {
|
||||
msc_debug_log("fvIsActive(): Cought \(error)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -124,6 +125,7 @@ func verifyUser(_ username: String) -> Bool {
|
||||
do {
|
||||
return try AuthRestartClient().verifyUser(username)
|
||||
} catch {
|
||||
msc_debug_log("verifyUser(): Cought \(error)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -134,6 +136,7 @@ func verifyRecoveryKeyPresent() -> Bool {
|
||||
do {
|
||||
return try AuthRestartClient().verifyRecoveryKeyPresent()
|
||||
} catch {
|
||||
msc_debug_log("verifyRecoveryKeyPresent(): Cought \(error)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -143,6 +146,7 @@ func verifyCanAttemptAuthRestart() -> Bool {
|
||||
do {
|
||||
return try AuthRestartClient().verifyCanAttemptAuthRestart()
|
||||
} catch {
|
||||
msc_debug_log("verifyCanAttemptAuthRestart(): Cought \(error)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -154,6 +158,7 @@ func storePassword(_ password: String, forUserName username: String = "") -> Boo
|
||||
try AuthRestartClient().storePassword(password, username: username)
|
||||
return true
|
||||
} catch {
|
||||
msc_debug_log("storePassword(): Cought \(error)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,11 +131,11 @@ func escapeHTML(_ text: String) -> String {
|
||||
extension GenericItem {
|
||||
func escapeAndQuoteCommonFields() {
|
||||
// Adds _escaped and _quoted versions of several commonly-used fields
|
||||
my["name_escaped"] = escapeHTML(my["name"] as? String ?? "")
|
||||
my["name_quoted"] = escapeQuotes(my["name"] as? String ?? "")
|
||||
my["display_name_escaped"] = escapeHTML(my["display_name"] as? String ?? "")
|
||||
my["developer_escaped"] = escapeHTML(my["developer"] as? String ?? "")
|
||||
my["display_version_escaped"] = escapeHTML(my["display_version"] as? String ?? "")
|
||||
my["name_escaped"] = escapeHTML(self["name"] as? String ?? "")
|
||||
my["name_quoted"] = escapeQuotes(self["name"] as? String ?? "")
|
||||
my["display_name_escaped"] = escapeHTML(self["display_name"] as? String ?? "")
|
||||
my["developer_escaped"] = escapeHTML(self["developer"] as? String ?? "")
|
||||
my["display_version_escaped"] = escapeHTML(self["display_version"] as? String ?? "")
|
||||
}
|
||||
|
||||
func addGeneralLabels() {
|
||||
|
||||
Reference in New Issue
Block a user