Merge pull request #2 from LenardHess/feature_configSecrets
Add configuration option to keep secrets out of config
This commit is contained in:
commit
2cb927a60a
1 changed files with 20 additions and 1 deletions
21
ddclient.in
21
ddclient.in
|
|
@ -1614,7 +1614,7 @@ sub _read_config {
|
||||||
$content .= "$_\n" unless /^#/;
|
$content .= "$_\n" unless /^#/;
|
||||||
|
|
||||||
## parsing passwords is special
|
## parsing passwords is special
|
||||||
if (/^([^#]*\s)?([^#]*?password\S*?)\s*=\s*('.*'|[^']\S*)(.*)/) {
|
if (/^([^#]*\s)?([^#]*?password)\s*=\s*('.*'|[^']\S*)(.*)/) {
|
||||||
my ($head, $key, $value, $tail) = ($1 // '', $2, $3, $4);
|
my ($head, $key, $value, $tail) = ($1 // '', $2, $3, $4);
|
||||||
$value = $1 if $value =~ /^'(.*)'$/;
|
$value = $1 if $value =~ /^'(.*)'$/;
|
||||||
$passwords{$key} = $value;
|
$passwords{$key} = $value;
|
||||||
|
|
@ -1645,6 +1645,25 @@ sub _read_config {
|
||||||
|
|
||||||
## verify that keywords are valid...and check the value
|
## verify that keywords are valid...and check the value
|
||||||
foreach my $k (keys %locals) {
|
foreach my $k (keys %locals) {
|
||||||
|
# Handle '_env' keyword suffix
|
||||||
|
if ($k =~ /(.*)_env$/)
|
||||||
|
{
|
||||||
|
debug("Loading value for $1 from environment variable $locals{$k}.");
|
||||||
|
if (exists($ENV{$locals{$k}}))
|
||||||
|
{
|
||||||
|
# Set the value to the value of the environment variable
|
||||||
|
$locals{$1} = $ENV{$locals{$k}};
|
||||||
|
# Remove the '_env' suffix from the key
|
||||||
|
$k = $1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
warning("Environment variable '$locals{$k}' not set for keyword '$k' (ignored)");
|
||||||
|
delete $locals{$k};
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$locals{$k} = $passwords{$k} if defined $passwords{$k};
|
$locals{$k} = $passwords{$k} if defined $passwords{$k};
|
||||||
if (!exists $variables{'merged'}{$k}) {
|
if (!exists $variables{'merged'}{$k}) {
|
||||||
warning("unrecognized keyword '%s' (ignored)", $k);
|
warning("unrecognized keyword '%s' (ignored)", $k);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue