Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong DES are not completely discarted. #780

Closed
DaniilKl opened this issue Apr 11, 2024 · 5 comments · Fixed by Dasharo/dts-scripts#7 or Dasharo/meta-dts#118
Closed

Wrong DES are not completely discarted. #780

DaniilKl opened this issue Apr 11, 2024 · 5 comments · Fixed by Dasharo/dts-scripts#7 or Dasharo/meta-dts#118
Assignees
Labels
bug Something isn't working DasharoToolsSuite

Comments

@DaniilKl
Copy link
Contributor

DaniilKl commented Apr 11, 2024

Component

Dasharo Tools Suite

Device

other

Dasharo version

No response

Dasharo Tools Suite version

Commit 3870e7b944d88d68821d7cdd83d70d6959348ed8 in Dasharo/dts-scripts repo or DTS v1.2.21

Brief summary

Wrong DES are not completely discarted.

How reproducible

100%

How to reproduce

  1. Build launch DTS using versions specified above.
  2. Add some random strings in as DES using DTS UI.

Expected behavior

If DES verification failed bad DES should be cleared from /etc/cloud-pass (actually entire file should be deleted).

Actual behavior

DTS saves bad DES even after verification fail, so the DES will be showed by DTS UI.

Screenshots

image

Additional context

DTS is expected to clear bad DES while executing code from /usr/sbin/dts:

(...)
      check_se_creds
      if [ $? -eq 0 ]; then
         print_ok "Verification of the Dasharo DES was successful. They are valid and will be used."
      else
        echo -e "Something may be wrong with the DES credentials. Please use option 4 to change the DES keys
                  \rand make sure that there is no typo."
        rm ${SE_credential_file}
        export CLOUDSEND_LOGS_URL="$BASE_CLOUDSEND_LOGS_URL"
        export CLOUDSEND_PASSWORD="$BASE_CLOUDSEND_PASSWORD"
        unset CLOUDSEND_DOWNLOAD_URL
        unset DES_IS_LOGGED
      fi
      read -p "Press ENTER to continue."

But it seems that execution is being terminated by error_exit() somewhere in check_se_creds(), so code which is sopposed to clear bad DES is never being executed.

Solutions you've tried

No response

@WiktorG351
Copy link

WiktorG351 commented Apr 15, 2024

@DaniilKl added a pr that adresses this (edit: and made it target the right repo, the pr in question is now this one)

@DaniilKl
Copy link
Contributor Author

@WiktorG351, could you also bump SRCREV in dts-scripts_git.bb in Dasharo/meta-dts to the newest from Dasharo/dts-scripts?

@DaniilKl
Copy link
Contributor Author

Actuially, I think that using error_exit function to handle errors is prone to similar misunderstanding in other areas of DTS shell scripts, so it is better to change the way errors are being handled. @macpijan, what do you think? I see error_exit is being used in other functions, but I am not sure whether it could cause problems:

λ grep -r error_exit 
include/dts-functions.sh:error_exit() {
include/dts-functions.sh:  [ "$_error_code" -ne 0 ] && error_exit "$_error_msg : ($_error_code)"
include/dts-functions.sh:      error_exit "No supported chipset found, exit."
include/dts-functions.sh:    error_exit "There is no Dasharo Entry Subscription available for your platform!"
include/dts-functions.sh:      error_exit "Incorrect version format"
include/dts-functions.sh:        error_exit "Cancelling flashing process..."
include/dts-functions.sh:            error_exit "No update available for your machine"
include/dts-functions.sh:              error_exit "No update available for your machine"
include/dts-functions.sh:              error_exit "No update available for your machine"
include/dts-functions.sh:      error_exit "No update available for your machine"
scripts/cloud_list:error_exit() {
scripts/cloud_list:  [ "$_error_code" -ne 0 ] && error_exit "$_error_msg : ($_error_code)"
scripts/dasharo-deploy:[ -z "$SYSTEM_VENDOR" ] && error_exit "SYSTEM_VENDOR not given"
scripts/dasharo-deploy:[ -z "$SYSTEM_MODEL" ] && error_exit "SYSTEM_MODEL not given"
scripts/dasharo-deploy:          error_exit "Bad option or resignation. Returning to main menu..."
scripts/dasharo-deploy:          error_exit "Bad option. Returning to main menu..."
scripts/dasharo-deploy:      error_exit "Aborting update process..."
scripts/dasharo-deploy:        error_exit "Aborting update process..."
scripts/dasharo-deploy:      error_exit "Dasharo Firmware is already installed. This script is only for\r
scripts/dasharo-deploy:      error_exit "Dasharo Firmware is not installed. This script is only for\r
scripts/ec_transition:      error_exit "No network connection to 3mdeb cloud, please recheck Ethernet connection"
scripts/ec_transition:          error_exit "Board model $SYSTEM_MODEL is currently not supported"
scripts/ec_transition:      error_exit "Board vendor: $SYSTEM_VENDOR is currently not supported"
scripts/ec_transition:    error_exit "Device has already Open Source Embedded Controller firmware, aborting..."
scripts/ec_transition:[ -z "$SYSTEM_VENDOR" ] && error_exit "SYSTEM_VENDOR not given"
scripts/ec_transition:[ -z "$SYSTEM_MODEL" ] && error_exit "SYSTEM_MODEL not given"

@DaniilKl
Copy link
Contributor Author

@WiktorG351, I will bump revision in the recipe by myself.

@macpijan
Copy link
Contributor

macpijan commented Apr 18, 2024

@DaniilKl

Actuially, I think that using error_exit function to handle errors is prone to similar misunderstanding in other areas of DTS shell scripts, so it is better to change the way errors are being handled. @macpijan, what do you think?

Think of what? I cannot see a proposal on what we should change this to. Can you please elaborate what the problem is, and what the proposed solution is (if you have it in mind)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DasharoToolsSuite
Projects
None yet
4 participants