Allow $site_path/secure.config to overlay $site_path/gerrit.config
The secure configuration file can be used to store only passwords, or other data which must be node specific and cannot otherwise be shared. This makes it easier to check gerrit.config into an SCM and track changes on it, without leaking key account information. Bug: issue 325 Change-Id: Iae5fa5ff853d116f2957fffcf3820e63bb830fd5 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -1127,6 +1127,30 @@ If not set, Gerrit generates this as "gerrit@`hostname`", where
|
||||
By default, not set, generating the value at startup.
|
||||
|
||||
|
||||
File `secure.config`
|
||||
--------------------
|
||||
The optional file `'$site_path'/secure.config` overrides (or
|
||||
supplements) the settings supplied by `'$site_path'/gerrit.config`.
|
||||
The file should be readable only by the daemon process and can be
|
||||
used to contain private configuration entries that wouldn't normally
|
||||
be exposed to everyone.
|
||||
|
||||
Sample `secure.config`:
|
||||
----
|
||||
[database]
|
||||
username = webuser
|
||||
password = s3kr3t
|
||||
|
||||
[ldap]
|
||||
password = l3tm3srch
|
||||
|
||||
[httpd]
|
||||
sslKeyPassword = g3rr1t
|
||||
|
||||
[sendemail]
|
||||
smtpPass = sp@m
|
||||
----
|
||||
|
||||
File `replication.config`
|
||||
-------------------------
|
||||
|
||||
|
||||
@@ -41,11 +41,13 @@ class GerritServerConfigProvider implements Provider<Config> {
|
||||
|
||||
@Override
|
||||
public Config get() {
|
||||
final File cfgPath = new File(sitePath, "gerrit.config");
|
||||
final FileBasedConfig cfg = new FileBasedConfig(cfgPath);
|
||||
final File gerrit_config = new File(sitePath, "gerrit.config");
|
||||
final File secure_config = new File(sitePath, "secure.config");
|
||||
|
||||
FileBasedConfig cfg = new FileBasedConfig(gerrit_config);
|
||||
|
||||
if (!cfg.getFile().exists()) {
|
||||
log.info("No " + cfgPath.getAbsolutePath() + "; assuming defaults");
|
||||
log.info("No " + gerrit_config.getAbsolutePath() + "; assuming defaults");
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -57,6 +59,17 @@ class GerritServerConfigProvider implements Provider<Config> {
|
||||
throw new ProvisionException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (secure_config.exists()) {
|
||||
cfg = new FileBasedConfig(cfg, secure_config);
|
||||
try {
|
||||
cfg.load();
|
||||
} catch (IOException e) {
|
||||
throw new ProvisionException(e.getMessage(), e);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ProvisionException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user