Files
santa/Source/santasyncservice/SNTSyncPostflight.m
Matt W 70474aba3e Sync clean all (#1275)
* WIP Clean syncs now leave non-transitive rules by default

* WIP Get existing tests compiling and passing

* Remove clean all sync server key. Basic tests.

* Add SNTConfiguratorTest, test deprecated key migration

* Revert changes to santactl status output

* Add new preflight response sync type key, lots of tests

* Rework configurator flow a bit so calls cannot be made out of order

* Comment clean sync states. Test all permutations.

* Update docs for new sync keys

* Doc updates as requested in PR
2024-01-24 09:26:20 -05:00

114 lines
3.6 KiB
Objective-C

/// Copyright 2015 Google Inc. All rights reserved.
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
#import "Source/santasyncservice/SNTSyncPostflight.h"
#import <MOLXPCConnection/MOLXPCConnection.h>
#import "Source/common/SNTSyncConstants.h"
#import "Source/common/SNTXPCControlInterface.h"
#import "Source/santasyncservice/SNTSyncState.h"
@implementation SNTSyncPostflight
- (NSURL *)stageURL {
NSString *stageName = [@"postflight" stringByAppendingFormat:@"/%@", self.syncState.machineID];
return [NSURL URLWithString:stageName relativeToURL:self.syncState.syncBaseURL];
}
- (BOOL)sync {
[self performRequest:[self requestWithDictionary:@{
kPostflightRulesReceived : @(self.syncState.rulesReceived),
kPostflightRulesProcessed : @(self.syncState.rulesProcessed),
}]];
id<SNTDaemonControlXPC> rop = [self.daemonConn synchronousRemoteObjectProxy];
// Set client mode if it changed
if (self.syncState.clientMode) {
[rop setClientMode:self.syncState.clientMode
reply:^{
}];
}
// Remove clean sync flag if we did a clean or clean all sync
if (self.syncState.syncType != SNTSyncTypeNormal) {
[rop setSyncTypeRequired:SNTSyncTypeNormal
reply:^{
}];
}
// Update allowlist/blocklist regexes
if (self.syncState.allowlistRegex) {
[rop setAllowedPathRegex:self.syncState.allowlistRegex
reply:^{
}];
}
if (self.syncState.blocklistRegex) {
[rop setBlockedPathRegex:self.syncState.blocklistRegex
reply:^{
}];
}
if (self.syncState.blockUSBMount != nil) {
[rop setBlockUSBMount:[self.syncState.blockUSBMount boolValue]
reply:^{
}];
}
if (self.syncState.remountUSBMode) {
[rop setRemountUSBMode:self.syncState.remountUSBMode
reply:^{
}];
}
if (self.syncState.enableBundles) {
[rop setEnableBundles:[self.syncState.enableBundles boolValue]
reply:^{
}];
}
if (self.syncState.enableTransitiveRules) {
[rop setEnableTransitiveRules:[self.syncState.enableTransitiveRules boolValue]
reply:^{
}];
}
if (self.syncState.enableAllEventUpload) {
[rop setEnableAllEventUpload:[self.syncState.enableAllEventUpload boolValue]
reply:^{
}];
}
if (self.syncState.disableUnknownEventUpload) {
[rop setDisableUnknownEventUpload:[self.syncState.disableUnknownEventUpload boolValue]
reply:^{
}];
}
if (self.syncState.overrideFileAccessAction) {
[rop setOverrideFileAccessAction:self.syncState.overrideFileAccessAction
reply:^{
}];
}
// Update last sync success
[rop setFullSyncLastSuccess:[NSDate date]
reply:^{
}];
return YES;
}
@end