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

Crash on failed write when updating. #981

Open
Reginald-Gillespie opened this issue Jul 31, 2024 · 0 comments
Open

Crash on failed write when updating. #981

Reginald-Gillespie opened this issue Jul 31, 2024 · 0 comments
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Milestone

Comments

@Reginald-Gillespie
Copy link

Reginald-Gillespie commented Jul 31, 2024

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:

...
 } else if restartPath := updater.Start(src); restartPath != "" {
		 	Systray.RestartWith(restartPath)
...

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

@Reginald-Gillespie Reginald-Gillespie added the type: imperfection Perceived defect in any part of project label Jul 31, 2024
@per1234 per1234 added the topic: code Related to content of the project itself label Aug 3, 2024
@Xayton Xayton added this to the next milestone Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants