From 21ec1735e1f80011a5affa4fe62c20ba40e3a829 Mon Sep 17 00:00:00 2001 From: Charlie Stigler Date: Thu, 23 Sep 2021 16:14:37 -0700 Subject: [PATCH] Fix SC Killer on legacy blocks, + upgrade Sentry to 7.3.0 --- Common/Utility/SCMigrationUtilities.h | 1 + Common/Utility/SCMigrationUtilities.m | 9 +++++++-- Podfile | 10 +++++----- SCKillerHelper/main.m | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Common/Utility/SCMigrationUtilities.h b/Common/Utility/SCMigrationUtilities.h index 44ee95d..f650348 100644 --- a/Common/Utility/SCMigrationUtilities.h +++ b/Common/Utility/SCMigrationUtilities.h @@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)copyLegacySettingsToDefaults; + (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID; ++ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID ignoreRunningBlock:(BOOL)ignoreRunningBlock; @end diff --git a/Common/Utility/SCMigrationUtilities.m b/Common/Utility/SCMigrationUtilities.m index f5d162d..b9b280e 100644 --- a/Common/Utility/SCMigrationUtilities.m +++ b/Common/Utility/SCMigrationUtilities.m @@ -210,7 +210,7 @@ + (void)copyLegacySettingsToDefaults { // - the defaults system // - a v3.x per-user secured settings file // we should check for block settings in all of these places and get rid of them -+ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID { ++ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID ignoreRunningBlock:(BOOL)ignoreRunningBlock { NSLog(@"Clearing legacy settings!"); BOOL runningAsRoot = (geteuid() == 0); @@ -224,7 +224,7 @@ + (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID { } // if we're gonna clear settings, there can't be a block running anywhere. otherwise, we should wait! - if ([SCBlockUtilities legacyBlockIsRunning]) { + if ([SCBlockUtilities legacyBlockIsRunning] && !ignoreRunningBlock) { NSLog(@"ERROR: Can't clear legacy settings because a block is ongoing!"); NSError* err = [SCErr errorWithCode: 702]; [SCSentry captureError: err]; @@ -290,5 +290,10 @@ + (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID { return retErr; } ++ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID { + return [SCMigrationUtilities clearLegacySettingsForUser: controllingUID ignoreRunningBlock: NO]; +} + + @end diff --git a/Podfile b/Podfile index bccb1be..1d71587 100644 --- a/Podfile +++ b/Podfile @@ -14,7 +14,7 @@ target "SelfControl" do pod 'TransformerKit', '~> 1.1.1' pod 'FormatterKit/TimeIntervalFormatter', '~> 1.8.0' pod 'LetsMove', '~> 1.24' - pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.0.3' + pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.3.0' # Add test target target 'SelfControlTests' do @@ -24,19 +24,19 @@ end target "SelfControl Killer" do use_frameworks! :linkage => :static - pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.0.3' + pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.3.0' end # we can't use_frameworks on these because they're command-line tools # Sentry says we need use_frameworks, but they seem to work OK anyway? target "SCKillerHelper" do - pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.0.3' + pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.3.0' end target "selfcontrol-cli" do - pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.0.3' + pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.3.0' end target "org.eyebeam.selfcontrold" do - pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.0.3' + pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.3.0' end post_install do |pi| diff --git a/SCKillerHelper/main.m b/SCKillerHelper/main.m index b889fd8..18eb5fd 100644 --- a/SCKillerHelper/main.m +++ b/SCKillerHelper/main.m @@ -201,7 +201,7 @@ int main(int argc, char* argv[]) { if ([SCMigrationUtilities legacySettingsFoundForUser: controllingUID]) { [SCMigrationUtilities copyLegacySettingsToDefaults: controllingUID]; - [SCMigrationUtilities clearLegacySettingsForUser: controllingUID]; + [SCMigrationUtilities clearLegacySettingsForUser: controllingUID ignoreRunningBlock: YES]; [log appendFormat: @"Found, copied, and cleared legacy settings (v3.0-3.0.3)!\n"]; } else { [log appendFormat: @"No legacy settings (v3.0-3.0.3) found.\n"];