From f955da0ce375943830d01b3ed934d11b2479dc28 Mon Sep 17 00:00:00 2001 From: CaS Date: Thu, 7 Jul 2005 21:11:04 +0000 Subject: [PATCH] Various tweaks git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@21421 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 +++++++++ MySQL.m | 8 ++++---- SQLClient.m | 19 ++++++++++--------- WebServer.h | 5 +++++ WebServer.m | 45 ++++++++++++++++++++++++++++++++++----------- 5 files changed, 62 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78aff54..11ec189 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-07-07 Richard Frith-Macdonald + + * MySQL.m: + * SQLClient.m: + * WebServer.h: + * WebServer.m: + Tweaks to keep gcc-4 happy (signedness issues) and add support for + using separate ssl conmfig for different IP addresses. + 2005-06-21 Richard Frith-Macdonald * SQLClient.m: Expand tilde in paths searched for backend bundles. diff --git a/MySQL.m b/MySQL.m index 1971ffa..567c4c3 100644 --- a/MySQL.m +++ b/MySQL.m @@ -305,7 +305,7 @@ static unsigned int trim(char *str) for (i = 0; i < fieldCount; i++) { - keys[i] = [NSString stringWithUTF8String: fields[i].name]; + keys[i] = [NSString stringWithUTF8String: (char*)fields[i].name]; } records = [[NSMutableArray alloc] initWithCapacity: recordCount]; @@ -320,7 +320,7 @@ static unsigned int trim(char *str) for (j = 0; j < fieldCount; j++) { id v = null; - unsigned char *p = row[j]; + unsigned char *p = (unsigned char*)row[j]; if (p != 0) { @@ -405,8 +405,8 @@ static unsigned int trim(char *str) break; default: - trim(p); - v = [NSString stringWithUTF8String: p]; + trim((char*)p); + v = [NSString stringWithUTF8String: (char*)p]; break; } } diff --git a/SQLClient.m b/SQLClient.m index c9db8a4..c10111f 100644 --- a/SQLClient.m +++ b/SQLClient.m @@ -634,12 +634,13 @@ static unsigned int maxConnections = 8; name: (NSString*)reference { NSNotification *n; - id conf = config; + NSDictionary *conf = config; id existing; if (conf == nil) { - conf = [NSUserDefaults standardUserDefaults]; + // Pretend the defaults object is a dictionary. + conf = (NSDictionary*)[NSUserDefaults standardUserDefaults]; } if ([reference isKindOfClass: NSStringClass] == NO) @@ -1239,7 +1240,7 @@ static void quoteString(NSMutableString *s) */ - (void) _configure: (NSNotification*)n { - id o = [n object]; + NSDictionary *o = [n object]; NSDictionary *d; NSString *s; Class c; @@ -1292,7 +1293,7 @@ static void quoteString(NSMutableString *s) /* Try alternative version with more libraries linked in. * In some systems and situations the dynamic linker needs * to haved the SQLClient, gnustep-base, and objc libraries - * explicityly linked into the bundle, but in others it + * explicitly linked into the bundle, but in others it * requires them to not be linked. To handle that, we create * two versions of each bundle, the seond version has _libs * appended to the bundle name, and has the extra libraries linked. @@ -1456,7 +1457,7 @@ static void quoteString(NSMutableString *s) NSRange s; NSString *v; NSString *alt; - id o; + id o; unsigned i; r.length = l - pos; @@ -1527,7 +1528,7 @@ static void quoteString(NSMutableString *s) if ([k length] > 0) { - o = [o objectForKey: k]; + o = [(NSDictionary*)o objectForKey: k]; } } if (o == vals) @@ -1538,7 +1539,7 @@ static void quoteString(NSMutableString *s) { if ([o isKindOfClass: NSStringClass] == YES) { - v = o; + v = (NSString*)o; } else { @@ -1688,9 +1689,9 @@ static void quoteString(NSMutableString *s) { return [query hash]; } -- (BOOL) isEqual: (SQLClientCacheInfo*)other +- (BOOL) isEqual: (id)other { - return [query isEqual: other->query]; + return [query isEqual: ((SQLClientCacheInfo*)other)->query]; } @end diff --git a/WebServer.h b/WebServer.h index 619d692..4242f1a 100644 --- a/WebServer.h +++ b/WebServer.h @@ -419,6 +419,11 @@ * KeyFile and Password then the server will * use the specified certificate and key files (which it will access * using the password).
+ * The secure dictionary may also contain other dictionaries + * keyed on IP addresses, and if the address that an incoming connection + * arrived on matches the key of a dictionary, that dictionary is used + * to provide the certificate information, with the top-level values + * being used as a fallback.
* This method returns YES on success, NO on failure ... if it returns NO * then the receiver will not be capable of handling incoming * web requests!
diff --git a/WebServer.m b/WebServer.m index 2b331f4..848af5c 100644 --- a/WebServer.m +++ b/WebServer.m @@ -211,7 +211,9 @@ password = [[request headerNamed: @"x-http-password"] value]; if ([access objectForKey: @"Users"] != nil) { - stored = [[access objectForKey: @"Users"] objectForKey: username]; + NSDictionary *users = [access objectForKey: @"Users"]; + + stored = [users objectForKey: username]; } else if ([access objectForKey: @"UserDB"] != nil) { @@ -246,7 +248,7 @@ if (sql == nil) { sql = [c alloc]; - sql = [c initWithConfiguration: nil name: name]; + sql = [sql initWithConfiguration: nil name: name]; } stored = [sql queryString: @"SELECT ", [info objectForKey: @"Password"], @@ -1160,9 +1162,30 @@ escapeData(const unsigned char* bytes, unsigned length, NSMutableData *d) { if (_sslConfig != nil) { - [hdl sslSetCertificate: [_sslConfig objectForKey: @"CertificateFile"] - privateKey: [_sslConfig objectForKey: @"KeyFile"] - PEMpasswd: [_sslConfig objectForKey: @"Password"]]; + NSString *address = [hdl socketLocalAddress]; + NSDictionary *primary = [_sslConfig objectForKey: address]; + NSString *certificateFile; + NSString *keyFile; + NSString *password; + + certificateFile = [primary objectForKey: @"CertificateFile"]; + if (certificateFile == nil) + { + certificateFile = [_sslConfig objectForKey: @"CertificateFile"]; + } + keyFile = [primary objectForKey: @"KeyFile"]; + if (keyFile == nil) + { + keyFile = [_sslConfig objectForKey: @"KeyFile"]; + } + password = [primary objectForKey: @"Password"]; + if (password == nil) + { + password = [_sslConfig objectForKey: @"Password"]; + } + [hdl sslSetCertificate: certificateFile + privateKey: keyFile + PEMpasswd: password]; } if ((h = [NSHost hostWithAddress: a]) == nil) @@ -1363,10 +1386,10 @@ escapeData(const unsigned char* bytes, unsigned length, NSMutableData *d) { bytes[back] = '\0'; end = back + 1; - if (strncmp(bytes + end, "HTTP/", 5) == 0) + if (strncmp((char*)bytes + end, "HTTP/", 5) == 0) { end += 5; - version = [NSString stringWithUTF8String: bytes + end]; + version = [NSString stringWithUTF8String: (char*)bytes + end]; } } if ([version floatValue] < 1.1) @@ -1396,7 +1419,7 @@ escapeData(const unsigned char* bytes, unsigned length, NSMutableData *d) end++; } bytes[end++] = '\0'; - method = [NSString stringWithUTF8String: bytes + start]; + method = [NSString stringWithUTF8String: (char*)bytes + start]; /* * Extract path string. @@ -1417,14 +1440,14 @@ escapeData(const unsigned char* bytes, unsigned length, NSMutableData *d) * Extract query string. */ bytes[end++] = '\0'; - query = [NSString stringWithUTF8String: bytes + end]; + query = [NSString stringWithUTF8String: (char*)bytes + end]; } else { bytes[end] = '\0'; } - path = [NSString stringWithUTF8String: bytes + start]; + path = [NSString stringWithUTF8String: (char*)bytes + start]; if ([method isEqualToString: @"GET"] == NO && [method isEqualToString: @"POST"] == NO) @@ -1673,7 +1696,7 @@ escapeData(const unsigned char* bytes, unsigned length, NSMutableData *d) for (pos = 4; pos < len; pos++) { - if (strncmp(&buf[pos-4], "\r\n\r\n", 4) == 0) + if (strncmp((char*)&buf[pos-4], "\r\n\r\n", 4) == 0) { break; }