Ticket #52514: openconnect-gui.diff
File openconnect-gui.diff, 18.5 KB (added by bket, 8 years ago) |
---|
-
Portfile
diff --git Portfile Portfile index 0ed2653..0c49b15 100644
2 2 # $Id: Portfile 137092 2015-06-04 20:38:23Z cal@macports.org $ 3 3 4 4 PortSystem 1.0 5 PortGroup cmake 1.0 5 6 PortGroup github 1.0 6 7 PortGroup qt5 1.0 7 8 8 github.setup openconnect openconnect-gui 1. 3v9 github.setup openconnect openconnect-gui 1.4.1 v 9 10 categories net 10 11 platforms darwin 11 12 maintainers hydroxide.nl:bjorn.ketelaars openmaintainer … … depends_lib-append port:gnutls \ 19 20 20 21 depends_run port:vpnc-scripts 21 22 22 checksums rmd160 2ee0a3bf301b3c9af6bb3b7663875afea6f0a307 \23 sha256 7 377a5e3de6e5b0764723d66fbd0a1d8b380ddbb5b3862714197a4ba47ee898223 checksums rmd160 f531bf977764aeb773657d32c94b0870acf14527 \ 24 sha256 7415a385269866cfeacde2fee7ae8bb029b4de0fcd3260260fc7bc0ed51c8eae 24 25 25 patchfiles patch-common_h.diff 26 patchfiles patch-CMakeLists_txt.diff \ 27 patch-bundle_qt_conf.diff \ 28 patch-src_CMakeLists_txt.diff \ 29 patch-src_dialog_editdialog_ui.diff \ 30 patch-src_dialog_mainwindow_ui.diff \ 31 patch-src_main_cpp.diff \ 32 patch-src_vpninfo_cpp.diff \ 33 patch-src_vpninfo_h.diff 26 34 27 configure.cmd ${qt_qmake_cmd} 28 configure.pre_args PREFIX="${prefix}" 35 cmake.out_of_source yes 29 36 30 37 post-patch { 31 reinplace -E "s|@PREFIX@|${prefix}|" ${worksrcpath}/common.h38 reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/CMakeLists.txt 32 39 } 33 40 34 41 destroot { 35 copy "${work srcpath}/openconnect-gui.app" ${destroot}${applications_dir}42 copy "${workpath}/build/bin/openconnect-gui.app" ${destroot}${applications_dir} 36 43 } 37 44 38 45 livecheck.url https://github.com/openconnect/openconnect-gui/releases -
new file files/patch-CMakeLists_txt.diff
diff --git files/patch-CMakeLists_txt.diff files/patch-CMakeLists_txt.diff new file mode 100644 index 0000000..d18599d
- + 1 --- CMakeLists.txt.orig 2016-10-05 18:39:23.000000000 +0200 2 +++ CMakeLists.txt 2016-10-05 18:41:33.000000000 +0200 3 @@ -1,4 +1,15 @@ 4 cmake_minimum_required(VERSION 3.5 FATAL_ERROR) 5 + 6 +if(APPLE) 7 + if(NOT CMAKE_OSX_SYSROOT) 8 + set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" CACHE STRING "" FORCE) 9 + endif() 10 + 11 + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) 12 + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE) 13 + endif() 14 +endif() 15 + 16 project(openconnect-gui 17 VERSION 1.4.1 18 LANGUAGES CXX 19 @@ -18,7 +29,7 @@ if(WIN32 AND MINGW) 20 21 set(DEFAULT_VPNC_SCRIPT "vpnc-script.js") 22 else(APPLE) 23 - set(DEFAULT_VPNC_SCRIPT "../Resources/vpnc-script") 24 + set(DEFAULT_VPNC_SCRIPT "@PREFIX@/etc/vpnc-scripts/vpnc-script") 25 else() 26 set(DEFAULT_VPNC_SCRIPT "/etc/vpnc/vpnc-script") 27 endif() 28 @@ -48,6 +59,9 @@ find_package(Qt5 5.6 REQUIRED COMPONENTS 29 if(WIN32 AND MINGW) 30 get_target_property(_qwindows_dll Qt5::QWindowsIntegrationPlugin LOCATION) 31 endif() 32 +if(APPLE) 33 + get_target_property(_qcocoa_dylib Qt5::QCocoaIntegrationPlugin LOCATION) 34 +endif() 35 36 include(clang-format) 37 38 @@ -66,6 +80,17 @@ else() 39 find_package(OpenConnect REQUIRED) 40 link_directories(${OPENCONNECT_LIBRARY_DIRS}) 41 include_directories(SYSTEM ${OPENCONNECT_INCLUDE_DIRS}) 42 + 43 + find_library(SECURITY_LIBRARY Security REQUIRED) 44 + if(SECURITY_LIBRARY) 45 + message(STATUS "Framework 'Security' found at ${SECURITY_LIBRARY}") 46 + 47 + link_directories(${SECURITY_LIBRARY_DIRS}) 48 + include_directories(SYSTEM ${SECURITY_LIBRARY_INCLUDE_DIRS}) 49 + else() 50 + message(FATAL_ERROR "Framework 'Security' not found!") 51 + endif() 52 + mark_as_advanced(SECURITY_LIBRARY) 53 endif() 54 55 add_subdirectory(src) -
new file files/patch-bundle_qt_conf.diff
diff --git files/patch-bundle_qt_conf.diff files/patch-bundle_qt_conf.diff new file mode 100644 index 0000000..a9f7547
- + 1 --- /dev/null 2 +++ bundle/qt.conf 3 @@ -0,0 +1,2 @@ 4 +[Paths] 5 +Plugins = PlugIns -
deleted file files/patch-common_h.diff
diff --git files/patch-common_h.diff files/patch-common_h.diff deleted file mode 100644 index e830704..0000000
+ - 1 --- common.h.orig 2016-07-12 20:00:11.000000000 +02002 +++ common.h 2016-07-12 19:58:32.000000000 +02003 @@ -25,7 +25,7 @@4 5 #define VERSION "1.3"6 #define APP_NAME "openconnect-gui"7 -#define APP_STRING APP_NAME" "VERSION8 +#define APP_STRING APP_NAME " " VERSION9 10 #define toAscii toLatin111 12 @@ -54,7 +54,7 @@13 #include <fcntl.h>14 #include <errno.h>15 #define ms_sleep(x) usleep(1000*x)16 -#define DEFAULT_VPNC_SCRIPT "/etc/vpnc/vpnc-script"17 +#define DEFAULT_VPNC_SCRIPT "@PREFIX@/etc/vpnc-scripts/vpnc-script"18 #define INVALID_SOCKET -119 #define SOCKET int20 #define closesocket close -
new file files/patch-src_CMakeLists_txt.diff
diff --git files/patch-src_CMakeLists_txt.diff files/patch-src_CMakeLists_txt.diff new file mode 100644 index 0000000..ab8cd67
- + 1 --- src/CMakeLists.txt 2 +++ src/CMakeLists.txt 3 @@ -96,8 +96,8 @@ if(APPLE) 4 MACOSX_BUNDLE_GUI_IDENTIFIER "io.github.openconnect.openconnect-gui" 5 MACOSX_BUNDLE_ICON_FILE "mono_lock.icns" 6 MACOSX_BUNDLE_INFO_STRING ${PRODUCT_NAME_LONG} 7 - MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION} 8 - MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" 9 +# MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION} 10 +# MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" 11 ) 12 endif() 13 14 @@ -129,6 +129,11 @@ if(UNIX) 15 ${OPENCONNECT_LIBRARIES} 16 ${GNUTLS_LIBRARY} 17 ) 18 + if(APPLE) 19 + target_link_libraries (${PROJECT_NAME} 20 + ${SECURITY_LIBRARY} 21 + ) 22 + endif() 23 endif() 24 25 # install executable 26 @@ -139,9 +144,11 @@ install(TARGETS ${PROJECT_NAME} 27 ) 28 29 # fixup the bundle 30 -#get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION) 31 -#get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) 32 -#get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) 33 +get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION) 34 +get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) 35 +get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) 36 +list(APPEND libSearchDirs ${QT_LIBRARY_DIR}) 37 + 38 if(WIN32 AND MINGW) 39 set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.exe") 40 list(APPEND libSearchDirs ${CMAKE_SOURCE_DIR}/nsis) 41 @@ -157,13 +164,34 @@ if(WIN32 AND MINGW) 42 DESTINATION . 43 COMPONENT App 44 ) 45 -else() 46 + 47 + set(additionalLib ${_qwindows_dll}) 48 +elseif(APPLE) 49 set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app") 50 list(APPEND libSearchDirs "") 51 + 52 + # Qt Platform Plugin 53 + install(FILES 54 + ${_qcocoa_dylib} 55 + DESTINATION ${PROJECT_NAME}.app/Contents/PlugIns/platforms 56 + COMPONENT App 57 + ) 58 + install(FILES 59 + ${CMAKE_SOURCE_DIR}/bundle/qt.conf 60 + DESTINATION ${PROJECT_NAME}.app/Contents/Resources 61 + COMPONENT App 62 + ) 63 + 64 + set(additionalLib \${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/PlugIns/platforms/libqcocoa.dylib) 65 +else() 66 + message(FATAL_ERROR "XXX: only mingw and apple build supported yet") 67 endif() 68 -set(additionalLib ${_qwindows_dll}) 69 + 70 install(CODE " 71 include(BundleUtilities) 72 + if(APPLE) 73 + set(BU_CHMOD_BUNDLE_ITEMS on) 74 + endif() 75 fixup_bundle(\"${APPS}\" \"${additionalLib}\" \"${libSearchDirs}\") 76 " DESTINATION . COMPONENT App 77 ) -
new file files/patch-src_dialog_editdialog_ui.diff
diff --git files/patch-src_dialog_editdialog_ui.diff files/patch-src_dialog_editdialog_ui.diff new file mode 100644 index 0000000..d814125
- + 1 --- src/dialog/editdialog.ui 2 +++ src/dialog/editdialog.ui 3 @@ -16,6 +16,9 @@ 4 <layout class="QVBoxLayout" name="verticalLayout"> 5 <item> 6 <layout class="QFormLayout" name="settingsProfileLayout"> 7 + <property name="fieldGrowthPolicy"> 8 + <enum>QFormLayout::ExpandingFieldsGrow</enum> 9 + </property> 10 <item row="0" column="0"> 11 <widget class="QLabel" name="nameLabel"> 12 <property name="text"> 13 @@ -278,6 +281,9 @@ 14 <layout class="QVBoxLayout" name="verticalLayout_2"> 15 <item> 16 <layout class="QFormLayout" name="formLayout_2"> 17 + <property name="fieldGrowthPolicy"> 18 + <enum>QFormLayout::ExpandingFieldsGrow</enum> 19 + </property> 20 <item row="1" column="0"> 21 <widget class="QLabel" name="userCertificateLabel"> 22 <property name="text"> 23 @@ -409,6 +415,9 @@ 24 <layout class="QVBoxLayout" name="verticalLayout_3"> 25 <item> 26 <layout class="QFormLayout" name="formLayout_3"> 27 + <property name="fieldGrowthPolicy"> 28 + <enum>QFormLayout::ExpandingFieldsGrow</enum> 29 + </property> 30 <item row="0" column="0"> 31 <widget class="QLabel" name="reconnectTimeoutLabel"> 32 <property name="text"> -
new file files/patch-src_dialog_mainwindow_ui.diff
diff --git files/patch-src_dialog_mainwindow_ui.diff files/patch-src_dialog_mainwindow_ui.diff new file mode 100644 index 0000000..68c4e19
- + 1 --- src/dialog/mainwindow.ui 2 +++ src/dialog/mainwindow.ui 3 @@ -171,21 +171,21 @@ 4 <layout class="QVBoxLayout" name="verticalLayout_3"> 5 <item> 6 <layout class="QFormLayout" name="formLayout"> 7 + <property name="fieldGrowthPolicy"> 8 + <enum>QFormLayout::ExpandingFieldsGrow</enum> 9 + </property> 10 + <property name="formAlignment"> 11 + <set>Qt::AlignJustify|Qt::AlignTop</set> 12 + </property> 13 <item row="0" column="0"> 14 <widget class="QLabel" name="ipV4LabelText"> 15 <property name="text"> 16 <string>IPv4:</string> 17 </property> 18 - <property name="alignment"> 19 - <set>Qt::AlignCenter</set> 20 - </property> 21 </widget> 22 </item> 23 <item row="0" column="1"> 24 <widget class="QLabel" name="ipV4Label"> 25 - <property name="text"> 26 - <string/> 27 - </property> 28 <property name="alignment"> 29 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 30 </property> 31 @@ -206,9 +206,6 @@ 32 </item> 33 <item row="1" column="1"> 34 <widget class="QLabel" name="ipV6Label"> 35 - <property name="text"> 36 - <string/> 37 - </property> 38 <property name="alignment"> 39 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 40 </property> 41 @@ -225,16 +222,10 @@ 42 <property name="text"> 43 <string>DNS:</string> 44 </property> 45 - <property name="alignment"> 46 - <set>Qt::AlignCenter</set> 47 - </property> 48 </widget> 49 </item> 50 <item row="2" column="1"> 51 <widget class="QLabel" name="dnsLabel"> 52 - <property name="text"> 53 - <string/> 54 - </property> 55 <property name="alignment"> 56 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 57 </property> 58 @@ -255,9 +246,6 @@ 59 </item> 60 <item row="3" column="1"> 61 <widget class="QLabel" name="cipherCSTPLabel"> 62 - <property name="text"> 63 - <string/> 64 - </property> 65 <property name="alignment"> 66 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 67 </property> 68 @@ -272,40 +260,27 @@ 69 </item> 70 <item row="4" column="1"> 71 <widget class="QLabel" name="cipherDTLSLabel"> 72 - <property name="text"> 73 - <string/> 74 - </property> 75 <property name="alignment"> 76 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 77 </property> 78 </widget> 79 </item> 80 - </layout> 81 - </item> 82 - <item> 83 - <widget class="Line" name="line"> 84 - <property name="orientation"> 85 - <enum>Qt::Horizontal</enum> 86 - </property> 87 - </widget> 88 - </item> 89 - <item> 90 - <layout class="QFormLayout" name="formLayout_2"> 91 - <item row="0" column="0"> 92 - <widget class="QLabel" name="uploadLaberText"> 93 + <item row="5" column="0"> 94 + <widget class="QLabel" name="downloadLabelText"> 95 <property name="text"> 96 - <string>Upload:</string> 97 - </property> 98 - <property name="alignment"> 99 - <set>Qt::AlignCenter</set> 100 + <string>Download:</string> 101 </property> 102 </widget> 103 </item> 104 - <item row="0" column="1"> 105 - <widget class="QLabel" name="uploadLabel"> 106 + <item row="6" column="0"> 107 + <widget class="QLabel" name="uploadLaberText"> 108 <property name="text"> 109 - <string/> 110 + <string>Upload:</string> 111 </property> 112 + </widget> 113 + </item> 114 + <item row="5" column="1"> 115 + <widget class="QLabel" name="downloadLabel"> 116 <property name="alignment"> 117 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 118 </property> 119 @@ -317,21 +292,8 @@ 120 </property> 121 </widget> 122 </item> 123 - <item row="1" column="0"> 124 - <widget class="QLabel" name="downloadLabelText"> 125 - <property name="text"> 126 - <string>Download:</string> 127 - </property> 128 - <property name="alignment"> 129 - <set>Qt::AlignCenter</set> 130 - </property> 131 - </widget> 132 - </item> 133 - <item row="1" column="1"> 134 - <widget class="QLabel" name="downloadLabel"> 135 - <property name="text"> 136 - <string/> 137 - </property> 138 + <item row="6" column="1"> 139 + <widget class="QLabel" name="uploadLabel"> 140 <property name="alignment"> 141 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> 142 </property> -
new file files/patch-src_main_cpp.diff
diff --git files/patch-src_main_cpp.diff files/patch-src_main_cpp.diff new file mode 100644 index 0000000..e07abf0
- + 1 --- src/main.cpp 2 +++ src/main.cpp 3 @@ -37,10 +37,14 @@ extern "C" { 4 #include <QSettings> 5 #endif 6 7 +#ifdef __MACH__ 8 +#include <mach-o/dyld.h> 9 +#include <Security/Security.h> 10 +#endif 11 + 12 #include <csignal> 13 #include <cstdio> 14 15 -#ifdef PROJ_GNUTLS_DEBUG 16 static QStringList* logger = nullptr; 17 18 static void log_func(int level, const char* str) 19 @@ -50,6 +54,42 @@ static void log_func(int level, const char* str) 20 logger->append(s.trimmed()); 21 } 22 } 23 + 24 +#ifdef __MACH__ 25 +bool relaunch_as_root() 26 +{ 27 + QMessageBox msgBox; 28 + char appPath[2048]; 29 + uint32_t size = sizeof(appPath); 30 + AuthorizationRef authRef; 31 + OSStatus status; 32 + 33 + /* Get the path of the current program */ 34 + if (_NSGetExecutablePath(appPath, &size) != 0) { 35 + msgBox.setText(QObject::tr 36 + ("Could not get program path to elevate privileges.")); 37 + return false; 38 + } 39 + 40 + status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, 41 + kAuthorizationFlagDefaults, &authRef); 42 + 43 + if (status != errAuthorizationSuccess) { 44 + msgBox.setText(QObject::tr 45 + ("Failed to create authorization reference.")); 46 + return false; 47 + } 48 + status = AuthorizationExecuteWithPrivileges(authRef, appPath, 49 + kAuthorizationFlagDefaults, NULL, NULL); 50 + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); 51 + 52 + if (status == errAuthorizationSuccess) { 53 + /* We've successfully re-launched with root privs. */ 54 + return true; 55 + } 56 + 57 + return false; 58 +} 59 #endif 60 61 int pin_callback(void* userdata, int attempt, const char* token_url, 62 @@ -89,6 +129,10 @@ int main(int argc, char* argv[]) 63 QSettings::setDefaultFormat(QSettings::IniFormat); 64 #endif 65 66 +#ifdef __MACH__ 67 + /* Re-launching with root privs on OS X needs Qt to allow setsuid */ 68 + QApplication::setSetuidAllowed(true); 69 +#endif 70 QApplication app(argc, argv); 71 app.setQuitOnLastWindowClosed(false); 72 app.setApplicationName(appDescription); 73 @@ -97,10 +141,14 @@ int main(int argc, char* argv[]) 74 app.setOrganizationName(appOrganizationName); 75 app.setOrganizationDomain(appOrganizationDomain); 76 77 -#if !defined(_WIN32) && !defined(PROJ_GNUTLS_DEBUG) 78 - if (getuid() != 0) { 79 - QMessageBox msgBox; 80 +#ifdef __MACH__ 81 + if (geteuid() != 0) { 82 + if (relaunch_as_root()) { 83 + /* We have re-launched with root privs. Exit this process. */ 84 + return 0; 85 + } 86 87 + QMessageBox msgBox; 88 msgBox.setText(QObject::tr("This program requires root privileges to fully function.")); 89 msgBox.setInformativeText(QObject::tr("VPN connection establishment would fail.")); 90 msgBox.exec(); 91 @@ -118,10 +166,10 @@ int main(int argc, char* argv[]) 92 gnutls_pkcs11_set_pin_function(pin_callback, &mainWindow); 93 #endif 94 95 -#ifdef PROJ_GNUTLS_DEBUG 96 gnutls_global_set_log_function(log_func); 97 - gnutls_global_set_log_level(3); 98 logger = mainWindow.get_log(); 99 +#ifdef PROJ_GNUTLS_DEBUG 100 + gnutls_global_set_log_level(3); 101 log_func(1, "started logging"); 102 #endif 103 -
new file files/patch-src_vpninfo_cpp.diff
diff --git files/patch-src_vpninfo_cpp.diff files/patch-src_vpninfo_cpp.diff new file mode 100644 index 0000000..d09ce0f
- + 1 --- src/vpninfo.cpp 2 +++ src/vpninfo.cpp 3 @@ -423,7 +423,7 @@ int VpnInfo::connect() 4 5 #ifdef Q_OS_WIN32 6 const QString osName{"win"}; 7 -#elif Q_OS_OSX 8 +#elif defined Q_OS_OSX 9 const QString osName{"mac-intel"}; 10 #elif defined Q_OS_LINUX 11 const QString osName = QString("linux%1").arg(QSysInfo::buildCpuArchitecture() == "i386" ? "" : "-64").toStdString().c_str(); -
new file files/patch-src_vpninfo_h.diff
diff --git files/patch-src_vpninfo_h.diff files/patch-src_vpninfo_h.diff new file mode 100644 index 0000000..867003e
- + 1 --- src/vpninfo.h 2 +++ src/vpninfo.h 3 @@ -22,6 +22,8 @@ 4 #include <QString> 5 #ifdef _WIN32 6 #include <winsock2.h> 7 +#else 8 +#include "common.h" 9 #endif 10 #ifdef __linux__ 11 #define SOCKET int