* Started work on a system to provide inter-machine ssh communication without needing to track or record passwords in the database or config files (outside the database access passwords). Added 'host_key' to the 'hosts' table that stores the host public key. Also now create ssh public/private key pairs for the 'root' and 'admin' users.

* Fixed some bugs in anvil-update-states so that bonds are recorded properly in the database.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 47280c8fd9
commit 80e7bc5ce0
  1. 2
      Anvil/Tools.pm
  2. 31
      Anvil/Tools/Database.pm
  3. 4
      Anvil/Tools/Storage.pm
  4. 8
      share/anvil.sql
  5. 15
      share/words.xml
  6. 91
      tools/anvil-daemon
  7. 154
      tools/anvil-manage-files
  8. 22
      tools/anvil-update-states

@ -941,6 +941,7 @@ sub _set_paths
},
data => {
group => "/etc/group",
host_ssh_key => "/etc/ssh/ssh_host_ecdsa_key.pub",
'.htpasswd' => "/etc/httpd/.htpasswd",
host_uuid => "/etc/anvil/host.uuid",
passwd => "/etc/passwd",
@ -1017,6 +1018,7 @@ sub _set_paths
rsync => "/usr/bin/rsync",
sed => "/usr/bin/sed",
'shutdown' => "/usr/sbin/shutdown",
'ssh-keygen' => "/usr/bin/ssh-keygen",
'ssh-keyscan' => "/usr/bin/ssh-keyscan",
strings => "/usr/bin/strings",
'striker-configure-host' => "/usr/sbin/striker-configure-host",

@ -2655,6 +2655,10 @@ If set, this is the file name logged as the source of any INSERTs or UPDATEs.
If set, this is the file line number logged as the source of any INSERTs or UPDATEs.
=head3 host_key (required)
The is the host's public key used by other machines to validate this machine when connecting to it using ssh. The value comes from C<< /etc/ssh/ssh_host_ecdsa_key.pub >>. An example string would be C<< ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMLEG+mcczSUgmcSuRNZc5OAFPa7IudZQv/cYWzCzmlKPMkIdcNiYDuFM1iFNiV9wVtAvkIXVSkOe2Ah/BGt6fQ= >>.
=head3 host_name (required)
This default value is the local hostname.
@ -2679,6 +2683,7 @@ sub insert_or_update_hosts
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : "";
my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $line = defined $parameter->{line} ? $parameter->{line} : "";
my $host_key = defined $parameter->{host_key} ? $parameter->{host_key} : "";
my $host_name = defined $parameter->{host_name} ? $parameter->{host_name} : $anvil->_hostname;
my $host_type = defined $parameter->{host_type} ? $parameter->{host_type} : $anvil->System->get_host_type;
my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->Get->host_uuid;
@ -2686,6 +2691,7 @@ sub insert_or_update_hosts
uuid => $uuid,
file => $file,
line => $line,
host_key => $host_key,
host_name => $host_name,
host_type => $host_type,
host_uuid => $host_uuid,
@ -2704,13 +2710,23 @@ sub insert_or_update_hosts
return("");
}
# If we're looking at ourselves and we don't have the host_key, read it in.
if ((not $host_key) && ($host_uuid eq $anvil->Get->host_uuid))
{
$host_key = $anvil->Storage->read_file({file => $anvil->data->{path}{data}{host_ssh_key}});
$host_key =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host_key => $host_key }});
}
# Read the old values, if they exist.
my $old_host_name = "";
my $old_host_type = "";
my $query = "
my $old_host_key = "";
my $query = "
SELECT
host_name,
host_type
host_type,
host_key
FROM
hosts
WHERE
@ -2727,10 +2743,12 @@ WHERE
foreach my $row (@{$results})
{
$old_host_name = $row->[0];
$old_host_type = $row->[1];
$old_host_type = defined $row->[1] ? $row->[1] : "";
$old_host_key = defined $row->[2] ? $row->[2] : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
old_host_name => $old_host_name,
old_host_type => $old_host_type,
old_host_key => $old_host_key,
}});
}
if (not $count)
@ -2743,18 +2761,22 @@ INSERT INTO
host_uuid,
host_name,
host_type,
host_key,
modified_date
) VALUES (
".$anvil->data->{sys}{database}{use_handle}->quote($host_uuid).",
".$anvil->data->{sys}{database}{use_handle}->quote($host_name).",
".$anvil->data->{sys}{database}{use_handle}->quote($host_type).",
".$anvil->data->{sys}{database}{use_handle}->quote($host_key).",
".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{timestamp})."
);
";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({query => $query, uuid => $uuid, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
elsif (($old_host_name ne $host_name) or ($old_host_type ne $host_type))
elsif (($old_host_name ne $host_name) or
($old_host_type ne $host_type) or
($old_host_key ne $host_key))
{
# Clear the stop data.
my $query = "
@ -2763,6 +2785,7 @@ UPDATE
SET
host_name = ".$anvil->data->{sys}{database}{use_handle}->quote($host_name).",
host_type = ".$anvil->data->{sys}{database}{use_handle}->quote($host_type).",
host_key = ".$anvil->data->{sys}{database}{use_handle}->quote($host_key).",
modified_date = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{timestamp})."
WHERE
host_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($host_uuid)."

@ -957,8 +957,8 @@ sub make_directory
$group =~ s/^(\S+)\s.*$/$1/;
print $THIS_FILE." ".__LINE__."; user: [".$user."], group: [".$group."]\n" if $test;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
group => $group,
user => $user,
group => $group,
user => $user,
}});
# Break the directories apart.

@ -48,6 +48,7 @@ CREATE TABLE hosts (
host_uuid uuid not null primary key, -- This is the single most important record in Anvil!. Everything links back to here.
host_name text not null,
host_type text, -- Either 'node' or 'dashboard' or 'dr_host'. It is left empty until the host is configured.
host_key text, -- This is the host's key used to authenticate it when other machines try to ssh to it.
modified_date timestamp with time zone not null
);
ALTER TABLE hosts OWNER TO admin;
@ -57,6 +58,7 @@ CREATE TABLE history.hosts (
host_uuid uuid,
host_name text,
host_type text,
host_key text,
modified_date timestamp with time zone not null
);
ALTER TABLE history.hosts OWNER TO admin;
@ -71,11 +73,13 @@ BEGIN
(host_uuid,
host_name,
host_type,
host_key,
modified_date)
VALUES
(history_hosts.host_uuid,
history_hosts.host_name,
history_hosts.host_type,
history_hosts.host_key,
history_hosts.modified_date);
RETURN NULL;
END;
@ -88,12 +92,12 @@ CREATE TRIGGER trigger_hosts
FOR EACH ROW EXECUTE PROCEDURE history_hosts();
-- This stores the SSH _public_ keys for a given user on a host.
-- This stores the SSH _public_keys for a given user on a host.
CREATE TABLE host_keys (
host_key_uuid uuid not null primary key, -- This is the single most important record in Anvil!. Everything links back to here.
host_key_host_uuid uuid not null,
host_key_user_name text not null, -- This is the user name on the system, not a web interface user.
host_key_public_key text not null, -- Either 'node' or 'dashboard'.
host_key_public_key text not null, -- Either 'node', 'dashboard' or 'dr'
modified_date timestamp with time zone not null,
FOREIGN KEY(host_key_host_uuid) REFERENCES hosts(host_uuid)

@ -563,6 +563,15 @@ Finished Downloading: [#!variable!file!#].
<key name="log_0266">This file is large, [#!variable!size!#], this might take a bit of time...</key>
<key name="log_0267">Failed to move the file: [#!variable!source_file!#] to: [#!variable!target_file!#] on the target: [#!variable!target!#] as: [#!variable!remote_user!#]. The error (if any) was: [#!variable!error!#] and the output (if any) was: [#!variable!output!#].</key>
<key name="log_0268">The file: [#!variable!file!#] has been added to the database (if needed) moved to: [#!variable!target!#].</key>
<key name="log_0269">The file: [#!variable!file!#] should exist, but doesn't. We will try to find it now.</key>
<key name="log_0270">The user: [#!variable!user!#] doesn't appear to have an SSH key yet. Will create it now. This could take some time, depending on how long it takes to collect entropy. If this appears to not be responding, move the mouse or do other things to generate activity on the host.</key>
<key name="log_0271">
The user: [#!variable!user!#]'s SSH key yet has been generated. The output is below;
====
#!variable!output!#
====
</key>
<key name="log_0272">The user: [#!variable!user!#] doesn't appear to have a base SSH directory. Will now create: [#!variable!directory!#].</key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
<key name="t_0000">Test</key>
@ -823,6 +832,12 @@ The update appears to have not completed successfully. The output was:
<key name="error_0054">Failed!</key>
<key name="error_0055">A request to toggle the script flag was received, but no file name was given.</key>
<key name="error_0056">A request to rename the file: [#!variable!file!#] to: [#!variable!to!#], but there is an existing file or directory with that name.</key>
<key name="error_0057">
Failed to generate an RSA public key for the user: [#!variable!user!#]. The output, if any, is below:
====
#!variable!output!#
====
</key>
<!-- These are units, words and so on used when displaying information. -->
<key name="unit_0001">Yes</key>

@ -65,6 +65,8 @@ $| = 1;
# in the loop as well to override defaults in code.
my $anvil = Anvil::Tools->new();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
# Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks
# is to setup the database server.
@ -209,6 +211,9 @@ sub handle_periodic_tasks
# Check to see if the PXE environment needs to be updated.
check_install_target($anvil);
# Check that the users we care about have ssh public keys and they're recorded in ssh_keys.
check_ssh_keys($anvil);
# Check if the files on disk have changed. Even if it is time to check, don't if a job is
# running.
if ((not $anvil->data->{timing}{jobs_running}) && ($anvil->Storage->check_md5sums))
@ -228,7 +233,7 @@ sub handle_periodic_tasks
"s2:timing::next_minute_check" => $anvil->data->{timing}{next_minute_check},
}});
# Make sure the shared directories.
# Make sure the shared directories exist.
foreach my $target (sort {$a cmp $b} keys %{$anvil->data->{path}{directories}{shared}})
{
my $directory = $anvil->data->{path}{directories}{shared}{$target};
@ -293,6 +298,87 @@ sub handle_periodic_tasks
return(0);
}
# Check that the host's fingerprint and users we care about have ssh public keys and they're recorded in ssh_keys.
sub check_ssh_keys
{
my ($anvil) = @_;
### TODO: Left off here... Then read in the same for all other machines and use it to generate/update each user's 'known_hosts' file.
### For each user, if there is no SSH public key, create it. If / once it exists, add/update it the database. Finally, use key user keys from other users on other systems to populate / update the user's authorized_keys file.
# Read in this host's machine fingerprint.
# 130 digimer@pulsar:~/anvil/anvil$ # el8-striker01 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMLEG+mcczSUgmcSuRNZc5OAFPa7IudZQv/cYWzCzmlKPMkIdcNiYDuFM1iFNiV9wVtAvkIXVSkOe2Ah/BGt6fQ=
#
# Get a list of all hosts and IPs we know about. We'll use this to update
# Users to check:
# root, admin, hacluster
foreach my $user ("root", "admin")
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { user => $user }});
my $user_home = $anvil->Get->users_home({user => $user});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { user_home => $user_home }});
# If the user doesn't exist, their home directory won't either, so skip.
next if not $user_home;
next if not -d $user_home;
# If the user's ~/.ssh directory doesn't exist, we need to create it.
my $ssh_directory = $user_home."/.ssh";
$ssh_directory =~ s/\/\//\//g;
if (not -e $ssh_directory)
{
# Create it.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0272", variables => { user => $user, directory => $ssh_directory }});
$anvil->Storage->make_directory({
directory => $ssh_directory,
user => $user,
group => $user,
mode => "0700",
});
if (not -e $ssh_directory)
{
# Failed ?
next;
}
}
my $ssh_private_key_file = $user_home."/.ssh/id_rsa";
my $ssh_public_key_file = $user_home."/.ssh/id_rsa.pub";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ssh_public_key_file => $ssh_public_key_file,
ssh_private_key_file => $ssh_private_key_file,
}});
if (not -e $ssh_public_key_file)
{
# Generate the SSH keys.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0270", variables => { user => $user }});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{'ssh-keygen'}." -t rsa -N \"\" -b 8191 -f ".$ssh_private_key_file});
if (-e $ssh_public_key_file)
{
# Success!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0271", variables => { user => $user, output => $output }});
}
else
{
# Failed?
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "error_0057", variables => { user => $user, output => $output }});
next;
}
}
# Now read in the key.
my $users_public_key = $anvil->Storage->read_file({file => $ssh_public_key_file});
$users_public_key =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { users_public_key => $users_public_key }});
}
return(0);
}
# This calls striker-manage-install-target to see if the dhcpd is running or not. If it is or isn't, the config
# variable 'install-target::enabled' is set/updated. On non-Striker hosts, this simply returns without doing
# anything.
@ -359,6 +445,9 @@ sub run_once
# Check to see if we need to do boot-time tasks. We only run these if we've just booted
boot_time_tasks($anvil);
# Check the ssh stuff.
check_ssh_keys($anvil);
if ($anvil->data->{switches}{'startup-only'})
{
$anvil->nice_exit({code => 0});

@ -130,7 +130,7 @@ else
check_incoming($anvil);
# Check for files we should have but don't yet have.
#find_missing_files($anvil);
find_missing_files($anvil);
}
# We're done
@ -169,6 +169,7 @@ sub find_missing_files
my $query = "
SELECT
a.file_uuid,
a.file_directory,
a.file_name
FROM
files a,
@ -181,27 +182,46 @@ AND
AND
b.host_uuid = c.file_location_host_uuid
ORDER BY
a.file_directory ASC,
a.file_name ASC,
b.host_name ASC
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, 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 => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $file_location_file_uuid = $row->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
file_location_file_uuid => $file_location_file_uuid,
my $file_uuid = $row->[0];
my $file_directory = $row->[1];
my $file_name = $row->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:file_uuid' => $file_uuid,
's2:file_directory' => $file_directory,
's3:file_name' => $file_name,
}});
### TODO: How to handle when the file with the same name exists on 2+ machines with
### different md5sums. Use the most recent mtime?
# Read in the file details.
my $test_file = $file_directory."/".$file_name;
$test_file =~ s/\/\//\//g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { test_file => $test_file }});
if (not -e $test_file)
{
# Missing file!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0269", variables => { file => $test_file }});
# Find what target, if any, we'll the file from.
my ($target, $port, $password) = find_file($anvil, $file_uuid);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
target => $target,
port => $port,
password => $password,
}});
}
}
# Read in any entries from 'file_locations'.
@ -209,6 +229,80 @@ ORDER BY
return(0);
}
### TODO: Use System->find_matching_ip() and System->get_ips().
### TODO: Add sorting by preferred target
# This looks for a file on another system. The exact order of search depends on what kind of machine we are.
sub find_file
{
my ($anvil, $file_uuid) = @_;
my $target = "";
my $port = "";
my $password = "";
# Find the file on any/all other hosts.
my $query = "
SELECT
a.host_uuid,
a.host_name,
a.host_type,
b.file_directory,
b.file_name,
b.file_size,
b.file_md5sum
FROM
hosts a,
files b,
file_locations c
WHERE
a.host_uuid = c.file_location_host_uuid
AND
b.file_uuid = c.file_location_file_uuid
AND
b.file_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($file_uuid)."
AND
a.host_uuid != ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{host_uuid})."
ORDER BY
file_mtime DESC;
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, 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 => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $host_uuid = $row->[0];
my $host_name = $row->[1];
my $host_type = $row->[2];
my $file_directory = $row->[3];
my $file_name = $row->[4];
my $file_size = $row->[5];
my $file_md5sum = $row->[6];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
host_uuid => $host_uuid,
host_name => $host_name,
host_type => $host_type,
file_directory => $file_directory,
file_name => $file_name,
file_size => $file_size,
file_md5sum => $file_md5sum,
}});
my $test_file = $file_directory."/".$file_name;
$test_file =~ s/\/\//\//g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { test_file => $test_file }});
# Can I connect to this machine?
}
return($target, $port, $password);
}
# This handles deleting a file.
sub check_incoming
{
@ -221,7 +315,7 @@ sub check_incoming
}
# Read any files in '/mnt/shared/incoming'.
$anvil->Storage->scan_directory({
debug => 1,
debug => 3,
directory => $anvil->data->{path}{directories}{shared}{base},
recursive => 1,
});
@ -232,7 +326,7 @@ sub check_incoming
{
# Skip if this isn't a file.
my $file_type = $anvil->data->{scan}{directories}{$full_path}{type};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
full_path => $full_path,
file_type => $file_type,
}});
@ -245,7 +339,7 @@ sub check_incoming
my $file_mimetype = $anvil->data->{scan}{directories}{$full_path}{mimetype};
my $file_executable = $anvil->data->{scan}{directories}{$full_path}{executable} = -x $full_path ? 1 : 0;
my $say_mimetype = convert_mimetype($anvil, $file_mimetype, $full_path, $file_executable);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
file_name => $file_name,
file_size => $file_size,
file_mtime => $file_mtime,
@ -256,7 +350,7 @@ sub check_incoming
# Do I know about this file? If so, is the file the same size? If either is no, calculate the md5sum.
my ($file_uuid, $recorded_size, $recorded_mtime, $recorded_md5sum) = get_file_db_info($anvil, "", $file_name);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
file_uuid => $file_uuid,
recorded_size => $recorded_size,
recorded_mtime => $recorded_mtime,
@ -297,7 +391,7 @@ sub check_incoming
# Insert or update the files entry.
($file_uuid) = $anvil->Database->insert_or_update_files({
debug => 2,
debug => 3,
file_uuid => $file_uuid,
file_name => $file_name,
file_directory => $file_directory,
@ -306,23 +400,23 @@ sub check_incoming
file_mtime => $file_mtime,
file_type => $say_mimetype,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file_uuid => $file_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file_uuid => $file_uuid }});
}
# If we still don't have a file UUID for some reason, skip this file.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file_uuid => $file_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file_uuid => $file_uuid }});
next if not $file_uuid;
# Make sure we know about this file on this system
my ($file_locatiom_uuid) = $anvil->Database->insert_or_update_file_locations({
debug => 2,
debug => 3,
file_location_file_uuid => $file_uuid,
file_location_host_uuid => $anvil->data->{sys}{host_uuid},
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file_locatiom_uuid => $file_locatiom_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file_locatiom_uuid => $file_locatiom_uuid }});
# Are we in the incoming directory? If so, move the file.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
full_path => $full_path,
incoming_directory => $incoming_directory,
}});
@ -334,14 +428,14 @@ sub check_incoming
my $target = $say_mimetype eq "definition" ? $anvil->data->{path}{directories}{shared}{definitions} : $anvil->data->{path}{directories}{shared}{files};
$target .= "/";
$target =~ s/\/\//\//g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { target => $target }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { target => $target }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0268", variables => {
file => $full_path,
target => $target,
}});
$anvil->Storage->move_file({
debug => 2,
debug => 3,
source_file => $full_path,
target_file => $target,
});
@ -349,7 +443,7 @@ sub check_incoming
# Update the file_directory.
my $say_directory =~ s/\/$//;
($file_uuid) = $anvil->Database->insert_or_update_files({
debug => 2,
debug => 3,
file_uuid => $file_uuid,
file_name => $file_name,
file_directory => $say_directory,
@ -358,7 +452,7 @@ sub check_incoming
file_mtime => $file_mtime,
file_type => $say_mimetype,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file_uuid => $file_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file_uuid => $file_uuid }});
}
}
@ -391,7 +485,7 @@ sub get_file_db_info
my ($anvil, $file_md5sum, $file_name) = @_;
$file_md5sum = "" if not defined $file_md5sum;
$file_name = "" if not defined $file_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
file_md5sum => $file_md5sum,
file_name => $file_name,
}});
@ -419,7 +513,7 @@ WHERE
}
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results,
count => $count,
}});
@ -432,7 +526,7 @@ WHERE
my $file_size = defined $results->[0]->[1] ? $results->[0]->[1] : 0;
my $file_mtime = defined $results->[0]->[2] ? $results->[0]->[2] : 0;
$file_md5sum = defined $results->[0]->[3] ? $results->[0]->[3] : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
file_uuid => $file_uuid,
file_size => $file_size,
file_mtime => $file_mtime,
@ -571,7 +665,7 @@ WHERE
sub convert_mimetype
{
my ($anvil, $mimetype, $file, $executable) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
mimetype => $mimetype,
file => $file,
executable => $executable,
@ -588,10 +682,10 @@ sub convert_mimetype
{
# This might be a definition, but look inside it to be sure.
my $is_domain = $anvil->System->call({
debug => 2,
debug => 3,
shell_call => "if \$(".$anvil->data->{path}{exe}{'grep'}." -q '</domain>' ".$file."); then ".$anvil->data->{path}{exe}{echo}." 1; else ".$anvil->data->{path}{exe}{echo}." 0; fi",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { is_domain => $is_domain }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { is_domain => $is_domain }});
if ($is_domain)
{
@ -612,7 +706,7 @@ sub convert_mimetype
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_mimetype => $say_mimetype }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_mimetype => $say_mimetype }});
return($say_mimetype);
}

@ -18,6 +18,8 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
}
my $anvil = Anvil::Tools->new();
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 0});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Database->connect;
@ -125,7 +127,8 @@ sub update_network
if (-e $mac_bond_file)
{
# It's a slave.
$mac_address = $anvil->Storage->read_file({file => $mac_bond_file});
$mac_address = $anvil->Storage->read_file({file => $mac_bond_file});
$mac_address =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { mac_address => $mac_address }});
}
@ -158,14 +161,21 @@ sub update_network
# Read the bond mode.
$bond_mode = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/mode"});
$bond_mode =~ s/\s.*//;
$primary_slave = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/primary"});
$primary_reselect = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/primary_reselect"});
$primary_reselect =~ s/\s.*//;
$active_slave = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/active_slave"});
$mii_polling_interval = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/miimon"});
$up_delay = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/updelay"});
$down_delay = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/downdelay"});
$bond_mode =~ s/\s.*//;
$bond_mode =~ s/\n$//;
$primary_slave =~ s/\n$//;
$primary_reselect =~ s/\s.*//;
$primary_reselect =~ s/\n$//;
$active_slave =~ s/\n$//;
$mii_polling_interval =~ s/\n$//;
$up_delay =~ s/\n$//;
$down_delay =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
active_slave => $active_slave,
bond_mode => $bond_mode,
@ -180,13 +190,13 @@ sub update_network
# No, but it's slaved to one.
my $target = readlink($full_path."/master");
$bond_master = ($target =~ /^.*\/(.*)$/)[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
target => $target,
bond_master => $bond_master,
}});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
active_slave => $active_slave,
bond_master => $bond_master,
bond_mode => $bond_mode,
@ -261,7 +271,7 @@ sub update_network
type => $type,
up_delay => $up_delay,
};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"network::interfaces::by_name::${interface}::active_slave" => $anvil->data->{network}{interfaces}{by_name}{$interface}{active_slave},
"network::interfaces::by_name::${interface}::bond_mode" => $anvil->data->{network}{interfaces}{by_name}{$interface}{bond_mode},
"network::interfaces::by_name::${interface}::bond_master" => $anvil->data->{network}{interfaces}{by_name}{$interface}{bond_master},

Loading…
Cancel
Save