Skip to content

Commit 7860a76

Browse files
committed
updates and fixes
1 parent a03eb16 commit 7860a76

4 files changed

Lines changed: 57 additions & 34 deletions

File tree

Object Info.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
"@executable_path/../Frameworks",
344344
);
345345
MACOSX_DEPLOYMENT_TARGET = 13.0;
346-
MARKETING_VERSION = 3.1.0;
346+
MARKETING_VERSION = 3.1.1;
347347
PRODUCT_BUNDLE_IDENTIFIER = com.jamf.pse.ObjectInfo;
348348
PRODUCT_NAME = "$(TARGET_NAME)";
349349
SWIFT_VERSION = 5.0;
@@ -369,7 +369,7 @@
369369
"@executable_path/../Frameworks",
370370
);
371371
MACOSX_DEPLOYMENT_TARGET = 13.0;
372-
MARKETING_VERSION = 3.1.0;
372+
MARKETING_VERSION = 3.1.1;
373373
PRODUCT_BUNDLE_IDENTIFIER = com.jamf.pse.ObjectInfo;
374374
PRODUCT_NAME = "$(TARGET_NAME)";
375375
SWIFT_VERSION = 5.0;

ObjectInfo/LoginVC.swift

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -703,37 +703,46 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
703703
let _sharedContainerUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.\(appsGroupId)")
704704
let _sharedSettingsPlistUrl = (_sharedContainerUrl?.appendingPathComponent("Library/Preferences/group.\(appsGroupId).plist"))!
705705
print("[migrateSettings] _sharedSettingsPlistUrl: \(_sharedSettingsPlistUrl.path(percentEncoded: false))")
706-
707-
if FileManager.default.fileExists(atPath: _sharedSettingsPlistUrl.path(percentEncoded: false)) {
708-
if !FileManager.default.fileExists(atPath: sharedSettingsPlistUrl.path(percentEncoded: false)) {
709-
print("[viewDidLoad] creating settings file")
710-
sharedDefaults!.set(Date(), forKey: "created")
711-
sharedDefaults!.set([String:AnyObject](), forKey: "serversDict")
712-
}
713-
print("[migrateSettings] file exists")
714-
if FileManager.default.isReadableFile(atPath: _sharedSettingsPlistUrl.path(percentEncoded: false)) {
715-
print("[migrateSettings] file is readable")
716-
do {
717-
let data = try Data(contentsOf: _sharedSettingsPlistUrl)
718-
print("[migrateSettings] file settings to data")
719-
720-
let plist = try PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any]
721-
print("[migrateSettings] converted to dictionary")
722-
for (key, value) in plist ?? [:] {
723-
print("[migrateSettings] setting value for key: \(key)")
724-
sharedDefaults!.set(value, forKey: key)
706+
707+
if !FileManager.default.fileExists(atPath: sharedSettingsPlistUrl.path(percentEncoded: false)) {
708+
print("[viewDidLoad] creating settings file")
709+
sharedDefaults!.set(Date(), forKey: "created")
710+
sharedDefaults!.set([String:AnyObject](), forKey: "serversDict")
711+
}
712+
let settingsMigrated = sharedDefaults!.object(forKey: "migrated") as? String ?? "false"
713+
print("[viewDidLoad] settingsMigrated: \(settingsMigrated)")
714+
if settingsMigrated != "true" {
715+
if FileManager.default.fileExists(atPath: _sharedSettingsPlistUrl.path(percentEncoded: false)) {
716+
print("[migrateSettings] file exists")
717+
if FileManager.default.isReadableFile(atPath: _sharedSettingsPlistUrl.path(percentEncoded: false)) {
718+
print("[migrateSettings] file is readable")
719+
do {
720+
let data = try Data(contentsOf: _sharedSettingsPlistUrl)
721+
print("[migrateSettings] file settings to data")
722+
723+
let plist = try PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any]
724+
print("[migrateSettings] converted to dictionary")
725+
for (key, value) in plist ?? [:] {
726+
// print("[migrateSettings] setting value for key: \(key)")
727+
sharedDefaults!.set(value, forKey: key)
728+
}
729+
sharedDefaults!.set("true" as AnyObject, forKey: "migrated")
730+
WriteToLog.shared.message(stringOfText: "[migrateSettings] migrated settings")
731+
} catch {
732+
print("[migrateSettings] failed to migrate settings")
725733
}
726-
try FileManager.default.moveItem(atPath: _sharedSettingsPlistUrl.path(percentEncoded: false), toPath: _sharedSettingsPlistUrl.path(percentEncoded: false).appending(".bak_\(WriteToLog.shared.getCurrentTime())"))
727-
WriteToLog.shared.message(stringOfText: "[migrateSettings] migrated settings")
728-
} catch {
729-
print("[migrateSettings] failed to migrate settings")
734+
} else {
735+
print("[migrateSettings] file is not readable")
730736
}
731737
} else {
732-
print("[migrateSettings] file is not readable")
738+
do {
739+
sharedDefaults!.set("true" as AnyObject, forKey: "migrated")
740+
try FileManager.default.copyItem(atPath: sharedSettingsPlistUrl.path(percentEncoded: false), toPath: _sharedSettingsPlistUrl.path(percentEncoded: false))
741+
} catch {
742+
743+
}
733744
}
734-
} else {
735-
print("[migrateSettings] did not find old settings")
736-
}
745+
}
737746
}
738747
}
739748

ObjectInfo/ViewController.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,19 +1560,31 @@ class ViewController: NSViewController, URLSessionDelegate, SendingLoginInfoDele
15601560
WriteToLog.shared.message(stringOfText: "[getLimitationsExceptions] endpointType: \(endpointType)")
15611561

15621562
if let scope = endpointInfo["scope"] as? [String : AnyObject] {
1563+
print("[getLimitationsExceptions] scope: \(scope)")
15631564
for lore in ["limitations", "exclusions"] {
15641565
var currentList = [String]()
15651566
if let limitationsExclusions = scope[lore] as? [String: AnyObject] {
1566-
if let groupDict = limitationsExclusions["user_groups"] as? [[String:String]] {
1567+
if let groupDict = limitationsExclusions["mobile_devices"] as? [[String: Any]] {
15671568
for groupInfo in groupDict {
1568-
if let groupName = groupInfo["name"] {
1569+
if let groupName = groupInfo["name"] as? String {
1570+
currentList.append(groupName)
1571+
}
1572+
}
1573+
}
1574+
if let groupDict = limitationsExclusions["user_groups"] as? [[String: Any]] {
1575+
for groupInfo in groupDict {
1576+
if let groupName = groupInfo["name"] as? String {
15691577
currentList.append(groupName)
15701578
}
15711579
}
15721580
}
15731581
}
15741582
limitationsExclusionsDict[lore] = currentList
1575-
self.detailedResults.append("\t\(limitationsExclusionsDict[lore] ?? [])")
1583+
if limitationsExclusionsDict[lore]?.count ?? 0 > 0 {
1584+
self.detailedResults.append("\tmobile_devices:\(limitationsExclusionsDict[lore] ?? [])")
1585+
} else {
1586+
self.detailedResults.append("\t")
1587+
}
15761588
}
15771589

15781590
}
@@ -1629,9 +1641,9 @@ class ViewController: NSViewController, URLSessionDelegate, SendingLoginInfoDele
16291641
}
16301642
} // else - end
16311643
// convert array to comma seperated list (newline not working)
1632-
var scopeList = "[]"
1644+
var scopeList = ""
16331645
for scopeItem in currentScopeArray {
1634-
if scopeList != "[]" {
1646+
if scopeList != "" {
16351647
scopeList.append(", \(scopeItem)")
16361648
} else {
16371649
scopeList = "\(scopeItem)"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Unused objects are not displayed. For example, if a package is not used in eith
2828

2929
**History**
3030

31+
2024-12-19: Version 3.1.1 - Better handling of shared settings. Sequoia introduced additional security around data stored in ~/Library/Group Containers that results in a prompt to access existing settings. This should give a one time prompt to allow access.
32+
3133
2024-12-19: Version 3.1.0 - Add scanning for printers in policies (issue #22). Unable to replicate crash on scanning prestages for packages but made modifications that may address the issue (#24).
3234

3335
2024-09-27: Version 3.0.0 - Address issues 16, 19, and 20. Add login window and update UI.

0 commit comments

Comments
 (0)