Crash on failed write when updating. #981
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
Milestone
Describe the problem
On windows when the code checks for updates, it always attempts to clone itself to the file "arduino-cloud-agent.exe-temp". However, if the ACA is inside a location such as
C:\Program Files
, it requires administrator perms to write new files or modify existing ones. This causes it to crash when it is not run as administrator under these conditions.To reproduce
Compile the exe, create a folder inside
C:\Program Files
, move the exe to that folder, attempt to run it without adminstrator permissions (I suggest doing this from powershell so that you can see the printed output saying access was denied to write to the .exe-temp file). Run it as admin, it creates the file and then runs perfectly.I found the issue originates in the update code, and I commented out these lines of
main.go
:After compiling it like this, it starts as a non-admin perfectly (not to say it shouldn't update, just to show that is where the issue lies).
Expected behavior
There are a few things that should be changed, imo. First, this issue still happens if you comment out the
updateUrl
in the config file. In general just as a matter of optimization, it should skip the update code entirely if this is not defined.The second thing I would do is before attempting an update, request administrator privileges. Some sort of modal popup that says it would like to update is ideal so users know why it needs admin perms, but not necessary. If these perms are denied, catch this and skip the update.
Arduino Create Agent version
Compiled from source 10 minutes ago
Operating system
Windows 11
The text was updated successfully, but these errors were encountered: