Permalink
Browse files

Reapply changes from rolled back commit that are common to master and…

… callback-auth branches

This includes 3a944d7, 770c189, ca864a1
  • Loading branch information...
dmoagx committed Feb 27, 2018
1 parent d9f773e commit 808ae467381bf597c487fb321dbabc3ccb309b67
@@ -1,3 +1,11 @@
This patch is neccesary to remove a linker error when trying to link SPMySQL with libmysqlclient.a.
To apply:
cd mysql-source-root
patch -p1 < this-file
(patch created with `diff -Naur`)
--- mysql-5.5.56-dist/extra/yassl/taocrypt/include/runtime.hpp 2017-04-27 09:12:30.000000000 +0200
+++ mysql-5.5.56/extra/yassl/taocrypt/include/runtime.hpp 2017-05-20 23:27:14.000000000 +0200
@@ -53,8 +53,8 @@
@@ -1,3 +1,12 @@
This patch backports field types that were added after MySQL 5.5,
but are technically still compatible to the old client libs.
To apply:
cd mysql-source-root
patch -p1 < this-file
(patch created with `diff -Naur`)
--- mysql-5.5.56-dist/include/mysql_com.h 2017-04-27 09:12:30.000000000 +0200
+++ mysql-5.5.56/include/mysql_com.h 2017-05-21 01:46:44.000000000 +0200
@@ -349,7 +349,11 @@
@@ -33,6 +33,7 @@
#include <mach/mach_time.h>
#include <pthread.h>
#include <SystemConfiguration/SCNetworkReachability.h>
#import "SPMySQLUtilities.h"
// Thread flag constant
static pthread_key_t mySQLThreadInitFlagKey;
@@ -321,12 +322,11 @@ - (BOOL)isConnected
}
/**
* Returns YES if the MCPConnection is connected to a server via SSL, NO otherwise.
* Returns YES if the SPMySQLConnection is connected to a server via SSL, NO otherwise.
*/
- (BOOL)isConnectedViaSSL
{
if (![self isConnected]) return NO;
return connectedWithSSL;
return ([self isConnected] && connectedWithSSL);
}
/**
@@ -470,14 +470,6 @@ + (NSString *)findSocketPath
const char *__crashreporter_info__ = NULL;
asm(".desc ___crashreporter_info__, 0x10");
static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
{
uint64_t elapsedTime_t = mach_absolute_time() - comparisonTime;
Nanoseconds elapsedTime = AbsoluteToNanoseconds(*(AbsoluteTime *)&(elapsedTime_t));
return (UnsignedWideToUInt64(elapsedTime) / 1000ULL);
}
@implementation SPMySQLConnection (PrivateAPI)
/**
@@ -489,8 +481,8 @@ - (BOOL)_connect
// If a connection is already active in some form, throw an exception
if (state != SPMySQLDisconnected && state != SPMySQLConnectionLostInBackground) {
@synchronized (self) {
uint64_t diff = _elapsedMicroSecondsSinceAbsoluteTime(initialConnectTime);
asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lluµs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
double diff = _elapsedSecondsSinceAbsoluteTime(initialConnectTime);
asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lfs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
__builtin_trap();
}
[NSException raise:NSInternalInconsistencyException format:@"Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).", state];
@@ -1147,7 +1139,10 @@ - (void)_validateThreadSetup
pthread_setspecific(mySQLThreadInitFlagKey, &mySQLThreadFlag);
// Set up the notification handler to deregister it
[[NSNotificationCenter defaultCenter] addObserver:[self class] selector:@selector(_removeThreadVariables:) name:NSThreadWillExitNotification object:[NSThread currentThread]];
[[NSNotificationCenter defaultCenter] addObserver:[self class]
selector:@selector(_removeThreadVariables:)
name:NSThreadWillExitNotification
object:[NSThread currentThread]];
}
/**
@@ -1,5 +1,5 @@
//
// Locking.h
// SPMySQLUtilities.h
// SPMySQLFramework
//
// Created by Rowan Beentje (rowan.beent.je) on February 6, 2012
@@ -47,7 +47,7 @@ CLEAN='NO'
MIN_OS_X_VERSION='10.6'
ARCHITECTURES='-arch i386 -arch x86_64'
CONFIGURE_OPTIONS='-DBUILD_CONFIG=mysql_release -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=bundled -DWITH_MYSQLD_LDFLAGS="-all-static --disable-shared" -DWITHOUT_SERVER=1 -DWITH_ZLIB=system'
CONFIGURE_OPTIONS='-DBUILD_CONFIG=mysql_release -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=bundled -DWITH_MYSQLD_LDFLAGS="-all-static --disable-shared" -DWITHOUT_SERVER=1 -DWITH_ZLIB=system -DWITH_UNIT_TESTS=0'
OUTPUT_DIR='SPMySQLFiles.build'
ESC=`printf '\033'`
@@ -208,6 +208,7 @@
@property (readwrite, assign) NSInteger sshKeyLocationEnabled;
@property (readwrite, retain) NSString *sshKeyLocation;
@property (readwrite, retain) NSString *sshPort;
@property (readwrite, copy, nonatomic) NSString *connectionKeychainID;
@property (readwrite, retain) NSString *connectionKeychainItemName;
@property (readwrite, retain) NSString *connectionKeychainItemAccount;
@property (readwrite, retain) NSString *connectionSSHKeychainItemName;
@@ -221,6 +222,9 @@
@property (readonly, assign) BOOL isConnecting;
@property (readonly, assign) BOOL isEditingConnection;
- (NSString *)keychainPassword;
- (NSString *)keychainPasswordForSSH;
// Connection processes
- (IBAction)initiateConnection:(id)sender;
- (IBAction)cancelConnection:(id)sender;
@@ -168,6 +168,7 @@ @implementation SPConnectionController
@synthesize dbDocument;
#endif
@synthesize connectionKeychainID = connectionKeychainID;
@synthesize connectionKeychainItemName;
@synthesize connectionKeychainItemAccount;
@synthesize connectionSSHKeychainItemName;
@@ -176,6 +177,28 @@ @implementation SPConnectionController
@synthesize isConnecting;
@synthesize isEditingConnection;
- (NSString *)keychainPassword
{
NSString *kcItemName = [self connectionKeychainItemName];
// If no keychain item is available, return an empty password
if (!kcItemName) return nil;
// Otherwise, pull the password from the keychain using the details from this connection
NSString *kcPassword = [keychain getPasswordForName:kcItemName account:[self connectionKeychainItemAccount]];
return kcPassword;
}
- (NSString *)keychainPasswordForSSH
{
if (![self connectionKeychainItemName]) return nil;
// Otherwise, pull the password from the keychain using the details from this connection
NSString *kcSSHPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
return kcSSHPassword;
}
#pragma mark -
#pragma mark Connection processes
@@ -737,7 +760,7 @@ - (void)updateFavoriteSelection:(id)sender
#ifndef SP_CODA
// Clear the keychain referral items as appropriate
if (connectionKeychainID) SPClear(connectionKeychainID);
[self setConnectionKeychainID:nil];
if (connectionKeychainItemName) SPClear(connectionKeychainItemName);
if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount);
if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName);
@@ -804,7 +827,7 @@ - (void)updateFavoriteSelection:(id)sender
}
// Store the selected favorite ID for use with the document on connection
if ([fav objectForKey:SPFavoriteIDKey]) connectionKeychainID = [[[fav objectForKey:SPFavoriteIDKey] stringValue] retain];
if ([fav objectForKey:SPFavoriteIDKey]) [self setConnectionKeychainID:[[fav objectForKey:SPFavoriteIDKey] stringValue]];
// And the same for the SSH password
connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[fav objectForKey:SPFavoriteNameKey] id:[fav objectForKey:SPFavoriteIDKey]] retain];
@@ -2022,7 +2045,10 @@ - (void)initiateMySQLConnection
[connectButton display];
#endif
[NSThread detachNewThreadWithName:SPCtxt(@"SPConnectionController MySQL connection task", dbDocument) target:self selector:@selector(initiateMySQLConnectionInBackground) object:nil];
[NSThread detachNewThreadWithName:SPCtxt(@"SPConnectionController MySQL connection task", dbDocument)
target:self
selector:@selector(initiateMySQLConnectionInBackground)
object:nil];
}
/**
@@ -2372,8 +2398,6 @@ - (void)addConnectionToDocument
for (NSUInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES];
#endif
if (connectionKeychainID) [dbDocument setKeychainID:connectionKeychainID];
// Pass the connection to the table document, allowing it to set
// up the other classes and the rest of the interface.
[dbDocument setConnection:mySQLConnection];
@@ -3167,7 +3191,6 @@ - (id)initWithDocument:(SPDatabaseDocument *)document
#endif
// Keychain references
connectionKeychainID = nil;
connectionKeychainItemName = nil;
connectionKeychainItemAccount = nil;
connectionSSHKeychainItemName = nil;
@@ -3621,7 +3644,7 @@ - (void)dealloc
SPClear(nibObjectsToRelease);
if (connectionKeychainID) SPClear(connectionKeychainID);
[self setConnectionKeychainID:nil];
if (connectionKeychainItemName) SPClear(connectionKeychainItemName);
if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount);
if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName);
@@ -262,8 +262,6 @@
NSMutableArray *runningActivitiesArray;
#endif
NSString *keyChainID;
#ifndef SP_CODA /* ivars */
NSThread *printThread;
@@ -342,7 +340,6 @@
#endif
- (void)setConnection:(SPMySQLConnection *)theConnection;
- (SPMySQLConnection *)getConnection;
- (void)setKeychainID:(NSString *)theID;
// Database methods
- (IBAction)setDatabases:(id)sender;
@@ -451,7 +448,6 @@
- (NSString *)port;
- (NSString *)mySQLVersion;
- (NSString *)user;
- (NSString *)keyChainID;
- (NSString *)connectionID;
#ifndef SP_CODA /* method decls */
- (NSString *)tabTitleForTooltip;
@@ -218,8 +218,6 @@ - (id)init
alterDatabaseCharsetHelper = nil; //init in awakeFromNib
addDatabaseCharsetHelper = nil;
keyChainID = nil;
#ifndef SP_CODA /* init ivars */
statusValues = nil;
printThread = nil;
@@ -613,14 +611,6 @@ - (SPMySQLConnection *)getConnection
return mySQLConnection;
}
/**
* Sets this connection's Keychain ID.
*/
- (void)setKeychainID:(NSString *)theId
{
keyChainID = [[NSString stringWithString:theId] retain];
}
#pragma mark -
#pragma mark Database methods
@@ -2863,11 +2853,6 @@ - (NSString *)port
return thePort;
}
- (NSString *)keyChainID
{
return keyChainID;
}
- (BOOL)isSaveInBundle
{
return _isSavedInBundle;
@@ -4674,7 +4659,8 @@ - (NSDictionary *) stateIncludingDetails:(NSDictionary *)detailsToReturn
}
[connection setObject:connectionType forKey:@"type"];
if ([[self keyChainID] length]) [connection setObject:[self keyChainID] forKey:@"kcid"];
NSString *kcid = [connectionController connectionKeychainID];
if ([kcid length]) [connection setObject:kcid forKey:@"kcid"];
[connection setObject:[self name] forKey:@"name"];
[connection setObject:[self host] forKey:@"host"];
[connection setObject:[self user] forKey:@"user"];
@@ -4686,7 +4672,7 @@ - (NSDictionary *) stateIncludingDetails:(NSDictionary *)detailsToReturn
[connection setObject:[self database] forKey:@"database"];
if (includePasswords) {
NSString *pw = [self keychainPasswordForConnection:nil];
NSString *pw = [connectionController keychainPassword];
if (!pw) pw = [connectionController password];
if (pw) [connection setObject:pw forKey:@"password"];
@@ -4875,19 +4861,19 @@ - (BOOL)setState:(NSDictionary *)stateDetails fromFile:(BOOL)spfBased
[connectionController setSslCACertFileLocation:[connection objectForKey:@"sslCACertFileLocation"]];
// Set the keychain details if available
if ([connection objectForKey:@"kcid"] && [(NSString *)[connection objectForKey:@"kcid"] length]) {
[self setKeychainID:[connection objectForKey:@"kcid"]];
[connectionController setConnectionKeychainItemName:[keychain nameForFavoriteName:[connectionController name] id:[self keyChainID]]];
NSString *kcid = (NSString *)[connection objectForKey:@"kcid"];
if ([kcid length]) {
[connectionController setConnectionKeychainID:kcid];
[connectionController setConnectionKeychainItemName:[keychain nameForFavoriteName:[connectionController name] id:kcid]];
[connectionController setConnectionKeychainItemAccount:[keychain accountForUser:[connectionController user] host:[connectionController host] database:[connection objectForKey:@"database"]]];
}
// Set password - if not in SPF file try to get it via the KeyChain
if ([connection objectForKey:@"password"])
[connectionController setPassword:[connection objectForKey:@"password"]];
else {
NSString *pw = [self keychainPasswordForConnection:nil];
if (pw)
[connectionController setPassword:pw];
NSString *pw = [connectionController keychainPassword];
if (pw) [connectionController setPassword:pw];
}
// Set the socket details, whether or not the type is a socket
@@ -4910,8 +4896,8 @@ - (BOOL)setState:(NSDictionary *)stateDetails fromFile:(BOOL)spfBased
if ([connection objectForKey:@"ssh_password"])
[connectionController setSshPassword:[connection objectForKey:@"ssh_password"]];
else {
if ([connection objectForKey:@"kcid"] && [(NSString *)[connection objectForKey:@"kcid"] length]) {
[connectionController setConnectionSSHKeychainItemName:[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]]];
if ([kcid length]) {
[connectionController setConnectionSSHKeychainItemName:[keychain nameForSSHForFavoriteName:[connectionController name] id:kcid]];
[connectionController setConnectionSSHKeychainItemAccount:[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]]];
}
NSString *sshpw = [self keychainPasswordForSSHConnection:nil];
@@ -7152,17 +7138,7 @@ - (void)queryGaveError:(NSString *)error connection:(id)connection
*/
- (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection
{
// If no keychain item is available, return an empty password
if (![connectionController connectionKeychainItemName]) return nil;
// Otherwise, pull the password from the keychain using the details from this connection
SPKeychain *keychain = [[SPKeychain alloc] init];
NSString *password = [keychain getPasswordForName:[connectionController connectionKeychainItemName] account:[connectionController connectionKeychainItemAccount]];
[keychain release];
return password;
return [connectionController keychainPassword];
}
/**
@@ -7173,25 +7149,10 @@ - (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection
- (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection
{
// If no keychain item is available, return an empty password
if (![connectionController connectionKeychainItemName]) return @"";
// Otherwise, pull the password from the keychain using the details from this connection
SPKeychain *keychain = [[SPKeychain alloc] init];
NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain];
NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain];
NSString *sshPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
NSString *password = [connectionController keychainPasswordForSSH];
if (!password) return @"";
if (!sshPassword || ![sshPassword length]) {
sshPassword = @"";
}
if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release];
[keychain release];
return sshPassword;
return password;
}
/**
@@ -7754,7 +7715,6 @@ - (void)dealloc
if (spfPreferences) SPClear(spfPreferences);
if (spfSession) SPClear(spfSession);
if (spfDocData) SPClear(spfDocData);
if (keyChainID) SPClear(keyChainID);
if (mainToolbar) SPClear(mainToolbar);
if (titleAccessoryView) SPClear(titleAccessoryView);
if (taskProgressWindow) SPClear(taskProgressWindow);
Oops, something went wrong.

0 comments on commit 808ae46

Please sign in to comment.