Skip to content

Commit

Permalink
feat(config): Allow loading extra config from file
Browse files Browse the repository at this point in the history
  • Loading branch information
dasJ committed Jan 11, 2023
1 parent 842fa97 commit 42e29ba
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions SoObjects/SOGo/SOGoSystemDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import <Foundation/NSFileManager.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSProcessInfo.h>

#import <NGExtensions/NSObject+Logs.h>

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down

0 comments on commit 42e29ba

Please sign in to comment.