* Fixed up security handling.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 56045214f2
commit 9e8ce6dec4
  1. 4
      Anvil/Tools/Storage.pm
  2. 14
      tools/anvil-prep-database

@ -2048,13 +2048,13 @@ sub write_file
my $overwrite = defined $parameter->{overwrite} ? $parameter->{overwrite} : 0; my $overwrite = defined $parameter->{overwrite} ? $parameter->{overwrite} : 0;
my $port = defined $parameter->{port} ? $parameter->{port} : 22; my $port = defined $parameter->{port} ? $parameter->{port} : 22;
my $password = defined $parameter->{password} ? $parameter->{password} : ""; 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 $target = defined $parameter->{target} ? $parameter->{target} : "";
my $user = defined $parameter->{user} ? $parameter->{user} : "root"; my $user = defined $parameter->{user} ? $parameter->{user} : "root";
my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root"; my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root";
my $error = 0; my $error = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => 0, list => { $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, file => $file,
group => $group, group => $group,
mode => $mode, mode => $mode,

@ -28,7 +28,7 @@ $| = 1;
my $anvil = Anvil::Tools->new(); my $anvil = Anvil::Tools->new();
$anvil->Log->level({set => 2}); $anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1}); $anvil->Log->secure({set => 0});
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
@ -434,7 +434,7 @@ sub add_to_local_config
my $host_uuid = $anvil->Get->host_uuid(); my $host_uuid = $anvil->Get->host_uuid();
my $local_uuid = ""; my $local_uuid = "";
my $anvil_conf_body = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'anvil.conf'}}); 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, host_uuid => $host_uuid,
anvil_conf_body => $anvil_conf_body, 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."::port = ".$anvil->data->{database}{$host_uuid}{port}."\n";
$insert .= "database::".$host_uuid."::password = ".$anvil->data->{database}{$host_uuid}{password}."\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"; $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. # Now inject the config.
my $new_body = ""; my $new_body = "";
@ -456,7 +456,8 @@ sub add_to_local_config
my $test_line = "database::${host_uuid}::"; my $test_line = "database::${host_uuid}::";
foreach my $line (split/\n/, $anvil_conf_body) 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/) if ($line =~ /^$test_line/)
{ {
# It's already configured, abort. # It's already configured, abort.
@ -470,7 +471,7 @@ sub add_to_local_config
if ($line eq "### end db list ###") if ($line eq "### end db list ###")
{ {
$new_body .= $insert; $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"; $new_body .= $line."\n";
} }
@ -480,11 +481,12 @@ sub add_to_local_config
if (not $config_seen) if (not $config_seen)
{ {
# Backup the original # 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 }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { backup_file => $backup_file }});
# Now update! # Now update!
$anvil->Storage->write_file({ $anvil->Storage->write_file({
secure => 1,
debug => 2, debug => 2,
file => $anvil->data->{path}{configs}{'anvil.conf'}, file => $anvil->data->{path}{configs}{'anvil.conf'},
body => $new_body, body => $new_body,

Loading…
Cancel
Save