fixed: Bug #3927 - Mavericks accessibility exception not working (when upgrading from 1.4.15 to 1.4.16)

This commit is contained in:
jerry
2014-03-21 16:08:33 +00:00
parent 4d75150143
commit f59569c4a0
11 changed files with 454 additions and 126 deletions

View File

@@ -23,3 +23,7 @@ add_subdirectory(syntool)
if (WIN32)
add_subdirectory(synergyp)
endif()
if (APPLE)
add_subdirectory(synmacph)
endif()

View File

@@ -0,0 +1,39 @@
# synergy -- mouse and keyboard sharing utility
# Copyright (C) 2014 Bolton Software Ltd.
#
# This package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# found in the file COPYING that should have accompanied this file.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
file(GLOB sources "*.c" "*.plist")
include_directories(
../
)
add_executable(synmacph ${sources})
get_target_property(current_property synmacph LINK_FLAGS)
set(OTHER_LINK_FLAGS "-sectcreate __TEXT __info_plist ${root_dir}/src/cmd/synmacph/Info.plist -sectcreate __TEXT __launchd_plist ${root_dir}/src/cmd/synmacph/Launchd.plist")
if (NOT ${current_property})
set_target_properties(synmacph PROPERTIES LINK_FLAGS ${OTHER_LINK_FLAGS})
endif()
target_link_libraries(synmacph)
if (CONF_CPACK)
install(TARGETS
synmacph
COMPONENT core
DESTINATION bin)
endif()

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>synmacph</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>synmacph</string>
<key>CFBundleVersion</key>
<string>1.5</string>
<key>SMAuthorizedClients</key>
<array>
<string>anchor apple generic and identifier &quot;synergy&quot; and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = SP58PFWX5L)</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>synmacph</string>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>

View File

@@ -0,0 +1,34 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014 Bolton Software Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <syslog.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char * argv[])
{
#pragma unused(argc)
#pragma unused(argv)
system("sudo sqlite3 /Library/Application\\ Support/com.apple.TCC/TCC.db 'delete from access where client like \"%Synergy.app%\"'");
(void) sleep(10);
return EXIT_SUCCESS;
}

View File

@@ -1,98 +1,102 @@
QT += widgets network
TEMPLATE = app
TARGET = synergy
DEPENDPATH += . \
res
INCLUDEPATH += . \
src
FORMS += res/MainWindowBase.ui \
res/AboutDialogBase.ui \
res/ServerConfigDialogBase.ui \
res/ScreenSettingsDialogBase.ui \
res/ActionDialogBase.ui \
res/HotkeyDialogBase.ui \
res/SettingsDialogBase.ui \
res/SetupWizardBase.ui
SOURCES += src/main.cpp \
src/MainWindow.cpp \
src/AboutDialog.cpp \
src/ServerConfig.cpp \
src/ServerConfigDialog.cpp \
src/ScreenSetupView.cpp \
src/Screen.cpp \
src/ScreenSetupModel.cpp \
src/NewScreenWidget.cpp \
src/TrashScreenWidget.cpp \
src/ScreenSettingsDialog.cpp \
src/BaseConfig.cpp \
src/HotkeyDialog.cpp \
src/ActionDialog.cpp \
src/Hotkey.cpp \
src/Action.cpp \
src/KeySequence.cpp \
src/KeySequenceWidget.cpp \
src/SettingsDialog.cpp \
src/AppConfig.cpp \
src/QSynergyApplication.cpp \
src/VersionChecker.cpp \
src/SetupWizard.cpp \
src/IpcClient.cpp \
src/IpcReader.cpp \
src/Ipc.cpp \
src/SynergyLocale.cpp \
src/QUtility.cpp \
src/PremiumAuth.cpp
HEADERS += src/MainWindow.h \
src/AboutDialog.h \
src/ServerConfig.h \
src/ServerConfigDialog.h \
src/ScreenSetupView.h \
src/Screen.h \
src/ScreenSetupModel.h \
src/NewScreenWidget.h \
src/TrashScreenWidget.h \
src/ScreenSettingsDialog.h \
src/BaseConfig.h \
src/HotkeyDialog.h \
src/ActionDialog.h \
src/Hotkey.h \
src/Action.h \
src/KeySequence.h \
src/KeySequenceWidget.h \
src/SettingsDialog.h \
src/AppConfig.h \
src/QSynergyApplication.h \
src/VersionChecker.h \
src/SetupWizard.h \
src/IpcClient.h \
src/IpcReader.h \
src/Ipc.h \
src/SynergyLocale.h \
src/QUtility.h \
src/PremiumAuth.h
RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc
macx {
QMAKE_INFO_PLIST = res/mac/Info.plist
TARGET = Synergy
QSYNERGY_ICON.files = res/mac/Synergy.icns
QSYNERGY_ICON.path = Contents/Resources
QMAKE_BUNDLE_DATA += QSYNERGY_ICON
LIBS += -framework \
ApplicationServices
}
debug {
OBJECTS_DIR = tmp/debug
MOC_DIR = tmp/debug
RCC_DIR = tmp/debug
}
release {
OBJECTS_DIR = tmp/release
MOC_DIR = tmp/release
RCC_DIR = tmp/release
}
win32 {
Debug:DESTDIR = ../../bin/Debug
Release:DESTDIR = ../../bin/Release
}
else:DESTDIR = ../../bin
QT += widgets network
TEMPLATE = app
TARGET = synergy
DEPENDPATH += . \
res
INCLUDEPATH += . \
src
FORMS += res/MainWindowBase.ui \
res/AboutDialogBase.ui \
res/ServerConfigDialogBase.ui \
res/ScreenSettingsDialogBase.ui \
res/ActionDialogBase.ui \
res/HotkeyDialogBase.ui \
res/SettingsDialogBase.ui \
res/SetupWizardBase.ui
SOURCES += src/main.cpp \
src/MainWindow.cpp \
src/AboutDialog.cpp \
src/ServerConfig.cpp \
src/ServerConfigDialog.cpp \
src/ScreenSetupView.cpp \
src/Screen.cpp \
src/ScreenSetupModel.cpp \
src/NewScreenWidget.cpp \
src/TrashScreenWidget.cpp \
src/ScreenSettingsDialog.cpp \
src/BaseConfig.cpp \
src/HotkeyDialog.cpp \
src/ActionDialog.cpp \
src/Hotkey.cpp \
src/Action.cpp \
src/KeySequence.cpp \
src/KeySequenceWidget.cpp \
src/SettingsDialog.cpp \
src/AppConfig.cpp \
src/QSynergyApplication.cpp \
src/VersionChecker.cpp \
src/SetupWizard.cpp \
src/IpcClient.cpp \
src/IpcReader.cpp \
src/Ipc.cpp \
src/SynergyLocale.cpp \
src/QUtility.cpp \
src/PremiumAuth.cpp
HEADERS += src/MainWindow.h \
src/AboutDialog.h \
src/ServerConfig.h \
src/ServerConfigDialog.h \
src/ScreenSetupView.h \
src/Screen.h \
src/ScreenSetupModel.h \
src/NewScreenWidget.h \
src/TrashScreenWidget.h \
src/ScreenSettingsDialog.h \
src/BaseConfig.h \
src/HotkeyDialog.h \
src/ActionDialog.h \
src/Hotkey.h \
src/Action.h \
src/KeySequence.h \
src/KeySequenceWidget.h \
src/SettingsDialog.h \
src/AppConfig.h \
src/QSynergyApplication.h \
src/VersionChecker.h \
src/SetupWizard.h \
src/IpcClient.h \
src/IpcReader.h \
src/Ipc.h \
src/SynergyLocale.h \
src/QUtility.h \
src/PremiumAuth.h
RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc
macx {
HEADERS += src/AXDatabaseCleaner.h
OBJECTIVE_SOURCES += src/AXDatabaseCleaner.mm
QMAKE_INFO_PLIST = res/mac/Info.plist
TARGET = Synergy
QSYNERGY_ICON.files = res/mac/Synergy.icns
QSYNERGY_ICON.path = Contents/Resources
QMAKE_BUNDLE_DATA += QSYNERGY_ICON
LIBS += -framework ApplicationServices \
-framework ServiceManagement \
-framework Security \
-framework cocoa
}
debug {
OBJECTS_DIR = tmp/debug
MOC_DIR = tmp/debug
RCC_DIR = tmp/debug
}
release {
OBJECTS_DIR = tmp/release
MOC_DIR = tmp/release
RCC_DIR = tmp/release
}
win32 {
Debug:DESTDIR = ../../bin/Debug
Release:DESTDIR = ../../bin/Release
}
else:DESTDIR = ../../bin

View File

@@ -12,5 +12,10 @@
<string>Synergy</string>
<key>CFBundleIdentifier</key>
<string>synergy</string>
<key>SMPrivilegedExecutables</key>
<dict>
<key>synmacph</key>
<string>anchor apple generic and identifier &quot;synmacph&quot; and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = SP58PFWX5L)</string>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,30 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014 Bolton Software Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
class AXDatabaseCleaner {
public:
AXDatabaseCleaner();
~AXDatabaseCleaner();
void loadPrivilegeHelper();
private:
class Private;
Private* d;
};

View File

@@ -0,0 +1,78 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014 Bolton Software Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "AXDatabaseCleaner.h"
#import <Cocoa/Cocoa.h>
#import <ServiceManagement/ServiceManagement.h>
#import <Security/Authorization.h>
const NSString* const label = @"synmacph";
class AXDatabaseCleaner::Private {
public:
NSAutoreleasePool* autoReleasePool;
AuthorizationRef authRef;
};
AXDatabaseCleaner::AXDatabaseCleaner()
{
d = new Private;
d->autoReleasePool = [[NSAutoreleasePool alloc] init];
}
AXDatabaseCleaner::~AXDatabaseCleaner()
{
[d->autoReleasePool release];
delete d;
}
void AXDatabaseCleaner::loadPrivilegeHelper()
{
OSStatus status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &d->authRef);
if (status != errAuthorizationSuccess) {
assert(NO);
d->authRef = NULL;
}
AuthorizationItem authItem = {kSMRightBlessPrivilegedHelper, 0, NULL, 0};
AuthorizationRights authRights = {1, &authItem};
AuthorizationFlags flags = kAuthorizationFlagDefaults
| kAuthorizationFlagInteractionAllowed
| kAuthorizationFlagPreAuthorize
| kAuthorizationFlagExtendRights;
BOOL result = NO;
NSError* error = nil;
status = AuthorizationCopyRights(d->authRef, &authRights, kAuthorizationEmptyEnvironment, flags, NULL);
if (status != errAuthorizationSuccess) {
error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
}
else {
CFErrorRef cfError;
result = (BOOL)SMJobBless(kSMDomainSystemLaunchd, (CFStringRef)label, d->authRef, &cfError);
if (!result) {
error = CFBridgingRelease(cfError);
}
}
if (!result) {
assert(error != nil);
NSLog(@"bless error: domain= %@ / code= %d", [error domain], (int) [error code]);
}
}

View File

@@ -31,6 +31,7 @@
#if defined(Q_OS_MAC)
#include <Carbon/Carbon.h>
#include "AXDatabaseCleaner.h"
#endif
class QThreadImpl : public QThread
@@ -136,11 +137,24 @@ bool checkMacAssistiveDevices()
// show up there automatically, but will be unchecked.
const void* keys[] = { kAXTrustedCheckOptionPrompt };
const void* values[] = { kCFBooleanTrue };
const void* falseValue[] = { kCFBooleanFalse };
const void* trueValue[] = { kCFBooleanTrue };
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL);
bool result = AXIsProcessTrustedWithOptions(options);
CFRelease(options);
CFDictionaryRef optionsWithoutPrompt = CFDictionaryCreate(NULL, keys, falseValue, 1, NULL, NULL);
CFDictionaryRef optionsWithPrompt = CFDictionaryCreate(NULL, keys, trueValue, 1, NULL, NULL);
bool result;
result = AXIsProcessTrustedWithOptions(optionsWithoutPrompt);
if (!result) {
// call privilege help tool
AXDatabaseCleaner axdc;
axdc.loadPrivilegeHelper();
result = AXIsProcessTrustedWithOptions(optionsWithPrompt);
}
CFRelease(optionsWithoutPrompt);
CFRelease(optionsWithPrompt);
return result;