Commit a6b87170 authored by Leigh B Stoller's avatar Leigh B Stoller

Allow '*' for state1 (source state) in the state_transition table,

which says that any source state is okay, for the specified target
state. Basically a convenience.
parent 6f773c65
...@@ -467,6 +467,24 @@ sub getValid() { ...@@ -467,6 +467,24 @@ sub getValid() {
return %valid; return %valid;
} }
#
# Check if a transition is valid. Actually, it is a check for an invalid
# transition.
#
sub IsValidTransition($$$)
{
my ($mode, $oldstate, $newstate) = @_;
my $isvalid = 1;
$isvalid = 0
if ($valid{$mode} &&
($valid{$mode}{$oldstate} || $valid{$mode}{"*"}) &&
! ($valid{$mode}{$oldstate}{$newstate} ||
$valid{$mode}{"*"}{$newstate}));
return $isvalid;
}
# #
# Read the list of valid mode transitions from the database # Read the list of valid mode transitions from the database
# #
...@@ -639,10 +657,10 @@ sub stateTransition($$) { ...@@ -639,10 +657,10 @@ sub stateTransition($$) {
$oldstate = $nodes{$node}{state}; $oldstate = $nodes{$node}{state};
$mode = $nodes{$node}{mode}; $mode = $nodes{$node}{mode};
if ($oldstate && $mode && $valid{$mode} && $valid{$mode}{$oldstate} && if ($oldstate && $mode && !IsValidTransition($mode,$oldstate,$newstate)) {
!$valid{$mode}{$oldstate}{$newstate}) {
notify("Invalid transition for node $node from $mode/$oldstate " . notify("Invalid transition for node $node from $mode/$oldstate " .
"to $newstate\n"); "to $newstate\n");
# #
# Machines in the secure boot path are not allowed to jump # Machines in the secure boot path are not allowed to jump
# willy-nilly into unknown states. # willy-nilly into unknown states.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment