* Created Validate->form_field() which makes it a little quicker/easier to sanity check a form field that uses one of the other Validate methods.
* Added Validate->is_mac to validate MAC addresses.
* Got config_step2 finishes and sanity checked.
Signed-off-by: Digimer <digimer@alteeve.ca>
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { step2_body => $step2_body }});
@ -374,64 +465,182 @@ sub sanity_check_step2
{
my ($an) = @_;
# This will flip if we run into a problem. We start by running through step1's sanity checks again.
# This should only fail is someone was passing raw data to us and screwed something up.
my $sane = sanity_check_step1($an);
# This will flip if we run into a problem.
my $sane = 1;
# Do we have a host name, striker user and password?
if ((not defined $an->data->{cgi}{hostname}{value}) or (not $an->data->{cgi}{hostname}{value}))
if (not $an->Validate->form_field({name => "hostname", type => "domain_name"}))
{
$an->data->{cgi}{hostname}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::hostname::alert" => $an->data->{cgi}{hostname}{alert} }});
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane }});
}
# The user name
if ((not defined $an->data->{cgi}{striker_user}{value}) or (not $an->data->{cgi}{striker_user}{value}))
{
$an->data->{cgi}{striker_user}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::striker_user::alert" => $an->data->{cgi}{striker_user}{alert} }});
}
if ((not defined $an->data->{cgi}{striker_password}{value}) or (not $an->data->{cgi}{striker_password}{value}))
# The password
if ((not defined $an->data->{cgi}{striker_password}{value}) or (not $an->data->{cgi}{striker_password}{value}) or (length($an->data->{cgi}{striker_password}{value}) < 6))
{
$an->data->{cgi}{striker_password}{alert} = 1;
$sane = 0;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::striker_password::alert" => $an->data->{cgi}{striker_password}{alert} }});
}
# Now it gets a bit tricker as we'll need to loop through the BCNs and IFNs.
my $bcn_count = $an->data->{cgi}{bcn_count}{value} ? $an->data->{cgi}{bcn_count}{value} : 1;
foreach my $bcn (1..$bcn_count)
# The gateway
if (not $an->Validate->form_field({name => "gateway", type => "ipv4"}))
{
my $this_bcn_key = "bcn".$bcn;
my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet";
my $this_iface1_key = "bcn".$bcn."_iface1_mac";
my $this_iface2_key = "bcn".$bcn."_iface2_mac";
# If I only have the iface1, we'll create a non-bonded interface (even if the option for a
# bond was presented to the user). So to be sane, we need a valid IP, subnet
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane }});
}
# DNS can be multiple entries, comma-separated.
if ((not defined $an->data->{cgi}{dns}{value}) or (not $an->data->{cgi}{dns}{value}))
{
$an->data->{cgi}{dns}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::dns::alert" => $an->data->{cgi}{dns}{alert} }});
}
my $ifn_count = $an->data->{cgi}{ifn_count}{value} ? $an->data->{cgi}{ifn_count}{value} : 1;
foreach my $ifn (1..$ifn_count)
else
{
foreach my $ip (split/,/, $an->data->{cgi}{dns}{value})
{
$ip =~ s/^\s+//;
$ip =~ s/\s+$//;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { ip => $ip }});
if (not $an->Validate->is_ipv4({ip => $ip}))
{
$an->data->{cgi}{dns}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::dns::alert" => $an->data->{cgi}{dns}{alert} }});
}
}
}
# Look for interfaces and sanity check them.
my $links = [];
foreach my $network ("bcn", "ifn")
{
my $this_ifn_key = "ifn".$ifn;
my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet";
my $this_iface1_key = "ifn".$ifn."_iface1_mac";
my $this_iface2_key = "ifn".$ifn."_iface2_mac";
my $count_key = $network."_count";
my $network_count = $an->data->{cgi}{$count_key}{value} ? $an->data->{cgi}{$count_key}{value} : 1;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
network => $network,
count_key => $count_key,
network_count => $network_count,
}});
foreach my $count (1..$network_count)
{
push @{$links}, $network."_link".$count;
my $this_ip_key = $network.$count."_ip";
my $this_subnet_key = $network.$count."_subnet";
my $this_iface1_key = $network.$count."_iface1_mac";
my $this_iface2_key = $network.$count."_iface2_mac";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
@ -61,7 +61,7 @@ This is the AN::Tools master 'words' file.
<keyname="striker_0031">Striker user name</key>
<keyname="striker_0032">This is the user name that you will log into Striker as and the name of the user that owns the database.</key>
<keyname="striker_0033">Striker password</key>
<keyname="striker_0034"><![CDATA[This will be the password used to log into this Striker and connect to its database.<br /><b>NOTE</b>: This password needs to be stored in plain text. Do not use a password you use elsewhere.]]></key>
<keyname="striker_0034"><![CDATA[This will be the password used to log into this Striker and connect to its database. It must be 6+ characters long.<br /><b>NOTE</b>: This password needs to be stored in plain text. Do not use a password you use elsewhere.]]></key>
<keyname="striker_0035">Gateway</key>
<keyname="striker_0036">This is the network gateway used to access the outside world.</key>