immense / Remotely

A remote control and remote scripting solution, built with .NET 8, Blazor, and SignalR.
GNU General Public License v3.0
4.28k stars 1.6k forks source link

Agent installer script failing on Mac (maybe apple silicon related?) #855

Open callumgare opened 3 months ago

callumgare commented 3 months ago

Describe the bug A number of issues occur when attempting to run the arm mac agent installer script, the most grave seeming to be the system immediately killing the agent due to unsigned code.

To Reproduce Steps to reproduce the behavior:

  1. On an apple silicon mac download and run the macOS arm64 Bash Installer from the downloads page.
  2. Observe a number of error including:
    • su: illegal option -- c (occurs on the second run of the installer)\ This appears to occur because $Owner is not set and $Owner is not set because the brew binary is not installed at /usr/local/bin/brew for apple silicon macs (https://github.com/Homebrew/install/blob/aceed88a4a062e2b41dc40a7428c71309fce14c9/install.sh#L154). A couple of suggestions to help with this, firstly adding set -e would help a lot in terms of making it clearer where the source of an issue is rather than having bash continue on blindly after ls fails and then dying later on down the line about something seemingly unrelated (I find http://redsymbol.net/articles/unofficial-bash-strict-mode/ to be quite helpful). Wrapping $Owner in quotes would also help since if $Owner is not set "$Owner" will still be given to su as an argument (an empty string) rather than having that argument excluded all together thus causing su to think the next argument (-c) is an argument for su which doesn't have a -c flag, hence the error. (I find ShellCheck very helpful for catching these sorts of things.) \ But for fixing the actual issue of brew living at a different path when installed on arm macs I think it might be easiest to use $(which brew) rather than hardcoding the path to the brew binary.
    • chmod: /usr/local/bin/Remotely/Desktop/Remotely_Desktop: No such file or directory\ The unzipped Remotely-MacOS-arm64.zip file doesn't include Desktop/Remotely_Desktop so chmod throws an error when trying to make a file at that path executable.
    • Bootstrap failed: 5: Input/output error\ When trying to run sudo launchctl bootstrap system /Library/LaunchDaemons/remotely-agent.plist this error is thrown. I'm not entirely sure why but I when I run the program which that launchd plist is attempting to start (/usr/local/bin/Remotely/Remotely_Agent) the system seems to immediately SIGKIL the process.
      bash-5.2$ /usr/local/bin/Remotely/Remotely_Agent
      Killed: 9

      And looking at console.app it seems to be due to a code-signing issue:

      AMFI: hook..execve() killing pid 96044: Attempt to execute completely unsigned code (must be at least ad-hoc signed).
      ASP: Security policy would not allow process: 96044, /usr/local/bin/Remotely/Remotely_Agent

I didn't have the capacity to debug further but I thought I'd at least report the issue and hopefully someone else will have the time fix it.

Remotely Version Server: 2024.02.23.1927 Agent: N/A

Expected Behavior The agent installer to complete successfully

Additional Details Also not major thing but might be nice if the script actually checked to see if brew, curl and jq is already installed first before blindly attempting to install again. I have all 3 installed already so I was initially a bit confused why I was greeted with this the first time I tried to run the agent installer script:

==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew

Press RETURN/ENTER to continue or any other key to abort:

Desktop Details:

matthew-on-git commented 3 weeks ago

Do you have the .zip? On my install using the latest docker, I don't have them https://github.com/immense/Remotely/issues/808 There's a comment they were added in the latest, so I'm trying to figure out what I'm missing on my docker compose file now. Maybe the latest doesn't have them again...?

luciandf commented 1 week ago

i have the same problems from the last two bullet points you listed. my mac is a mini from 2012 with sonoma I think. I am not a mac guy, I just got it to try to instegrate some airtags with homeassistant and that's about it. was thinking of monitoring the mac with this remote desktop solution.