Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert smapp changes #518

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.13] - 2023-10-05
### Fixed
- [SMAppService preventing legacy LaunchAgent from loading](https://github.com/macadmins/nudge/pull/516)
## [1.1.13] - 2023-10-06
### Removed
- Removed support for SMAppService method of registering LaunchAgents. This version will only use "legacy" LaunchAgents until this new service method works well.

## [1.1.12] - 2023-09-25
### Added
Expand Down
1 change: 0 additions & 1 deletion Example Assets/com.github.macadmins.Nudge.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"imminentWindowTime": 24,
"initialRefreshCycle": 18000,
"launchAgentIdentifier": "com.github.macadmins.Nudge",
"loadLaunchAgent": false,
"maxRandomDelayInSeconds": 1200,
"noTimers": false,
"nudgeRefreshCycle": 60,
Expand Down
2 changes: 0 additions & 2 deletions Example Assets/com.github.macadmins.Nudge.mobileconfig
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@
<integer>18000</integer>
<key>launchAgentIdentifier</key>
<string>com.github.macadmins.Nudge</string>
<key>loadLaunchAgent</key>
<false/>
<key>maxRandomDelayInSeconds</key>
<integer>1200</integer>
<key>noTimers</key>
Expand Down
1 change: 0 additions & 1 deletion Example Assets/com.github.macadmins.Nudge.tester.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"userExperience": {
"elapsedRefreshCycle": 10,
"initialRefreshCycle": 10,
"loadLaunchAgent": false,
"nudgeRefreshCycle": 5,
"randomDelay": false
},
Expand Down
6 changes: 0 additions & 6 deletions Nudge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
63D7D0F625C9E9A500236281 /* NudgeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D7D0F525C9E9A500236281 /* NudgeTests.swift */; };
63D7D10125C9E9A500236281 /* NudgeUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D7D10025C9E9A500236281 /* NudgeUITests.swift */; };
63D7D12725C9F1EE00236281 /* StandardMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D7D12625C9F1EE00236281 /* StandardMode.swift */; };
73CC1D7829B81EE500FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist in Resources */ = {isa = PBXBuildFile; fileRef = 73CC1D7729B81EE500FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist */; };
73CC1D7A29B81F0600FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 73CC1D7729B81EE500FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -68,7 +66,6 @@
dstPath = Nudge.app/Contents/Library/LaunchAgents;
dstSubfolderSpec = 16;
files = (
73CC1D7A29B81F0600FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -116,7 +113,6 @@
63D7D10025C9E9A500236281 /* NudgeUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NudgeUITests.swift; sourceTree = "<group>"; };
63D7D10225C9E9A500236281 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
63D7D12625C9F1EE00236281 /* StandardMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardMode.swift; sourceTree = "<group>"; };
73CC1D7729B81EE500FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.github.macadmins.Nudge.SMAppService.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -248,7 +244,6 @@
63D7D0E125C9E9A400236281 /* Nudge */ = {
isa = PBXGroup;
children = (
73CC1D7729B81EE500FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist */,
639B6B5425DF374600E38EC1 /* UI */,
639B6B3925DF1FEB00E38EC1 /* Preferences */,
639B6B4725DF218900E38EC1 /* Utilities */,
Expand Down Expand Up @@ -412,7 +407,6 @@
63D7D0EA25C9E9A500236281 /* Preview Assets.xcassets in Resources */,
63D7D0E725C9E9A500236281 /* Assets.xcassets in Resources */,
639B6B0F25DC9ED300E38EC1 /* com.github.macadmins.Nudge.mobileconfig in Resources */,
73CC1D7829B81EE500FBF8E2 /* com.github.macadmins.Nudge.SMAppService.plist in Resources */,
63C6A08E2833FB6500D5264A /* com.github.macadmins.Nudge.tester.json in Resources */,
035C2AEC25D8ABC400429458 /* com.github.macadmins.Nudge.json in Resources */,
6316F0E72832CA0700E1354D /* Schema in Resources */,
Expand Down
1 change: 0 additions & 1 deletion Nudge/Preferences/DefaultPreferencesNudge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ let imminentRefreshCycle = userExperienceProfile?["imminentRefreshCycle"] as? In
let imminentWindowTime = userExperienceProfile?["imminentWindowTime"] as? Int ?? userExperienceJSON?.imminentWindowTime ?? 24
let initialRefreshCycle = userExperienceProfile?["initialRefreshCycle"] as? Int ?? userExperienceJSON?.initialRefreshCycle ?? 18000
let launchAgentIdentifier = userExperienceProfile?["launchAgentIdentifier"] as? String ?? userExperienceJSON?.launchAgentIdentifier ?? "com.github.macadmins.Nudge"
let loadLaunchAgent = userExperienceProfile?["loadLaunchAgent"] as? Bool ?? userExperienceJSON?.loadLaunchAgent ?? false
let maxRandomDelayInSeconds = userExperienceProfile?["maxRandomDelayInSeconds"] as? Int ?? userExperienceJSON?.maxRandomDelayInSeconds ?? 1200
let noTimers = userExperienceProfile?["noTimers"] as? Bool ?? userExperienceJSON?.noTimers ?? false
let nudgeRefreshCycle = userExperienceProfile?["nudgeRefreshCycle"] as? Int ?? userExperienceJSON?.nudgeRefreshCycle ?? 60
Expand Down
3 changes: 0 additions & 3 deletions Nudge/Preferences/PreferencesStructure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ struct UserExperience: Codable {
var gracePeriodPath: String?
var imminentRefreshCycle, imminentWindowTime, initialRefreshCycle: Int?
var launchAgentIdentifier: String?
var loadLaunchAgent: Bool?
var maxRandomDelayInSeconds: Int?
var noTimers: Bool?
var nudgeRefreshCycle: Int?
Expand Down Expand Up @@ -312,7 +311,6 @@ extension UserExperience {
imminentWindowTime: Int?? = nil,
initialRefreshCycle: Int?? = nil,
launchAgentIdentifier: String?? = nil,
loadLaunchAgent: Bool?? = nil,
maxRandomDelayInSeconds: Int?? = nil,
noTimers: Bool?? = nil,
nudgeRefreshCycle: Int?? = nil,
Expand All @@ -335,7 +333,6 @@ extension UserExperience {
imminentWindowTime: imminentWindowTime ?? self.imminentWindowTime,
initialRefreshCycle: initialRefreshCycle ?? self.initialRefreshCycle,
launchAgentIdentifier: launchAgentIdentifier ?? self.launchAgentIdentifier,
loadLaunchAgent: loadLaunchAgent ?? self.loadLaunchAgent,
maxRandomDelayInSeconds: maxRandomDelayInSeconds ?? self.maxRandomDelayInSeconds,
noTimers: noTimers ?? self.noTimers,
nudgeRefreshCycle: nudgeRefreshCycle ?? self.nudgeRefreshCycle,
Expand Down
10 changes: 0 additions & 10 deletions Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// Pre-Launch Logic
func applicationWillFinishLaunching(_ notification: Notification) {
// print("applicationWillFinishLaunching")
if #available(macOS 13, *) {
let appService = SMAppService.agent(plistName: "com.github.macadmins.Nudge.SMAppService.plist")
let appServiceStatus = appService.status
if CommandLine.arguments.contains("--register") || loadLaunchAgent {
Utils().loadSMAppLaunchAgent(appService: appService, appServiceStatus: appServiceStatus)
} else if CommandLine.arguments.contains("--unregister") || !loadLaunchAgent {
Utils().unloadSMAppLaunchAgent(appService: appService, appServiceStatus: appServiceStatus)
}
}

if FileManager.default.fileExists(atPath: "/Library/Managed Preferences/com.github.macadmins.Nudge.json.plist") {
prefsProfileLog.warning("\("Found bad profile path at /Library/Managed Preferences/com.github.macadmins.Nudge.json.plist", privacy: .public)")
exit(1)
Expand Down
93 changes: 0 additions & 93 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import AppKit
import CoreMediaIO
import Foundation
#if canImport(ServiceManagement)
import ServiceManagement
#endif
import SwiftUI
import SystemConfiguration

Expand Down Expand Up @@ -147,96 +144,6 @@ struct Utils {
return allow1HourDeferralButton
}

@available(macOS 13.0, *)
func loadSMAppLaunchAgent(appService: SMAppService, appServiceStatus: SMAppService.Status) {
let url = URL(string: "/Library/LaunchAgents/\(launchAgentIdentifier).plist")!
let legacyStatus = SMAppService.statusForLegacyPlist(at: url)
let passedThroughCLI = CommandLine.arguments.contains("--register")
if legacyStatus == .enabled {
if passedThroughCLI {
print("Legacy Nudge LaunchAgent currently loaded. Please disable this agent before attempting to register modern agent.")
exit(1)
} else {
osLog.info("Legacy Nudge LaunchAgent currently loaded. Please disable this agent before attempting to register modern agent.")
}
} else {
if appServiceStatus == .enabled {
if passedThroughCLI {
print("Nudge LaunchAgent is currently registered and enabled")
exit(0)
} else {
osLog.info("Nudge LaunchAgent is currently registered and enabled")
}
} else {
do {
if passedThroughCLI {
print("Registering Nudge LaunchAgent")
} else {
osLog.info("Registering Nudge LaunchAgent")
}
try appService.register()
} catch {
if passedThroughCLI {
print("Failed to register Nudge LaunchAgent")
exit(1)
} else {
osLog.info("Failed to register Nudge LaunchAgent")
return
}
}
if passedThroughCLI {
print("Successfully registered Nudge LaunchAgent")
exit(0)
} else {
osLog.info("Successfully registered Nudge LaunchAgent")
}
}
}
}

@available(macOS 13.0, *)
func unloadSMAppLaunchAgent(appService: SMAppService, appServiceStatus: SMAppService.Status) {
let passedThroughCLI = CommandLine.arguments.contains("--unregister")
if appServiceStatus == .notFound {
if passedThroughCLI {
print("Nudge LaunchAgent has never been registered")
exit(0)
} else {
osLog.info("Nudge LaunchAgent has never been registered")
}
} else if appServiceStatus == .notRegistered {
if passedThroughCLI {
print("Nudge LaunchAgent is not currently registered")
exit(0)
} else {
osLog.info("Nudge LaunchAgent is not currently registered")
}
} else {
do {
if passedThroughCLI {
print("Unregistering Nudge LaunchAgent")
} else {
osLog.info("Unregistering Nudge LaunchAgent")
}
try appService.unregister()
} catch {
if passedThroughCLI {
print("Failed to unregister Nudge LaunchAgent")
exit(1)
} else {
osLog.info("Failed to unregister Nudge LaunchAgent")
return
}
}
if passedThroughCLI {
print("Successfully unregistered Nudge LaunchAgent")
exit(0)
} else {
osLog.info("Successfully unregistered Nudge LaunchAgent")
}
}
}

func allow24HourDeferral() -> Bool {
if demoModeEnabled() {
return true
Expand Down
33 changes: 0 additions & 33 deletions Nudge/com.github.macadmins.Nudge.SMAppService.plist

This file was deleted.

14 changes: 0 additions & 14 deletions Schema/jamf/com.github.macadmins.Nudge.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,20 +744,6 @@
}
]
},
"loadLaunchAgent": {
"description": "Loads the Nudge LaunchAgent using macOS Ventura's SMAppService API (macOS 13+ required).",
"anyOf": [
{
"title": "Not Configured",
"type": "null"
},
{
"title": "Configured",
"default": false,
"type": "boolean"
}
]
},
"maxRandomDelayInSeconds": {
"description": "The maximum amount of delay Nudge will utilize before launching the UI. This is useful if you do not want your users to all receive the Nudge prompt at the exact time of the LaunchAgent. Note: This functionality only applies when also enabling `randomDelay`.",
"anyOf": [
Expand Down