02111-1307, USA.
*/
+#import <unistd.h>
+
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSTimeZone.h>
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;
}
- (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;
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
NSArray *creds;
password = nil;
- auth = [[context request] headerForKey:@"authorization"];
+ auth = [[context request] headerForKey: @"authorization"];
if (auth)
{
creds = [self parseCredentials: auth];
- (SOGoUser *) userInContext: (WOContext *)_ctx
{
- static SOGoUser *anonymous = nil, *freebusy;
+ static SOGoUser *anonymous = nil;
SOGoUser *user;
NSArray *traversalPath;
NSString *login;
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)
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
{
static NSString *fallbackIMAP4Server = nil;
static NSString *defaultLanguage = nil;
static NSURL *AgenorProfileURL = nil;
+static BOOL acceptAnyUser = NO;
NSString *SOGoWeekStartHideWeekNumbers = @"HideWeekNumbers";
NSString *SOGoWeekStartJanuary1 = @"January1";
if (!defaultLanguage)
ASSIGN (defaultLanguage, @"English");
}
+
+ acceptAnyUser = (![ud stringForKey: @"AuthentificationMethod"]);
}
+ (SOGoUser *) userWithLogin: (NSString *) newLogin
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;