@@ -95,9 +95,11 @@ @implementation SNTConfigurator
9595static NSString *const kStatsOrganizationID = @" StatsOrganizationID" ;
9696
9797static NSString *const kMachineOwnerKey = @" MachineOwner" ;
98+ static NSString *const kMachineOwnerGroupsKey = @" MachineOwnerGroups" ;
9899static NSString *const kMachineIDKey = @" MachineID" ;
99100static NSString *const kMachineOwnerPlistFileKey = @" MachineOwnerPlist" ;
100101static NSString *const kMachineOwnerPlistKeyKey = @" MachineOwnerKey" ;
102+ static NSString *const kMachineOwnerGroupsPlistKeyKey = @" MachineOwnerGroupsKey" ;
101103static NSString *const kMachineIDPlistFileKey = @" MachineIDPlist" ;
102104static NSString *const kMachineIDPlistKeyKey = @" MachineIDKey" ;
103105
@@ -284,9 +286,11 @@ - (instancetype)initWithSyncStateFile:(NSString *)syncStateFilePath
284286 kEnableStatsCollectionKey : number,
285287 kStatsOrganizationID : string,
286288 kMachineOwnerKey : string,
289+ kMachineOwnerGroupsKey : array,
287290 kMachineIDKey : string,
288291 kMachineOwnerPlistFileKey : string,
289292 kMachineOwnerPlistKeyKey : string,
293+ kMachineOwnerGroupsPlistKeyKey : string,
290294 kMachineIDPlistFileKey : string,
291295 kMachineIDPlistKeyKey : string,
292296 kEventLogType : string,
@@ -542,6 +546,10 @@ + (NSSet *)keyPathsForValuesAffectingMachineOwner {
542546 return [self configStateSet ];
543547}
544548
549+ + (NSSet *)keyPathsForValuesAffectingMachineOwnerGroups {
550+ return [self configStateSet ];
551+ }
552+
545553+ (NSSet *)keyPathsForValuesAffectingMachineID {
546554 return [self configStateSet ];
547555}
@@ -1031,14 +1039,34 @@ - (NSString *)machineOwner {
10311039
10321040 NSString *plistPath = self.configState [kMachineOwnerPlistFileKey ];
10331041 NSString *plistKey = self.configState [kMachineOwnerPlistKeyKey ];
1034- if (plistPath && plistKey) {
1042+ if (plistPath. length && plistKey. length ) {
10351043 NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile: plistPath];
10361044 machineOwner = [plist[plistKey] isKindOfClass: [NSString class ]] ? plist[plistKey] : nil ;
10371045 }
10381046
10391047 return machineOwner ?: @" " ;
10401048}
10411049
1050+ - (NSArray <NSString *> *)machineOwnerGroups {
1051+ NSArray <NSString *> *machineOwnerGroups = self.configState [kMachineOwnerGroupsKey ];
1052+ if (machineOwnerGroups.count ) return machineOwnerGroups;
1053+
1054+ NSString *plistPath = self.configState [kMachineOwnerPlistFileKey ];
1055+ NSString *plistKey = self.configState [kMachineOwnerGroupsPlistKeyKey ];
1056+ if (plistPath.length && plistKey.length ) {
1057+ NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile: plistPath];
1058+ machineOwnerGroups = [plist[plistKey] isKindOfClass: [NSArray class ]] ? plist[plistKey] : nil ;
1059+ for (NSString *group in machineOwnerGroups) {
1060+ if (![group isKindOfClass: [NSString class ]]) {
1061+ machineOwnerGroups = nil ;
1062+ break ;
1063+ }
1064+ }
1065+ }
1066+
1067+ return machineOwnerGroups;
1068+ }
1069+
10421070- (NSString *)machineID {
10431071 NSString *machineId = self.configState [kMachineIDKey ];
10441072 if (machineId) return machineId;
0 commit comments