recovery-utils: add check into recover library if dualboot is enabled
This commit add a verification into the recovery library to avoid
that it is executed when in dualboot mode.
Signed-off-by: Mike Engel <Mike.Engel@digi.com>
https://onedigi.atlassian.net/browse/DEL-7580
(cherry picked from commit 30aa4a7444)
This commit is contained in:
parent
efb615fc7c
commit
c47377df22
|
|
@ -70,4 +70,11 @@ int set_encryption_key(char *key, unsigned char force);
|
||||||
*/
|
*/
|
||||||
int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force);
|
int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if device has dualboot enabled.
|
||||||
|
*
|
||||||
|
* Return: 1 if enabled and 0 if disabled, -1 on error when reading the environment
|
||||||
|
*/
|
||||||
|
int is_dualboot_enabled(void);
|
||||||
|
|
||||||
#endif /* RECOVERY_H */
|
#endif /* RECOVERY_H */
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,12 @@ static int append_recovery_command(const char *value)
|
||||||
int rcvr_cmd_len;
|
int rcvr_cmd_len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
/* Check if we are in dualboot mode */
|
||||||
|
if (is_dualboot_enabled()) {
|
||||||
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
ret = uboot_getenv("recovery_command", &old_recovery_cmd);
|
ret = uboot_getenv("recovery_command", &old_recovery_cmd);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf(stderr, "Error: getenv 'recovery_command'\n");
|
fprintf(stderr, "Error: getenv 'recovery_command'\n");
|
||||||
|
|
@ -584,6 +590,12 @@ int update_firmware(const char *swu_path)
|
||||||
int file_prefix_len = 0;
|
int file_prefix_len = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
/* Check if we are in dualboot mode */
|
||||||
|
if (is_dualboot_enabled()) {
|
||||||
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Verify input parameter */
|
/* Verify input parameter */
|
||||||
if (!swu_path) {
|
if (!swu_path) {
|
||||||
fprintf(stderr, "Error: NULL 'swu_path'\n");
|
fprintf(stderr, "Error: NULL 'swu_path'\n");
|
||||||
|
|
@ -624,6 +636,12 @@ int reboot_recovery(unsigned int reboot_timeout)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
/* Check if we are in dualboot mode */
|
||||||
|
if (is_dualboot_enabled()) {
|
||||||
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
printf("\nThe recovery commands have been properly configured and "
|
printf("\nThe recovery commands have been properly configured and "
|
||||||
|
|
@ -668,6 +686,12 @@ int set_encryption_key(char *key, unsigned char force)
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned char i = 0;
|
unsigned char i = 0;
|
||||||
|
|
||||||
|
/* Check if we are in dualboot mode */
|
||||||
|
if (is_dualboot_enabled()) {
|
||||||
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize arrays */
|
/* Initialize arrays */
|
||||||
parts[0] = NULL;
|
parts[0] = NULL;
|
||||||
encrypted[0] = NULL;
|
encrypted[0] = NULL;
|
||||||
|
|
@ -768,6 +792,12 @@ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* Check if we are in dualboot mode */
|
||||||
|
if (is_dualboot_enabled()) {
|
||||||
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* If both lists are empty, we have nothing to do */
|
/* If both lists are empty, we have nothing to do */
|
||||||
if (!to_encrypt && !to_unencrypt)
|
if (!to_encrypt && !to_unencrypt)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -932,3 +962,27 @@ err:
|
||||||
return ret < 0 ? -1 : ret;
|
return ret < 0 ? -1 : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function: is_device_closed
|
||||||
|
* Description: check if the device is in dualboot mode
|
||||||
|
*/
|
||||||
|
int is_dualboot_enabled (void)
|
||||||
|
{
|
||||||
|
const char *var;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Parse dualboot */
|
||||||
|
ret = uboot_getenv("dualboot", &var);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "Error: getenv 'dualboot'\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Is dualboot enabled */
|
||||||
|
if (!strcmp(var, "no"))
|
||||||
|
ret = 0;
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue