Skip to content

Crash on failed write when updating. #981

Open
@Reginald-Gillespie

Description

@Reginald-Gillespie

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions