From: helge Date: Thu, 4 May 2006 01:24:29 +0000 (+0000) Subject: Added an option to ignore hostname checks for WebDAV moves. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=217c50c2ed2a0d8b91b499a7fba85531a26ea7ac;p=sope Added an option to ignore hostname checks for WebDAV moves. Improved HTTP logging. git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1260 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index d945385a..4a5399fc 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,15 @@ +2006-05-04 Helge Hess + + * v4.5.230 + + * WebDAV/SoObjectWebDAVDispatcher.m: added default + 'SoWebDAVDisableCrossHostMoveCheck' to disable the check for the + hostname on WebDAV MOVE/COPY operations. This can give issues when + Apache is accessed with different DNS names or IPs. + + * WOHttpAdaptor/WOHttpTransaction.m: log HTTP request size after + response size + 2006-05-01 Helge Hess * v4.5.229 diff --git a/sope-appserver/NGObjWeb/Defaults.plist b/sope-appserver/NGObjWeb/Defaults.plist index 7e5f05cc..7b844c99 100644 --- a/sope-appserver/NGObjWeb/Defaults.plist +++ b/sope-appserver/NGObjWeb/Defaults.plist @@ -212,7 +212,9 @@ ); SoWebDAVFormatOutput = NO; DAVParserDebugProp = NO; - + + SoWebDAVDisableCrossHostMoveCheck = NO; + SoWebDAVDefaultAllowMethods = ( GET, HEAD, POST, OPTIONS, MKCOL, DELETE, PUT, LOCK, UNLOCK, COPY, MOVE diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index dc86cd93..65af81b9 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=229 +SUBMINOR_VERSION:=230 # v4.5.214 requires libNGExtensions v4.5.179 # v4.5.122 requires libNGExtensions v4.5.153 diff --git a/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m b/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m index f2a1530d..dbb44661 100644 --- a/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m +++ b/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m @@ -151,8 +151,7 @@ static NGLogger *transActionLogger = nil; if (self->woResponse == nil) return; - [self logResponse:self->woResponse - toRequest:self->woRequest + [self logResponse:self->woResponse toRequest:self->woRequest connection:self->socket]; if (perfLogger) { @@ -402,7 +401,7 @@ static int logCounter = 0; rt < 0.0 ? -1.0 : rt]; } - if (self->woResponse) { + if (self->woResponse != nil) { [self deliverResponse:self->woResponse toRequest:self->woRequest onStream:self->io]; @@ -414,7 +413,7 @@ static int logCounter = 0; rt < 0.0 ? -1.0 : rt]; } } - else if (self->woRequest) { + else if (self->woRequest != nil) { [self errorWithFormat:@"got no response for request %@ ..", self->woRequest]; @@ -720,7 +719,7 @@ static int logCounter = 0; rlen = strlen((const char *)r); if ((slen + rlen + 8) < 1000) { [t1 getCString:(char *)buf]; - sprintf((char *)&(buf[slen]), " %i %s\r\n", s, r); + snprintf((char *)&(buf[slen]), sizeof(buf), " %i %s\r\n", s, r); isok = [_out safeWriteBytes:buf count:strlen((char *)buf)]; } else @@ -735,7 +734,7 @@ static int logCounter = 0; /* add content length header */ - sprintf((char *)buf, "%d", [body length]); + snprintf((char *)buf, sizeof(buf), "%d", [body length]); t1 = [[NSString alloc] initWithCString:(char *)buf]; [_response setHeader:t1 forKey:@"content-length"]; [t1 release]; t1 = nil; @@ -879,6 +878,7 @@ static __inline__ const char *monthAbbr(int m) { Profiling: this method takes 0.95% of -run if the output is piped to /dev/null on OSX, morphing caldate to string is 0.79% of that. */ + static BOOL doExtLog = YES; NSString *remoteHost; NSNumber *zippedLen; NSCalendarDate *now; @@ -928,11 +928,14 @@ static __inline__ const char *monthAbbr(int m) { [buf appendString:@" "]; [buf appendString:[_request httpVersion]]; [buf appendString:@"\" "]; - [buf appendFormat:@"%i", [_response status]]; - [buf appendFormat:@" %i", [[_response content] length]]; - + [buf appendFormat:@"%i %i", + [_response status], + [[_response content] length]]; + if (doExtLog) + [buf appendFormat:@"/%i", [[_request content] length]]; + /* append duration */ - if (lstartDate) + if (lstartDate != nil) [buf appendFormat:@" %.3f", [now timeIntervalSinceDate:lstartDate]]; else [buf appendString:@" -"]; diff --git a/sope-appserver/NGObjWeb/WOHttpAdaptor/WORecordRequestStream.m b/sope-appserver/NGObjWeb/WOHttpAdaptor/WORecordRequestStream.m index eb466e67..db1cb1d2 100644 --- a/sope-appserver/NGObjWeb/WOHttpAdaptor/WORecordRequestStream.m +++ b/sope-appserver/NGObjWeb/WOHttpAdaptor/WORecordRequestStream.m @@ -28,7 +28,7 @@ @implementation WORecordRequestStream - (id)initWithSource:(id)_source { - if ((self = [super initWithSource:_source])) { + if ((self = [super initWithSource:_source]) != nil) { self->readLog = [[NSMutableData alloc] initWithCapacity:ReadLogInitSize]; self->writeLog = [[NSMutableData alloc] initWithCapacity:WriteLogInitSize]; } diff --git a/sope-appserver/NGObjWeb/WOStatisticsStore.m b/sope-appserver/NGObjWeb/WOStatisticsStore.m index 58b0d62d..b91d9079 100644 --- a/sope-appserver/NGObjWeb/WOStatisticsStore.m +++ b/sope-appserver/NGObjWeb/WOStatisticsStore.m @@ -69,9 +69,9 @@ static BOOL runMultithreaded = NO; if (gmt == nil) gmt = [[NSTimeZone timeZoneWithAbbreviation:@"GMT"] retain]; - + runMultithreaded = [[NSUserDefaults standardUserDefaults] - boolForKey:@"WORunMultithreaded"]; + boolForKey:@"WORunMultithreaded"]; } - (id)init { @@ -99,7 +99,7 @@ static id mkuint(unsigned int i) { return [NSNumberClass numberWithUnsignedInt:i]; } static id mkdbl(double d) { -#if 1 +#if 1 // TODO: why is that? char buf[64]; sprintf(buf, "%.3f", d); return [NSStringClass stringWithCString:buf]; @@ -138,7 +138,7 @@ static id mkdbl(double d) { if (pageStats->totalResponseCount > 0) { [stats setObject: - mkuint(pageStats->totalResponseSize / pageStats->totalResponseCount) + mkuint(pageStats->totalResponseSize/pageStats->totalResponseCount) forKey:@"averageResponseSize"]; [stats setObject: mkdbl(pageStats->totalDuration / pageStats->totalResponseCount) diff --git a/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m b/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m index 53f5eb73..ffb31018 100644 --- a/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m +++ b/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m @@ -49,6 +49,7 @@ static int debugOn = -1; static BOOL debugBulkTarget = NO; +static BOOL disableCrossHostMoveCheck = NO; static NSNumber *yesNum = nil; + (void)initialize { @@ -60,6 +61,9 @@ static NSNumber *yesNum = nil; debugOn = [ud boolForKey:@"SoObjectDAVDispatcherDebugEnabled"] ? 1 : 0; if (debugOn) NSLog(@"Note: WebDAV dispatcher debugging is enabled."); if (yesNum == nil) yesNum = [[NSNumber numberWithBool:YES] retain]; + + disableCrossHostMoveCheck = + [ud boolForKey:@"SoWebDAVDisableCrossHostMoveCheck"]; } // THREAD @@ -696,7 +700,7 @@ static NSTimeZone *gmt = nil; pathInfo, delProps, setProps]; } - if ([pathInfo length] == 0) { + if (![pathInfo isNotEmpty]) { /* edit an object */ NSException *e; @@ -847,30 +851,37 @@ static NSTimeZone *gmt = nil; /* The WebDAV spec is not really clear on what we should return in this case? Let me know if anybody has a suggestion ... + + Note: This is easy to confuse if you don't use the Apache server name + to access Apache (eg just the IP). Which is why we allow to + disable this check. */ [self logWithFormat:@"tried to do a cross server move (%@ vs %@)", [srvURL absoluteString], [destURL absoluteString]]; - return [self httpException:403 /* Forbidden */ - reason:@"MOVE destination is on a different host."]; + if (!disableCrossHostMoveCheck) { + return [self httpException:403 /* Forbidden */ + reason:@"MOVE destination is on a different host."]; + } } - if (path_) { + if (path_ != NULL) { NSMutableArray *ma; unsigned i; /* TODO: hack hack hack */ ma = [[[destURL path] componentsSeparatedByString:@"/"] mutableCopy]; - if ([ma count] > 0) // leading slash ("") + if ([ma isNotEmpty]) // leading slash ("") [ma removeObjectAtIndex:0]; - if ([ma count] > 0) // the appname (eg zidestore) + if ([ma isNotEmpty]) // the appname (eg zidestore) [ma removeObjectAtIndex:0]; - if ([ma count] > 0) // the request handler key (eg so) + if ([ma isNotEmpty]) // the request handler key (eg so) [ma removeObjectAtIndex:0]; /* unescape path components */ for (i = 0; i < [ma count]; i++) { - NSString *s = [ma objectAtIndex:i], *ns; + NSString *s, *ns; + s = [ma objectAtIndex:i]; ns = [s stringByUnescapingURL]; if (ns != s) [ma replaceObjectAtIndex:i withObject:ns];