Skip to content

Commit

Permalink
Fix SC Killer on legacy blocks, + upgrade Sentry to 7.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cstigler committed Sep 23, 2021
1 parent b484257 commit 21ec173
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions Common/Utility/SCMigrationUtilities.h
Expand Up @@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)copyLegacySettingsToDefaults;

+ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID;
+ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID ignoreRunningBlock:(BOOL)ignoreRunningBlock;

@end

Expand Down
9 changes: 7 additions & 2 deletions Common/Utility/SCMigrationUtilities.m
Expand Up @@ -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);
Expand All @@ -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];
Expand Down Expand Up @@ -290,5 +290,10 @@ + (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID {
return retErr;
}

+ (NSError*)clearLegacySettingsForUser:(uid_t)controllingUID {
return [SCMigrationUtilities clearLegacySettingsForUser: controllingUID ignoreRunningBlock: NO];
}



@end
10 changes: 5 additions & 5 deletions Podfile
Expand Up @@ -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
Expand All @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion SCKillerHelper/main.m
Expand Up @@ -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"];
Expand Down

0 comments on commit 21ec173

Please sign in to comment.