Skip to content

Logical bugs when executing scripts #766

@jonathanschaaij

Description

@jonathanschaaij

The following bugs can be found in src/adu-shell/src/script_tasks.cpp in the Execute function on line 32.

Expected Behavior

  • Don't execute file if the file is not found.
  • Properly restore previous permissions if the permissions were changed.

Current Behavior

  • If the file is not found the file is still executed (Which logs more difficult errors to debug)
  • It never restores the previous owners or permissions.

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.

  1. Run an update agent without a component enumerator
  2. Deploy a proxy update with a nested swupdate with a custom script.

This results in the following:

  1. The script is successfully downloaded inside a sandbox directory
  2. The script has its permission changed to execute the first time.
  3. The 'isInstalled' action is successfully executed in the script -> Returns NOT INSTALLED
  4. The downlaod-script function is called for the Install Step
  5. The hash can not be validated because of wrongly restored filepermissions
  6. The file is deleted -> Issue Download function returns SUCCESS after deleting file it should have downloaded. #765
  7. The file is still executed even though it no longer exists

Logical mistakes in the code:

  • The files details are read

  • If the file detaisl could not be read it immediately tries to execute the code, which will fail. It should log a FileNotFound error

  • If the file is found it changes the permissions, but ONLY sets the filePermissionsChanged boolean if setting the permissions has failed. -> Therefore won't attempt to restore the old permissions.

  • Even if it would attempt to restore the permissions, it would not apply the old permissions, but it would reapply the new permission completely defeating the purpose of the 'restore'

Overall, it seems like this code has never been reviewed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions