diff --git a/Anvil/Tools/Storage.pm b/Anvil/Tools/Storage.pm index 69f241eb..9892da38 100755 --- a/Anvil/Tools/Storage.pm +++ b/Anvil/Tools/Storage.pm @@ -2048,13 +2048,13 @@ sub write_file my $overwrite = defined $parameter->{overwrite} ? $parameter->{overwrite} : 0; my $port = defined $parameter->{port} ? $parameter->{port} : 22; my $password = defined $parameter->{password} ? $parameter->{password} : ""; - my $secure = defined $parameter->{secure} ? $parameter->{secure} : ""; + my $secure = defined $parameter->{secure} ? $parameter->{secure} : 0; my $target = defined $parameter->{target} ? $parameter->{target} : ""; my $user = defined $parameter->{user} ? $parameter->{user} : "root"; my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root"; my $error = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => 0, list => { - body => $body, + body => $secure ? $anvil->Words->string({key => "log_0186"}) : $body, file => $file, group => $group, mode => $mode, diff --git a/tools/anvil-prep-database b/tools/anvil-prep-database index 312ce0ad..eb973508 100755 --- a/tools/anvil-prep-database +++ b/tools/anvil-prep-database @@ -28,7 +28,7 @@ $| = 1; my $anvil = Anvil::Tools->new(); $anvil->Log->level({set => 2}); -$anvil->Log->secure({set => 1}); +$anvil->Log->secure({set => 0}); # Read switches $anvil->Get->switches; @@ -434,7 +434,7 @@ sub add_to_local_config my $host_uuid = $anvil->Get->host_uuid(); my $local_uuid = ""; my $anvil_conf_body = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'anvil.conf'}}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, secure => 1, level => 2, list => { host_uuid => $host_uuid, anvil_conf_body => $anvil_conf_body, }}); @@ -448,7 +448,7 @@ sub add_to_local_config $insert .= "database::".$host_uuid."::port = ".$anvil->data->{database}{$host_uuid}{port}."\n"; $insert .= "database::".$host_uuid."::password = ".$anvil->data->{database}{$host_uuid}{password}."\n"; $insert .= "database::".$host_uuid."::ping = ".$anvil->data->{database}{$host_uuid}{ping}."\n\n"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { insert => $insert }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, secure => 1, level => 2, list => { insert => $insert }}); # Now inject the config. my $new_body = ""; @@ -456,7 +456,8 @@ sub add_to_local_config my $test_line = "database::${host_uuid}::"; foreach my $line (split/\n/, $anvil_conf_body) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }}); + my $secure = (($line =~ /password/) && ($line !~ /^#/)) ? 1 : 0; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, secure => $secure, level => 2, list => { line => $line }}); if ($line =~ /^$test_line/) { # It's already configured, abort. @@ -470,7 +471,7 @@ sub add_to_local_config if ($line eq "### end db list ###") { $new_body .= $insert; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_body => $new_body }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, secure => 1, level => 2, list => { new_body => $new_body }}); } $new_body .= $line."\n"; } @@ -480,11 +481,12 @@ sub add_to_local_config if (not $config_seen) { # Backup the original - my $backup_file = $anvil->Storage->backup({file => $anvil->data->{path}{configs}{'anvil.conf'}}); + my $backup_file = $anvil->Storage->backup({secure => 1, file => $anvil->data->{path}{configs}{'anvil.conf'}}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { backup_file => $backup_file }}); # Now update! $anvil->Storage->write_file({ + secure => 1, debug => 2, file => $anvil->data->{path}{configs}{'anvil.conf'}, body => $new_body,