feat: check for provisioning state on shbc failure and reset if necessary
This commit is contained in:
34
commands.cpp
34
commands.cpp
@@ -492,3 +492,37 @@ bool cmd_start_config_host_based(config_host_based_settings& server_cert, config
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmd_get_provisioning_state(int& state)
|
||||||
|
{
|
||||||
|
state = 0;
|
||||||
|
|
||||||
|
// initialize HECI interface
|
||||||
|
if (heci_Init(NULL, PTHI_CLIENT) == 0) return false;
|
||||||
|
|
||||||
|
// get Control Mode
|
||||||
|
AMT_PROVISIONING_STATE provisioningState;
|
||||||
|
AMT_STATUS amt_status = pthi_GetProvisioningState(&provisioningState);
|
||||||
|
if (amt_status == 0)
|
||||||
|
{
|
||||||
|
state = provisioningState;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmd_stop_configuration()
|
||||||
|
{
|
||||||
|
// initialize HECI interface
|
||||||
|
if (heci_Init(NULL, PTHI_CLIENT) == 0) return false;
|
||||||
|
|
||||||
|
AMT_STATUS amt_status = pthi_StopConfiguration();
|
||||||
|
if (amt_status == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
@@ -57,5 +57,7 @@ bool cmd_get_certificate_hashes(std::vector<cert_hash_entry>& hash_entries);
|
|||||||
bool cmd_get_remote_access_connection_status(int& network_status, int& remote_status, int& remote_trigger, std::string& mps_hostname);
|
bool cmd_get_remote_access_connection_status(int& network_status, int& remote_status, int& remote_trigger, std::string& mps_hostname);
|
||||||
bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings, bool wired_interface = true);
|
bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings, bool wired_interface = true);
|
||||||
bool cmd_start_config_host_based(config_host_based_settings& server_cert, config_host_based_settings& amt_cert);
|
bool cmd_start_config_host_based(config_host_based_settings& server_cert, config_host_based_settings& amt_cert);
|
||||||
|
bool cmd_get_provisioning_state(int& state);
|
||||||
|
bool cmd_stop_configuration();
|
||||||
|
|
||||||
#endif
|
#endif
|
23
main.cpp
23
main.cpp
@@ -294,6 +294,29 @@ int main(int argc, char* argv[])
|
|||||||
server_cert.hash = certHash;
|
server_cert.hash = certHash;
|
||||||
bool sbhc_success = cmd_start_config_host_based(server_cert, amt_cert);
|
bool sbhc_success = cmd_start_config_host_based(server_cert, amt_cert);
|
||||||
|
|
||||||
|
if (!sbhc_success)
|
||||||
|
{
|
||||||
|
int state;
|
||||||
|
if (cmd_get_provisioning_state(state))
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case 0:
|
||||||
|
std::cout << "Provisioning state already in pre-provisioning." << std::endl;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
std::cout << "Provisioning state is in-provisioning." << std::endl;
|
||||||
|
(cmd_stop_configuration()) ? std::cout << "Provisioning state succesfully reset." : std::cout << "Provisioning state could not be reset.";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
std::cout << "Provisioning state is post-provisioning." << std::endl;
|
||||||
|
(cmd_stop_configuration()) ? std::cout << "Provisioning state succesfully reset." : std::cout << "Provisioning state could not be reset.";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create the response
|
// create the response
|
||||||
std::string response;
|
std::string response;
|
||||||
if (!shbc_create_response(amt_cert.algorithm, amt_cert.hash, sbhc_success, response)) return;
|
if (!shbc_create_response(amt_cert.algorithm, amt_cert.hash, sbhc_success, response)) return;
|
||||||
|
Reference in New Issue
Block a user