* Fixed a bug where the config page would be shown while a job was pending.

* Fixed a bug in Database->insert_or_update_users() wasn't handling the user's session salt.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 9e8ce6dec4
commit 458ef94851
  1. 12
      Anvil/Tools/Database.pm
  2. 28
      cgi-bin/home
  3. 1
      tools/anvil-change-password
  4. 21
      tools/anvil-configure-striker

@ -3365,6 +3365,7 @@ sub insert_or_update_users
my $user_name = defined $parameter->{user_name} ? $parameter->{user_name} : "";
my $user_password_hash = defined $parameter->{user_password_hash} ? $parameter->{user_password_hash} : "";
my $user_salt = defined $parameter->{user_salt} ? $parameter->{user_salt} : "";
my $user_session_salt = defined $parameter->{user_session_salt} ? $parameter->{user_session_salt} : "";
my $user_algorithm = defined $parameter->{user_algorithm} ? $parameter->{user_algorithm} : "";
my $user_hash_count = defined $parameter->{user_hash_count} ? $parameter->{user_hash_count} : "";
my $user_language = defined $parameter->{user_language} ? $parameter->{user_language} : $anvil->data->{sys}{language};
@ -3508,6 +3509,7 @@ INSERT INTO
user_is_admin,
user_is_experienced,
user_is_trusted,
user_session_salt,
modified_date
) VALUES (
".$anvil->data->{sys}{use_db_fh}->quote($user_uuid).",
@ -3520,6 +3522,7 @@ INSERT INTO
".$anvil->data->{sys}{use_db_fh}->quote($user_is_admin).",
".$anvil->data->{sys}{use_db_fh}->quote($user_is_experienced).",
".$anvil->data->{sys}{use_db_fh}->quote($user_is_trusted).",
".$anvil->data->{sys}{use_db_fh}->quote($user_session_salt).",
".$anvil->data->{sys}{use_db_fh}->quote($anvil->data->{sys}{db_timestamp})."
);
";
@ -3539,7 +3542,8 @@ SELECT
user_language,
user_is_admin,
user_is_experienced,
user_is_trusted
user_is_trusted,
user_session_salt
FROM
users
WHERE
@ -3564,6 +3568,7 @@ WHERE
my $old_user_is_admin = $row->[6];
my $old_user_is_experienced = $row->[7];
my $old_user_is_trusted = $row->[8];
my $old_user_session_salt = $row->[9];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
old_user_name => $old_user_name,
old_user_password_hash => $old_user_password_hash,
@ -3574,6 +3579,7 @@ WHERE
old_user_is_admin => $old_user_is_admin,
old_user_is_experienced => $old_user_is_experienced,
old_user_is_trusted => $old_user_is_trusted,
old_user_session_salt => $old_user_session_salt
}});
# Anything change?
@ -3586,7 +3592,8 @@ WHERE
($old_user_language ne $user_language) or
($old_user_is_admin ne $user_is_admin) or
($old_user_is_experienced ne $user_is_experienced) or
($old_user_is_trusted ne $user_is_trusted))
($old_user_is_trusted ne $user_is_trusted) or
($old_user_session_salt ne $user_session_salt))
{
# Something changed, save.
my $query = "
@ -3602,6 +3609,7 @@ SET
user_is_admin = ".$anvil->data->{sys}{use_db_fh}->quote($user_is_admin).",
user_is_experienced = ".$anvil->data->{sys}{use_db_fh}->quote($user_is_experienced).",
user_is_trusted = ".$anvil->data->{sys}{use_db_fh}->quote($user_is_trusted).",
user_session_salt = ".$anvil->data->{sys}{use_db_fh}->quote($user_session_salt).",
modified_date = ".$anvil->data->{sys}{use_db_fh}->quote($anvil->data->{sys}{db_timestamp})."
WHERE
user_uuid = ".$anvil->data->{sys}{use_db_fh}->quote($user_uuid)."

@ -73,19 +73,20 @@ $anvil->data->{form}{body} = "";
my $header = $anvil->Template->get({file => "main.html", name => "header", variables => { language => $anvil->Words->language }});
# If any jobs are pending/running, show the "unavailable" option.
my $available = check_availability($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { available => $available }});
my $available = check_availability($anvil);
my $configured = $available ? check_if_configured($anvil) : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
available => $available,
configured => $configured,
}});
if (not $available)
{
# Set the body to 'say::maintenance'.
$anvil->data->{form}{body} = $anvil->data->{say}{maintenance};
}
# If there is no user account yet, then the system is new and needs to be reconfigured.
my $configured = check_if_configured($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }});
if (not $configured)
elsif (not $configured)
{
# If there is no user account yet, then the system is new and needs to be reconfigured.
configure_striker($anvil);
}
else
@ -404,8 +405,9 @@ sub check_availability
{
my ($anvil) = @_;
my $debug = 3;
my $available = 1;
my $query = "
my $query = "
SELECT
job_progress,
modified_date,
@ -419,11 +421,11 @@ AND
AND
job_host_uuid = ".$anvil->data->{sys}{use_db_fh}->quote($anvil->Get->host_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
@ -435,7 +437,7 @@ AND
my $unixtime = $results->[0]->[2];
my $seconds_ago = $anvil->Convert->add_commas({number => (time - $unixtime)});
$available = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
available => $available,
percent => $percent,
seconds_ago => $seconds_ago,
@ -449,10 +451,10 @@ AND
title => "#!string!striker_0046!#",
description => $anvil->Words->string({key => "striker_0047", variables => { percent => $percent, timestamp => $timestamp, seconds_ago => $seconds_ago }}),
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'say::maintenance' => $anvil->data->{say}{maintenance} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'say::maintenance' => $anvil->data->{say}{maintenance} }});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { available => $available }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { available => $available }});
return($available);
}

@ -178,6 +178,7 @@ sub update_local_passwords
user_is_admin => 1,
user_is_experienced => 1,
user_is_trusted => 1,
user_session_salt => "", # Logs them out, effectively
});
print $anvil->Words->string({key => "message_0025"})."\n";

@ -52,11 +52,11 @@ my $connections = $anvil->Database->connect({
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0031"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0132", variables => { connections => $connections }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0132", variables => { connections => $connections }});
if (not $connections)
{
# No databases, exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "error_0003"})."\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "error_0003"});
$anvil->nice_exit({exit_code => 2});
}
@ -66,10 +66,6 @@ reconfigure_network($anvil);
update_passwords($anvil);
### TODO: This is only until we can get the damn networking stable on reconfigure.
# Reboot.
$anvil->Database->insert_or_update_jobs({
job_uuid => $anvil->data->{job}{uuid},
update_progress_only => 1,
@ -88,6 +84,8 @@ $anvil->Database->insert_or_update_variables({
variable_source_table => "hosts",
});
### TODO: This is only until we can get the damn networking stable on reconfigure.
# Reboot.
$anvil->System->call({shell_call => $anvil->data->{path}{exe}{'shutdown'}." --reboot now"});
$anvil->nice_exit({code => 0});
@ -223,11 +221,11 @@ sub reconfigure_network
# Now configure the network.
my $dns = defined $anvil->data->{variables}{form}{config_step2}{dns}{value} ? [split/,/, $anvil->data->{variables}{form}{config_step2}{dns}{value}] : [];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dns => $dns }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dns => $dns }});
for (my $i = 0; $i < @{$dns}; $i++)
{
$dns->[$i] = $anvil->Words->clean_spaces({ string => $dns->[$i] });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "dns->[$i]" => $dns->[$i] }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "dns->[$i]" => $dns->[$i] }});
}
my $gateway = defined $anvil->data->{variables}{form}{config_step2}{gateway}{value} ? $anvil->data->{variables}{form}{config_step2}{gateway}{value} : "";
@ -736,7 +734,7 @@ sub get_uuid_from_interface_file
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uuid => $uuid }});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uuid => $uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uuid => $uuid }});
return($uuid);
}
@ -838,7 +836,7 @@ AND
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
@ -846,9 +844,10 @@ AND
{
my $this_variable = $row->[0];
my $this_value = $row->[1];
my $secure = $this_variable =~ /passw/ ? 1 : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
this_variable => $this_variable,
this_value => $this_value,
this_value => (($anvil->Log->secure) or (not $secure)) ? $this_value : $anvil->Words->string({key => "log_0186"}),
}});
$anvil->_make_hash_reference($anvil->data->{variables}, $this_variable, $this_value);

Loading…
Cancel
Save