]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1088 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 27 Jun 2007 17:41:36 +0000 (17:41 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 27 Jun 2007 17:41:36 +0000 (17:41 +0000)
Main/sogod.m
SoObjects/SOGo/SOGoAuthenticator.m
SoObjects/SOGo/SOGoUser.m

index 821bb1dbe6b23e268f48a610c74e84c5e78ae129..3dfb7920c174c6f91e5b94a7ce6a6bc4754ca098 100644 (file)
@@ -19,6 +19,8 @@
   02111-1307, USA.
 */
 
+#import <unistd.h>
+
 #import <Foundation/NSUserDefaults.h>
 #import <Foundation/NSTimeZone.h>
 
@@ -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;
 }
index 0c8d5c0a8b950bbe169a13d09714e71d50e3e10a..fa9a0526de7abc588db9c43d0db3a36d3a6644e6 100644 (file)
 
 - (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];
 
 - (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
        {
index a79694b9e539e9d6ff54aed9ba6ff3db6a240c83..87383f4d866abc02ed3e7500e181b3aed47eee6b 100644 (file)
@@ -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;