Skip to content

Commit 9014f1d

Browse files
authored
Merge pull request #635 from macadmins/development
v2.0.7
2 parents b620927 + 0172835 commit 9014f1d

File tree

8 files changed

+75
-19
lines changed

8 files changed

+75
-19
lines changed

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.0.7] - 2024-08-08
8+
Requires macOS 12.0 and higher.
9+
10+
### Added
11+
- If using `utilizeSOFAFeed`, you can now set the `aboutUpdateURL` to `sofa`
12+
- If a URL is found in the relevant `SecurityInfo` key for the corresponding update, this value will be used.
13+
- If no URL is found, the aboutUpdateURL button will not be shown to the user
14+
- [Feature Request 629](https://github.com/macadmins/nudge/issues/629)
15+
16+
### Changed
17+
- The `SMAppService` logic logs have been moved to debug logs
18+
- When an updated Managed Preference is sent for `com.github.macadmins.Nudge`, if the values are different, [Nudge will exit](https://github.com/macadmins/nudge/commit/f13a697dd61400f7f0d73dc38226f7769ed8e4f4)
19+
- This is a workaround for issue [602](https://github.com/macadmins/nudge/issues/602)
20+
- The LaunchAgent will ensure the application is successfully restarted at a future time.
21+
22+
### Fixed
23+
- The Jamf JSON schema file had an [item missing](https://github.com/macadmins/nudge/pull/632) and a [key incorrectly set](https://github.com/macadmins/nudge/pull/634)
24+
725
## [2.0.6] - 2024-08-01
826
Requires macOS 12.0 and higher.
927

Example Assets/com.github.macadmins.Nudge.tester.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"osVersionRequirements": [
77
{
8-
"aboutUpdateURL": "https://apple.com",
8+
"aboutUpdateURL": "sofa",
99
"requiredMinimumOSVersion": "latest",
1010
"unsupportedURL": "https://google.com"
1111
}

Nudge.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@
698698
"@executable_path/../Frameworks",
699699
);
700700
MACOSX_DEPLOYMENT_TARGET = 12.0;
701-
MARKETING_VERSION = 2.0.6;
701+
MARKETING_VERSION = 2.0.7;
702702
PRODUCT_BUNDLE_IDENTIFIER = com.github.macadmins.Nudge;
703703
PRODUCT_NAME = "$(TARGET_NAME)";
704704
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -729,7 +729,7 @@
729729
"@executable_path/../Frameworks",
730730
);
731731
MACOSX_DEPLOYMENT_TARGET = 12.0;
732-
MARKETING_VERSION = 2.0.6;
732+
MARKETING_VERSION = 2.0.7;
733733
PRODUCT_BUNDLE_IDENTIFIER = com.github.macadmins.Nudge;
734734
PRODUCT_NAME = "$(TARGET_NAME)";
735735
PROVISIONING_PROFILE_SPECIFIER = "";

Nudge/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.6</string>
18+
<string>2.0.7</string>
1919
<key>CFBundleVersion</key>
20-
<string>2.0.6</string>
20+
<string>2.0.7</string>
2121
<key>LSApplicationCategoryType</key>
2222
<string>public.app-category.utilities</string>
2323
<key>LSMinimumSystemVersion</key>

Nudge/UI/Common/InformationButton.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,19 @@ struct InformationButton: View {
2020

2121
private var informationButton: some View {
2222
guard OSVersionRequirementVariables.aboutUpdateURL != "" else { return AnyView(EmptyView()) }
23+
var selectedURL = OSVersionRequirementVariables.aboutUpdateURL
24+
if OSVersionRequirementVariables.aboutUpdateURL == "sofa" && OptionalFeatureVariables.utilizeSOFAFeed {
25+
if nudgePrimaryState.sofaAboutUpdateURL.hasPrefix("https://") {
26+
selectedURL = nudgePrimaryState.sofaAboutUpdateURL
27+
} else {
28+
return AnyView(EmptyView())
29+
}
30+
}
2331

2432
return AnyView(
25-
Button(action: UIUtilities().openMoreInfo) {
33+
Button(action: {
34+
UIUtilities().openMoreInfo(infoURL: selectedURL)
35+
}) {
2636
Text(.init(UserInterfaceVariables.informationButtonText.localized(desiredLanguage: getDesiredLanguage(locale: appState.locale))))
2737
.foregroundColor(dynamicTextColor)
2838
}

Nudge/UI/Defaults.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Globals {
2323
static let snc = NSWorkspace.shared.notificationCenter
2424
// Preferences
2525
static let configJSON = ConfigurationManager().getConfigurationAsJSON()
26-
static var configProfile = ConfigurationManager().getConfigurationAsProfile()
26+
static let configProfile = ConfigurationManager().getConfigurationAsProfile()
2727
static let nudgeDefaults = UserDefaults.standard
2828
static let nudgeJSONPreferences = NetworkFileManager().getNudgeJSONPreferences()
2929
// Device Properties
@@ -83,6 +83,7 @@ class AppState: ObservableObject {
8383
@Published var requireDualQuitButtons = false
8484
@Published var requiredMinimumOSVersion = OSVersionRequirementVariables.requiredMinimumOSVersion
8585
@Published var shouldExit = false
86+
@Published var sofaAboutUpdateURL: String = ""
8687
@Published var timerCycle = 0
8788
@Published var userDeferrals = Globals.nudgeDefaults.object(forKey: "userDeferrals") as? Int ?? 0
8889
@Published var userQuitDeferrals = Globals.nudgeDefaults.object(forKey: "userQuitDeferrals") as? Int ?? 0

Nudge/UI/Main.swift

+24-2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
282282

283283
// Start setting UI fields
284284
nudgePrimaryState.requiredMinimumOSVersion = selectedOS!.productVersion
285+
nudgePrimaryState.sofaAboutUpdateURL = selectedOS!.securityInfo
285286
nudgePrimaryState.activelyExploitedCVEs = activelyExploitedCVEs
286287
releaseDate = selectedOS!.releaseDate ?? Date()
287288
if requiredInstallationDate == Date(timeIntervalSince1970: 0) {
@@ -650,7 +651,22 @@ class AppDelegate: NSObject, NSApplicationDelegate {
650651
private func handleSMAppService() {
651652
if #available(macOS 13, *) {
652653
let appService = SMAppService.agent(plistName: "com.github.macadmins.Nudge.SMAppService.plist")
654+
let mainAppServce = SMAppService.mainApp
653655
let appServiceStatus = appService.status
656+
let mainAppServiceStatus = mainAppServce.status
657+
// print("")
658+
// print("com.github.macadmins.Nudge.SMAppService")
659+
// print("notRegistered: \(appServiceStatus == SMAppService.Status.notRegistered)")
660+
// print("enabled: \(appServiceStatus == SMAppService.Status.enabled)")
661+
// print("requiresApproval: \(appServiceStatus == SMAppService.Status.requiresApproval)")
662+
// print("notFound: \(appServiceStatus == SMAppService.Status.notFound)")
663+
// print("")
664+
// print("mainAppService")
665+
// print("notRegistered: \(mainAppServiceStatus == SMAppService.Status.notRegistered)")
666+
// print("enabled: \(mainAppServiceStatus == SMAppService.Status.enabled)")
667+
// print("requiresApproval: \(mainAppServiceStatus == SMAppService.Status.requiresApproval)")
668+
// print("notFound: \(mainAppServiceStatus == SMAppService.Status.notFound)")
669+
// print("")
654670

655671
if CommandLine.arguments.contains("--register") || UserExperienceVariables.loadLaunchAgent {
656672
SMAppManager().loadSMAppLaunchAgent(appService: appService, appServiceStatus: appServiceStatus)
@@ -724,8 +740,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
724740
Globals.nc.addObserver(
725741
forName: UserDefaults.didChangeNotification,
726742
object: nil,
727-
queue: .main) { [weak self] _ in
728-
Globals.configProfile = ConfigurationManager().getConfigurationAsProfile()
743+
queue: .main) { _ in
744+
if ConfigurationManager().getConfigurationAsProfile() == Globals.configProfile {
745+
LogManager.debug("MDM Profile has been re-installed or updated but configuration is identical, no need to quit Nudge.", logger: sofaLog)
746+
} else {
747+
LogManager.info("MDM Profile has been re-installed or updated. Quitting Nudge to allow LaunchAgent to re-initalize with new settings.", logger: sofaLog)
748+
nudgePrimaryState.shouldExit = true
749+
exit(2)
750+
}
729751
}
730752
}
731753

Nudge/Utilities/Utils.swift

+15-10
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ struct SubProcessUtilities {
12831283

12841284
struct SMAppManager {
12851285
private func handleLegacyLaunchAgent(passedThroughCLI: Bool, action: String) {
1286-
logOrPrint("Legacy Nudge LaunchAgent currently loaded. Please disable this agent before attempting to \(action) modern agent.", passedThroughCLI: passedThroughCLI, exitCode: 1)
1286+
logOrPrint("Legacy Nudge LaunchAgent currently loaded. Please disable this agent before attempting to \(action) modern agent.", error: false, passedThroughCLI: passedThroughCLI, exitCode: 1)
12871287
}
12881288

12891289
@available(macOS 13.0, *)
@@ -1299,29 +1299,34 @@ struct SMAppManager {
12991299

13001300
switch appServiceStatus {
13011301
case .enabled:
1302-
logOrPrint("Nudge LaunchAgent is currently registered and enabled", passedThroughCLI: passedThroughCLI, exitCode: 0)
1302+
logOrPrint("Nudge LaunchAgent is currently registered and enabled", error: false, passedThroughCLI: passedThroughCLI, exitCode: 0)
13031303
default:
13041304
registerOrUnregister(appService: appService, passedThroughCLI: passedThroughCLI, action: "register")
13051305
}
13061306
}
13071307

1308-
private func logOrPrint(_ message: String, passedThroughCLI: Bool, exitCode: Int? = nil) {
1308+
private func logOrPrint(_ message: String, error: Bool, passedThroughCLI: Bool, exitCode: Int? = nil) {
13091309
if passedThroughCLI {
13101310
print(message)
13111311
if let code = exitCode { exit(Int32(code)) }
13121312
} else {
1313-
LogManager.info("\(message)", logger: uiLog)
1313+
if error {
1314+
LogManager.error("\(message)", logger: uiLog)
1315+
} else {
1316+
LogManager.debug("\(message)", logger: uiLog)
1317+
}
1318+
13141319
}
13151320
}
13161321

13171322
@available(macOS 13.0, *)
13181323
private func registerOrUnregister(appService: SMAppService, passedThroughCLI: Bool, action: String) {
13191324
do {
1320-
logOrPrint("\(action.capitalized)ing Nudge LaunchAgent", passedThroughCLI: passedThroughCLI)
1325+
logOrPrint("\(action.capitalized)ing Nudge LaunchAgent", error: false, passedThroughCLI: passedThroughCLI)
13211326
try action == "register" ? appService.register() : appService.unregister()
1322-
logOrPrint("Successfully \(action)ed Nudge LaunchAgent", passedThroughCLI: passedThroughCLI, exitCode: 0)
1327+
logOrPrint("Successfully \(action)ed Nudge LaunchAgent", error: false, passedThroughCLI: passedThroughCLI, exitCode: 0)
13231328
} catch {
1324-
logOrPrint("Failed to \(action) Nudge LaunchAgent", passedThroughCLI: passedThroughCLI, exitCode: 1)
1329+
logOrPrint("Failed to \(action) Nudge LaunchAgent", error: true, passedThroughCLI: passedThroughCLI, exitCode: 1)
13251330
}
13261331
}
13271332

@@ -1331,7 +1336,7 @@ struct SMAppManager {
13311336

13321337
switch appServiceStatus {
13331338
case .notFound, .notRegistered:
1334-
logOrPrint("Nudge LaunchAgent has never been registered or is not currently registered", passedThroughCLI: passedThroughCLI, exitCode: 0)
1339+
logOrPrint("Nudge LaunchAgent has never been registered or is not currently registered", error: false, passedThroughCLI: passedThroughCLI, exitCode: 0)
13351340
default:
13361341
registerOrUnregister(appService: appService, passedThroughCLI: passedThroughCLI, action: "unregister")
13371342
}
@@ -1418,8 +1423,8 @@ struct UIUtilities {
14181423
return shellCommands.contains(where: path.hasPrefix)
14191424
}
14201425

1421-
func openMoreInfo() {
1422-
guard let url = URL(string: OSVersionRequirementVariables.aboutUpdateURL) else {
1426+
func openMoreInfo(infoURL: String) {
1427+
guard let url = URL(string: infoURL) else {
14231428
return
14241429
}
14251430
LogManager.notice("User clicked moreInfo button", logger: uiLog)

0 commit comments

Comments
 (0)