02111-1307, USA.
*/
-#include <NGObjWeb/NGObjWeb.h>
-#include "common.h"
+#import <unistd.h>
-int main(int argc, char **argv, char **env) {
+#import <Foundation/NSAutoreleasePool.h>
+#import <Foundation/NSString.h>
+#import <Foundation/NSTimeZone.h>
+#import <Foundation/NSUserDefaults.h>
+
+#import <NGObjWeb/SoApplication.h>
+
+int
+main (int argc, char **argv, char **env)
+{
+ NSString *tzName;
+ NSUserDefaults *ud;
NSAutoreleasePool *pool;
+ int rc;
+
+ pool = [NSAutoreleasePool new];
- pool = [[NSAutoreleasePool alloc] init];
+ rc = -1;
+
+ if (getuid() > 0)
+ {
#if LIB_FOUNDATION_LIBRARY
- [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
+ [NSProcessInfo initializeWithArguments: argv
+ count: argc environment: env];
#endif
- [NGBundleManager defaultBundleManager];
-
- WOWatchDogApplicationMain(@"SOGo", argc, (void*)argv);
+ ud = [NSUserDefaults standardUserDefaults];
+ rc = 0;
+ tzName = [ud stringForKey: @"SOGoServerTimeZone"];
+ if (!tzName)
+ tzName = @"UTC";
+ [NSTimeZone setDefaultTimeZone:
+ [NSTimeZone timeZoneWithName: tzName]];
+ WOWatchDogApplicationMain (@"SOGo", argc, (void *) argv);
+ }
+ else
+ NSLog (@"Don't run SOGo as root!");
[pool release];
- return 0;
+
+ return rc;
}