-
Notifications
You must be signed in to change notification settings - Fork 46
Description
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.
- Run an update agent without a component enumerator
- Deploy a proxy update with a nested swupdate with a custom script.
This results in the following:
- The script is successfully downloaded inside a sandbox directory
- The script has its permission changed to execute the first time.
- The 'isInstalled' action is successfully executed in the script -> Returns NOT INSTALLED
- The downlaod-script function is called for the Install Step
- The hash can not be validated because of wrongly restored filepermissions
- The file is deleted -> Issue Download function returns SUCCESS after deleting file it should have downloaded. #765
- 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.