Fixed bug in "disable" logic
Improved handling for setting action scripts/binaries
This commit is contained in:
Patrick Wardle 2023-11-22 11:36:57 -10:00
parent fd2d903328
commit bd58fdf8cb
6 changed files with 73 additions and 34 deletions

View File

@ -22,7 +22,6 @@
CD2F800C24455333009C3D77 /* AboutWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD2F800924455333009C3D77 /* AboutWindow.xib */; };
CD2F800D24455333009C3D77 /* AboutWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2F800B24455333009C3D77 /* AboutWindowController.m */; };
CD2F801724468A8C009C3D77 /* patrons.txt in Resources */ = {isa = PBXBuildFile; fileRef = CD2F801624468A8C009C3D77 /* patrons.txt */; };
CD3052C72AF6D86600250347 /* OverSight Installer.app in Resources */ = {isa = PBXBuildFile; fileRef = CD3052C62AF6D86600250347 /* OverSight Installer.app */; };
CD6836682391DB6F00CF19C1 /* security.plist in Resources */ = {isa = PBXBuildFile; fileRef = CD6836672391DB6F00CF19C1 /* security.plist */; };
CD8FD5D523BAE2D200EFE0FB /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD8FD5D323BAE2D100EFE0FB /* Preferences.xib */; };
CD8FD5D623BAE2D200EFE0FB /* PrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CD8FD5D423BAE2D200EFE0FB /* PrefsWindowController.m */; };
@ -34,6 +33,7 @@
CDC60991263CBD36006D1332 /* AVMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = CDC60990263CBD36006D1332 /* AVMonitor.m */; };
CDC60994263CBEE7006D1332 /* Client.m in Sources */ = {isa = PBXBuildFile; fileRef = CDC60993263CBEE7006D1332 /* Client.m */; };
CDCBF0DE26499DFF001D9F9A /* Event.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCBF0DD26499DFF001D9F9A /* Event.m */; };
CDE4C11A2B0EAA7A001521CE /* OverSight Installer.app in Resources */ = {isa = PBXBuildFile; fileRef = CDE4C1192B0EAA7A001521CE /* OverSight Installer.app */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -76,7 +76,6 @@
CD2F800A24455333009C3D77 /* AboutWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutWindowController.h; sourceTree = "<group>"; };
CD2F800B24455333009C3D77 /* AboutWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutWindowController.m; sourceTree = "<group>"; };
CD2F801624468A8C009C3D77 /* patrons.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = patrons.txt; path = ../Shared/patrons.txt; sourceTree = "<group>"; };
CD3052C62AF6D86600250347 /* OverSight Installer.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "OverSight Installer.app"; sourceTree = "<group>"; };
CD6836672391DB6F00CF19C1 /* security.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = security.plist; sourceTree = "<group>"; };
CD8FD5D223BAE2D100EFE0FB /* PrefsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrefsWindowController.h; sourceTree = "<group>"; };
CD8FD5D323BAE2D100EFE0FB /* Preferences.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Preferences.xib; sourceTree = "<group>"; };
@ -96,6 +95,7 @@
CDC60993263CBEE7006D1332 /* Client.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Client.m; sourceTree = "<group>"; };
CDCBF0DC26499DFF001D9F9A /* Event.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = "<group>"; };
CDCBF0DD26499DFF001D9F9A /* Event.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Event.m; sourceTree = "<group>"; };
CDE4C1192B0EAA7A001521CE /* OverSight Installer.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "OverSight Installer.app"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -214,7 +214,7 @@
CDE09AF12919829000561CFF /* Uninstaller */ = {
isa = PBXGroup;
children = (
CD3052C62AF6D86600250347 /* OverSight Installer.app */,
CDE4C1192B0EAA7A001521CE /* OverSight Installer.app */,
);
path = Uninstaller;
sourceTree = "<group>";
@ -292,7 +292,7 @@
buildActionMask = 2147483647;
files = (
CD8FD5D523BAE2D200EFE0FB /* Preferences.xib in Resources */,
CD3052C72AF6D86600250347 /* OverSight Installer.app in Resources */,
CDE4C11A2B0EAA7A001521CE /* OverSight Installer.app in Resources */,
CD6836682391DB6F00CF19C1 /* security.plist in Resources */,
CD2F800C24455333009C3D77 /* AboutWindow.xib in Resources */,
7D16D6951F64E43300DB3161 /* UpdateWindow.xib in Resources */,
@ -465,7 +465,7 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.2.0;
CURRENT_PROJECT_VERSION = 2.2.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -476,7 +476,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.2;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight";
PRODUCT_NAME = OverSight;
@ -491,7 +491,7 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.2.0;
CURRENT_PROJECT_VERSION = 2.2.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -502,7 +502,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.2;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight";
PRODUCT_NAME = OverSight;

View File

@ -19,7 +19,6 @@
#import "Event.h"
#import "LogMonitor.h"
@interface AVMonitor : NSObject <UNUserNotificationCenterDelegate>
//log monitor
@ -67,6 +66,9 @@
//last alert (default) interaction
@property(nonatomic, retain)NSDate* lastNotificationDefaultAction;
//listener queue
@property(nonatomic, retain)dispatch_queue_t eventQueue;
/* METHODS */
//start

View File

@ -62,6 +62,9 @@ extern os_log_t logHandle;
//init video listeners
self.cameraListeners = [NSMutableDictionary dictionary];
//init event queue
self.eventQueue = dispatch_queue_create([[NSString stringWithFormat:@"%s.eventQueue", BUNDLE_ID] UTF8String], DISPATCH_QUEUE_CONCURRENT);
//set up delegate
UNUserNotificationCenter.currentNotificationCenter.delegate = self;
@ -789,7 +792,7 @@ extern os_log_t logHandle;
};
//add property listener for audio changes
status = AudioObjectAddPropertyListenerBlock(deviceID, &propertyStruct, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), listenerBlock);
status = AudioObjectAddPropertyListenerBlock(deviceID, &propertyStruct, self.eventQueue, listenerBlock);
if(noErr != status)
{
//err msg
@ -803,7 +806,7 @@ extern os_log_t logHandle;
self.audioListeners[device.uniqueID] = listenerBlock;
//dbg msg
os_log_debug(logHandle, "monitoring %{public}@ for audio changes", device.localizedName);
os_log_debug(logHandle, "monitoring %{public}@ (uuid: %{public}@ / %x) for audio changes", device.localizedName, device.uniqueID, deviceID);
//happy
bRegistered = YES;
@ -922,7 +925,7 @@ bail:
};
//register (add) property block listener
status = CMIOObjectAddPropertyListenerBlock(deviceID, &propertyStruct, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), listenerBlock);
status = CMIOObjectAddPropertyListenerBlock(deviceID, &propertyStruct, self.eventQueue, listenerBlock);
if(noErr != status)
{
//err msg
@ -936,7 +939,7 @@ bail:
self.cameraListeners[device.uniqueID] = listenerBlock;
//dbg msg
os_log_debug(logHandle, "monitoring %{public}@ for video changes", device.localizedName);
os_log_debug(logHandle, "monitoring %{public}@ (uuid: %{public}@ / %x) for video changes", device.localizedName, device.uniqueID, deviceID);
//happy
bRegistered = YES;
@ -1023,7 +1026,7 @@ bail:
builtInMic = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
//dbg msg
os_log_debug(logHandle, "Apple Mic not found, defaulting to default device: %{public}@/%{public}@)", builtInMic.manufacturer, builtInMic.localizedName);
os_log_debug(logHandle, "Apple Mic not found, defaulting to default device: %{public}@/%{public}@", builtInMic.manufacturer, builtInMic.localizedName);
}
return builtInMic;
@ -1046,7 +1049,8 @@ bail:
{
//is built in camera?
if( (YES == [currentCamera.uniqueID isEqualToString:@"FaceTime HD Camera"]) ||
(YES == [currentCamera.localizedName isEqualToString:@"FaceTime-HD-camera"]) )
(YES == [currentCamera.localizedName isEqualToString:@"FaceTime-HD-camera"]) ||
(YES == [currentCamera.localizedName isEqualToString:@"FaceTime HD Camera"]) )
{
//found
builtInCamera = currentCamera;
@ -1215,6 +1219,20 @@ bail:
//extract its last event
deviceLastEvent = self.deviceEvents[deviceID];
//disabled?
// really shouldn't ever get here, but can't hurt to check
if(YES == [NSUserDefaults.standardUserDefaults boolForKey:PREF_IS_DISABLED])
{
//set result
result = NOTIFICATION_SPURIOUS;
//dbg msg
os_log_debug(logHandle, "disable is set, so ignoring event");
//bail
goto bail;
}
//inactive alerting off?
// ignore if event is an inactive/off
if( (NSControlStateValueOff == event.state) &&
@ -1380,13 +1398,14 @@ bail:
{
//deliver
[self showNotification:event];
//execute user-specified action?
if(YES == [NSUserDefaults.standardUserDefaults boolForKey:PREF_EXECUTE_ACTION])
{
//exec
[self executeUserAction:event];
}
}
//should (also) exec user action?
if( (NOTIFICATION_ERROR != result) &&
(NOTIFICATION_SPURIOUS != result) &&
(0 != [[NSUserDefaults.standardUserDefaults objectForKey:PREF_EXECUTE_PATH] length]) )
{
//exec
[self executeUserAction:event];
}
return;
@ -1590,7 +1609,7 @@ bail:
propertyStruct.mElement = kAudioObjectPropertyElementMaster;
//remove
status = AudioObjectRemovePropertyListenerBlock(deviceID, &propertyStruct, dispatch_get_main_queue(), self.audioListeners[device.uniqueID]);
status = AudioObjectRemovePropertyListenerBlock(deviceID, &propertyStruct, self.eventQueue, self.audioListeners[device.uniqueID]);
if(noErr != status)
{
//err msg
@ -1600,6 +1619,9 @@ bail:
goto bail;
}
//dbg msg
os_log_debug(logHandle, "stopped monitoring %{public}@ (uuid: %{public}@ / %x) for audio changes", device.localizedName, device.uniqueID, deviceID);
//unset listener block
self.audioListeners[device.uniqueID] = nil;
@ -1633,7 +1655,7 @@ bail:
propertyStruct.mElement = kAudioObjectPropertyElementMaster;
//remove
status = CMIOObjectRemovePropertyListenerBlock(deviceID, &propertyStruct, dispatch_get_main_queue(), self.cameraListeners[device.uniqueID]);
status = CMIOObjectRemovePropertyListenerBlock(deviceID, &propertyStruct, self.eventQueue, self.cameraListeners[device.uniqueID]);
if(noErr != status)
{
//err msg
@ -1643,6 +1665,9 @@ bail:
goto bail;
}
//dbg msg
os_log_debug(logHandle, "stopped monitoring %{public}@ (uuid: %{public}@ / %x) for video changes", device.localizedName, device.uniqueID, deviceID);
//unset listener block
self.cameraListeners[device.uniqueID] = nil;

View File

@ -27,7 +27,7 @@
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="196" y="240" width="600" height="426"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<rect key="screenRect" x="0.0" y="0.0" width="3440" height="1415"/>
<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="600" height="426"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

View File

@ -466,6 +466,9 @@ bail:
{
//uncheck
self.executePathButton.state = NSControlStateValueOff;
//unset
[NSUserDefaults.standardUserDefaults setBool:NSControlStateValueOff forKey:PREF_EXECUTE_ACTION];
}
//bail
@ -478,6 +481,15 @@ bail:
//ensure its executable
execTask(CHMOD, @[@"+x", panel.URL.path], YES, NO);
//enable
self.executePath.enabled = NSControlStateValueOn;
//check button as well
self.executePathButton.state = NSControlStateValueOn;
//save execute state
[NSUserDefaults.standardUserDefaults setBool:NSControlStateValueOn forKey:PREF_EXECUTE_ACTION];
//save path & sync
[NSUserDefaults.standardUserDefaults setObject:self.executePath.stringValue forKey:PREF_EXECUTE_PATH];
[NSUserDefaults.standardUserDefaults synchronize];

View File

@ -329,7 +329,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#Note: To build uninstaller for app (menu)\n# 0. Delete this script and Installer.app from App's on-disk folder \n# 1. Build Installer\n# 2. Copy into App \"Uninstaller\" folder (& proj if needed)\n# 3. Re-add script, and then build (archive) for deployment\n\n#archive\n# copy in main application \nif [[ $BUILT_PRODUCTS_DIR = *\"ArchiveIntermediates\"* ]]; then\n cp -R -f \"$PROJECT_TEMP_ROOT/UninstalledProducts/macosx/OverSight.app\" \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources\"\n \n#normal build\n# delete and copy in main application \nelse\n\nrm -rf \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources/OverSight.app\"\ncp -R -f \"$BUILT_PRODUCTS_DIR/OverSight.app\" \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources\"\n\nfi\n\n\n";
shellScript = "#Note: To build uninstaller for app (menu)\n# 0. Delete this script and Installer.app from App's on-disk folder \n# 1. Build Installer\n# 2. Copy into App \"Uninstaller\" folder (& proj if needed)\n# 3. Re-add script, and then build (archive) for deployment\n\n#archive\n# copy in main application \nif [[ $BUILT_PRODUCTS_DIR = *\"ArchiveIntermediates\"* ]]; then\n cp -R -f \"$PROJECT_TEMP_ROOT/UninstalledProducts/macosx/OverSight.app\" \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources\"\n \n#normal build\n# delete and copy in main application \nelse\n\nrm -rf \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources/OverSight.app\"\ncp -R -f \"$BUILT_PRODUCTS_DIR/OverSight.app\" \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources\"\n\nfi\n\n";
};
/* End PBXShellScriptBuildPhase section */
@ -380,14 +380,14 @@
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2.2.0;
CURRENT_PROJECT_VERSION = 2.2.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = NO;
INFOPLIST_FILE = Helper/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.2;
ONLY_ACTIVE_ARCH = NO;
OTHER_CODE_SIGN_FLAGS = "";
OTHER_LDFLAGS = (
@ -415,14 +415,14 @@
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2.2.0;
CURRENT_PROJECT_VERSION = 2.2.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = NO;
INFOPLIST_FILE = Helper/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.2;
ONLY_ACTIVE_ARCH = NO;
OTHER_CODE_SIGN_FLAGS = "";
OTHER_LDFLAGS = (
@ -451,7 +451,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.2.0;
CURRENT_PROJECT_VERSION = 2.2.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -463,7 +463,7 @@
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.2;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight.installer";
PRODUCT_NAME = "OverSight Installer";
@ -480,7 +480,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.2.0;
CURRENT_PROJECT_VERSION = 2.2.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -492,7 +492,7 @@
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.2;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight.installer";
PRODUCT_NAME = "OverSight Installer";