From: wolfgang Date: Wed, 27 Jun 2007 17:41:36 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1088 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a7b4de605bb2da7a14cba9241e9e2aab5d52745;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1088 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/Main/sogod.m b/Main/sogod.m index 821bb1db..3dfb7920 100644 --- a/Main/sogod.m +++ b/Main/sogod.m @@ -19,6 +19,8 @@ 02111-1307, USA. */ +#import + #import #import @@ -31,21 +33,33 @@ main (int argc, char **argv, char **env) NSString *tzName; NSUserDefaults *ud; NSAutoreleasePool *pool; + int rc; pool = [NSAutoreleasePool new]; + + if (getuid() > 0) + { + rc = 0; #if LIB_FOUNDATION_LIBRARY - [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; #endif - [NGBundleManager defaultBundleManager]; + [NGBundleManager defaultBundleManager]; - ud = [NSUserDefaults standardUserDefaults]; - tzName = [ud stringForKey: @"SOGoServerTimeZone"]; - if (!tzName) - tzName = @"Canada/Eastern"; - [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: tzName]]; + ud = [NSUserDefaults standardUserDefaults]; + tzName = [ud stringForKey: @"SOGoServerTimeZone"]; + if (!tzName) + tzName = @"Canada/Eastern"; + [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: tzName]]; - WOWatchDogApplicationMain (@"SOGo", argc, (void *) argv); + WOWatchDogApplicationMain (@"SOGo", argc, (void *) argv); + } + else + { + NSLog (@"Don't run SOGo as root!"); + rc = -1; + } [pool release]; - return 0; + + return rc; } diff --git a/SoObjects/SOGo/SOGoAuthenticator.m b/SoObjects/SOGo/SOGoAuthenticator.m index 0c8d5c0a..fa9a0526 100644 --- a/SoObjects/SOGo/SOGoAuthenticator.m +++ b/SoObjects/SOGo/SOGoAuthenticator.m @@ -47,13 +47,11 @@ - (id) init { - NSUserDefaults *ud; - if ((self = [super init])) { - ud = [NSUserDefaults standardUserDefaults]; - - authMethod = [[ud stringForKey:@"AuthentificationMethod"] retain]; + authMethod = [[NSUserDefaults standardUserDefaults] + stringForKey: @"AuthentificationMethod"]; + [authMethod retain]; } return self; @@ -79,9 +77,9 @@ else accept = ([_login length] > 0); - return (accept - || ([_login isEqualToString: @"freebusy"] - && [_pwd isEqualToString: @"freebusy"])); + return accept; +// || ([_login isEqualToString: @"freebusy"] +// && [_pwd isEqualToString: @"freebusy"])); } - (NSString *) _passwordInContext: (WOContext *) context @@ -90,7 +88,7 @@ NSArray *creds; password = nil; - auth = [[context request] headerForKey:@"authorization"]; + auth = [[context request] headerForKey: @"authorization"]; if (auth) { creds = [self parseCredentials: auth]; @@ -105,7 +103,7 @@ - (SOGoUser *) userInContext: (WOContext *)_ctx { - static SOGoUser *anonymous = nil, *freebusy; + static SOGoUser *anonymous = nil; SOGoUser *user; NSArray *traversalPath; NSString *login; @@ -114,10 +112,10 @@ anonymous = [[SOGoUser alloc] initWithLogin: @"anonymous" roles: [NSArray arrayWithObject: SoRole_Anonymous]]; - if (!freebusy) - freebusy - = [[SOGoUser alloc] initWithLogin: @"freebusy" - roles: [NSArray arrayWithObject: SOGoRole_FreeBusy]]; +// if (!freebusy) +// freebusy +// = [[SOGoUser alloc] initWithLogin: @"freebusy" +// roles: [NSArray arrayWithObject: SOGoRole_FreeBusy]]; login = [self checkCredentialsInContext:_ctx]; if (login) @@ -125,10 +123,10 @@ if ([login isEqualToString: @"anonymous"]) { traversalPath = [_ctx objectForKey: @"SoRequestTraversalPath"]; - if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"]) - user = freebusy; - else - user = anonymous; +// if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"]) +// user = freebusy; +// else + user = anonymous; } else { diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index a79694b9..87383f4d 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -40,6 +40,7 @@ static NSTimeZone *serverTimeZone = nil; static NSString *fallbackIMAP4Server = nil; static NSString *defaultLanguage = nil; static NSURL *AgenorProfileURL = nil; +static BOOL acceptAnyUser = NO; NSString *SOGoWeekStartHideWeekNumbers = @"HideWeekNumbers"; NSString *SOGoWeekStartJanuary1 = @"January1"; @@ -83,6 +84,8 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; if (!defaultLanguage) ASSIGN (defaultLanguage, @"English"); } + + acceptAnyUser = (![ud stringForKey: @"AuthentificationMethod"]); } + (SOGoUser *) userWithLogin: (NSString *) newLogin @@ -115,17 +118,22 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; roles: (NSArray *) newRoles { LDAPUserManager *um; - NSDictionary *user; + NSString *realUID; if ([newLogin isEqualToString: @"anonymous"] || [newLogin isEqualToString: @"freebusy"]) self = [super initWithLogin: newLogin roles: newRoles]; else { - um = [LDAPUserManager sharedUserManager]; - user = [um contactInfosForUserWithUIDorEmail: newLogin]; - self = [super initWithLogin: [user objectForKey: @"c_uid"] - roles: newRoles]; + if (acceptAnyUser) + realUID = newLogin; + else + { + um = [LDAPUserManager sharedUserManager]; + realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] + objectForKey: @"c_uid"]; + } + self = [super initWithLogin: realUID roles: newRoles]; } return self;