OpenTTD-patches icon indicating copy to clipboard operation
OpenTTD-patches copied to clipboard

OpenTTD keeps asking for documents permission upon opening

Open unbeatable-101 opened this issue 3 years ago • 24 comments

Version of OpenTTD

v0.42.3, macOS 12.0 Beta (21A5506j)

Expected result

You give the permission once

Actual result

It keeps asking and never stops

Steps to reproduce

Open OpenTTD on macOS, (Might need to do it on the beta)

unbeatable-101 avatar Sep 06 '21 20:09 unbeatable-101

https://ipfs.io/ipfs/QmS2wqbnfRsF4EnF6x9VeqiRjQ5warjAj3x2DtexF7ZkEi?filename=Screen%20Recording%202021-09-06%20at%2016.09.02.tar.gz

unbeatable-101 avatar Sep 06 '21 20:09 unbeatable-101

Unfortunately I don't have access to any devices running macos at the moment. Does this also occur in non-beta versions of macos, or in vanilla OpenTTD?

JGRennison avatar Sep 11 '21 23:09 JGRennison

It does not occur in vanilla OpenTTD, ~~and I can't test on a non-beta macos now, but I probably can tomorrow~~ Nevermind, I'll just use VNC

unbeatable-101 avatar Sep 12 '21 01:09 unbeatable-101

There is no repeated prompt on macOS 10.15

unbeatable-101 avatar Sep 13 '21 23:09 unbeatable-101

Now it only asks twice upon each launch, which is good enough for me

unbeatable-101 avatar Oct 15 '21 02:10 unbeatable-101

Oddly enough, starting the game using the OpenTTD binary (/Applications/OpenTTD.app/Contents/MacOS/openttd) doesn't make the dialogue pop up.

Now it only asks twice upon each launch, which is good enough for me

Also it is actually random

unbeatable-101 avatar Oct 19 '21 15:10 unbeatable-101

When I launch the binary directly from the terminal it generates no permissions prompts whatsoever.

I know this probably isn't much help, but I tried slipping the JGR executable into a vanilla app bundle. It still generated the same permissions spam, unfortunately.

As an interim solution, you can write a one-line script that executes the binary directly and just double-click that to play. Though it will generate a terminal window that you have to close afterwards.

I'm running macOS 12.0.1 (arm64)

darrenrhs avatar Nov 28 '21 22:11 darrenrhs

Does the app need notarised?

(Might be a red herring, I didn't keep up with what Gatekeeper etc want per macOS version).

andythenorth avatar Nov 28 '21 23:11 andythenorth

Actually, yeah. Why didn't I think of that?

You get this prompt on a fresh install:

"OpenTTD.app" cannot be opened because the developer cannot be verified.

darrenrhs avatar Nov 29 '21 01:11 darrenrhs

@darrenrhs @andythenorth I doubt that is the issue, as you can completely get rid of that alert before even running it by running xattr -c /Applications/OpenTTD.app

unbeatable-101 avatar Nov 29 '21 04:11 unbeatable-101

Hmm. I could go look what was done for the vanilla client. I believe that is notarised and builds an application bundle (packaged app), but I'm out of my depth with those questions

I usually just run vanilla self-compiled from terminal. I haven't built JGRPP for a while, but I'll try compiling it later maybe :)

andythenorth avatar Nov 29 '21 20:11 andythenorth

Last time I built JGRPP was x86 on a different Mac, which has been migrated to an m1.

I just pulled for my pre-existing JGRPP checkout, rm-ed the existing build folder, and re-compiled from scratch (m1, Monterey 12.0.1, XCode toolchain; seems to produce a native arm build with no further intervention).

I don't get any Gatekeeper warnings for the openttd executable, nor any warnings about accessing e.g. ~/Documents. I may have pre-existing authorisations for Gatekeeper, but the Mac hardware, OS, architecture and XCode version have all changed since the last JGRPP build. Sorry this gives no further insight to the problem :(

andythenorth avatar Nov 29 '21 20:11 andythenorth

I confirm the bug. I started experiencing it after I moved from Intel to Apple silicon. Vanilla OpenTTD works fine even with Apple silicon.

Version 0.44.2 (downloaded as .dmg) macOS Monterey (12.0.1) Apple M1 Pro Silicon

vladoschreiner avatar Dec 12 '21 19:12 vladoschreiner

I confirm the bug. I started experiencing it after I moved from Intel to Apple silicon. Vanilla OpenTTD works fine even with Apple silicon.

Is anybody on x86 having this issue, or is it just arm64?

darrenrhs avatar Dec 12 '21 21:12 darrenrhs

@darrenrhs @andythenorth I doubt that is the issue, as you can completely get rid of that alert before even running it by running xattr -c /Applications/OpenTTD.app

or if you want to be specific, you can do xattr -r -d com.apple.quarantine /Applications/OpenTTD.app

also just wanted to add another monterey (12.1)/m1 max/0.44.2 user with this issue. the dialog also pops up when connecting to a multiplayer server and periodically while connected. I think (but I'm not entirely sure) that if you wait too long to grant permission in the latter case, you'll desync from the server as well

HotelCalifornia avatar Dec 29 '21 16:12 HotelCalifornia

It's been over 7 months since this issue was reported and it's still happening on the latest stable version of Mac OS (12.3.1) as well as the latest stable version of OpenTTD JGR (v0.47.1). At this point, I spend about 5 minutes dismissing a few hundred warnings each time I want to play the game. The two workaround commands mentioned do not make a difference. None of this happens with the vanilla OpenTTD builds.

What can I do or provide to help you debug and hopefully fix this?

ozupey avatar Apr 24 '22 17:04 ozupey

At this point, I spend about 5 minutes dismissing a few hundred warnings each time I want to play the game

Do you get fewer warnings when you start OpenTTD-jgrpp with no preexisting openttd folder inside your documents folder? (You can rename any existing openttd folder in your documents folder to something different but related to preserve the contents inside but temporarily make it invisible to the openttd process)

James103 avatar Apr 24 '22 17:04 James103

Do you get fewer warnings when you start OpenTTD-jgrpp with no preexisting openttd folder inside your documents folder?

Yes, there are a lot less, only about 5. But any activity involving the disk (e.g. downloading online content) causes 10-20 more prompts. If I then quit and re-open the game a few times it seems to add more and more prompts to the point of it becoming unplayable.

ozupey avatar Apr 24 '22 17:04 ozupey

It's been over 7 months since this issue was reported and it's still happening on the latest stable version of Mac OS (12.3.1) as well as the latest stable version of OpenTTD JGR (v0.47.1). At this point, I spend about 5 minutes dismissing a few hundred warnings each time I want to play the game. The two workaround commands mentioned do not make a difference. None of this happens with the vanilla OpenTTD builds.

What can I do or provide to help you debug and hopefully fix this?

There's not a lot I can do about problems created by Apple which only exist on Apple platforms.

JGRennison avatar Apr 24 '22 19:04 JGRennison

There's not a lot I can do about problems created by Apple which only exist on Apple platforms.

Seeing as the vanilla game runs perfectly fine on the exact same platform, I think there is something that can be done.

I do understand it can be difficult though, especially since it's a less popular platform and you don't have a device to test it on, which is why I asked what I can provide to help debug this. :)

ozupey avatar Apr 24 '22 19:04 ozupey

Are you still able to reproduce this issue? If so, can you please attach a screenshot of the prompt you're getting?

It should say something along the lines of "OpenTTD would like to access files in your Documents folder. [Don't Allow] [OK]"

James103 avatar May 08 '22 17:05 James103

Here is a video of it happening

https://user-images.githubusercontent.com/58151048/167321569-5eec8121-6680-412f-93fa-3bae9a25db30.mp4

unbeatable-101 avatar May 09 '22 00:05 unbeatable-101

I found an identical issue with qBittorrent here. They alleviated the issue by issuing the following command in a terminal:

codesign -s - --deep PATH_TO_APP

For most users here this would be:

codesign -s - --deep /Applications/OpenTTD.app

After this, you should only be prompted once and never again.

Please note that this does not "resolve" this bug as it continues to ship in the current build and is not intended behaviour.

It is also not a command that users should be using routinely or blindly because it is a circumvention of system security. It essentially allows the user to "ad-hoc" sign code, which if you do not trust the code in question you should not be doing. The command in question signs recursively into the app folder, so any bundled code gets signed as well.

darrenrhs avatar May 27 '22 13:05 darrenrhs

I found an identical issue with qBittorrent here. They alleviated the issue by issuing the following command in a terminal:

codesign -s - --deep PATH_TO_APP

For most users here this would be:

codesign -s - --deep /Applications/OpenTTD.app

After this, you should only be prompted once and never again.

Please note that this does not "resolve" this bug as it continues to ship in the current build and is not intended behaviour.

It is also not a command that users should be using routinely or blindly because it is a circumvention of system security. It essentially allows the user to "ad-hoc" sign code, which if you do not trust the code in question you should not be doing. The command in question signs recursively into the app folder, so any bundled code gets signed as well.

This did the trick! Thank you so much. While still "unresolved", I find this an acceptable workaround for my own purposes. Also FWIW, I just encountered this problem today so... timely!

the-tzar avatar May 28 '22 23:05 the-tzar