From 42e29babd62de83bf8fbc0f9d340cfcf87d28f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Wed, 11 Jan 2023 19:18:47 +0100 Subject: [PATCH] feat(config): Allow loading extra config from file --- SoObjects/SOGo/SOGoSystemDefaults.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index fbd18c7db7..e93e0c725e 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -25,6 +25,7 @@ #import #import #import +#import #import @@ -113,9 +114,10 @@ + (void) prepareUserDefaults * enforce the following order of precedence. * First match wins * 1. Command line arguments - * 2. .GNUstepDefaults - * 3. /etc/sogo/{debconf,sogo}.conf - * 4. SOGoDefaults.plist + * 2. File from $SOGO_EXTRA_CONFIG_FILE + * 3. .GNUstepDefaults + * 4. /etc/sogo/{debconf,sogo}.conf + * 5. SOGoDefaults.plist * * The default standardUserDefaults search list is as follows: * GSPrimaryDomain @@ -143,7 +145,7 @@ + (void) prepareUserDefaults NSBundle *bundle; NSString *confFiles[] = {@"/etc/sogo/debconf.conf", @"/etc/sogo/sogo.conf"}; - NSString *filename, *redirectURL; + NSString *filename, *redirectURL, *envFile; NSUInteger count; logger = [SOGoStartupLogger sharedLogger]; @@ -163,6 +165,12 @@ + (void) prepareUserDefaults for (count = 0; count < sizeof(confFiles)/sizeof(confFiles[0]); count++) _injectConfigurationFromFile (configFromFiles, confFiles[count], logger); + /* Fill/Override configuration with configuration stored in the extra + * config file */ + envFile = [[[NSProcessInfo processInfo] environment] objectForKey:@"SOGO_EXTRA_CONFIG_FILE"]; + if (envFile) + _injectConfigurationFromFile (configFromFiles, envFile, logger); + /* This dance is required to let other appplications (sogo-tool) use * options from the sogod domain while preserving the order of precedence * - remove the 'sogod' domain from the user defaults search list