Running Wine as OSX app and file permissions

Questions about Wine on macOS.
Locked
jwong
Level 2
Level 2
Posts: 27
Joined: Thu Feb 17, 2011 4:58 pm

Running Wine as OSX app and file permissions

Post by jwong »

I've created a notepad.app wrapper which runs the notepad application included with Wine. If I run Wine from the Terminal (ex. 'wine64 notepad'), everything works fine. But if I click/run my notepad.app from the Finder window, I don't see any files on my system when using the common file Open dialog. I see folders but not the files.

I've gone into System Preferences->Security & Privacy->Privacy->Full Disk Access and added my notepad wrapper to the list, but that didn't change anything.

Something about starting my wrapper interactively is limiting its file access/permssion but runninng via command does not.

How do I go about granting access to my wrapper?

Note, I am using Catalina. I was not able to check if the problem existed prior to Catalina.
The_SamminAter
Level 3
Level 3
Posts: 52
Joined: Sun Sep 09, 2018 6:16 pm

Re: Running Wine as OSX app and file permissions

Post by The_SamminAter »

You can't run any non-fully 64 bit exes in macOS 10.15 (Catalina). That aside, you can create a text file with no extension, that contains this (or a variant of this):

#!/bin/bash
/Applications/Wine\ Devel.app/Contents/Resources/wine/bin/notepad
killall Terminal
Gcenx
Level 6
Level 6
Posts: 709
Joined: Mon Dec 25, 2017 12:11 pm

Re: Running Wine as OSX app and file permissions

Post by Gcenx »

@jwong You said wrapper? If your using my updated version of Wineskin it’s not going to work properly as it’s not notarized nor does it pass permissions from the wrapper onto wine processes.

@The_SamminAter the notepad within /bin is just a bash script, it would be better to use

killall wine64-preloader
Or if the wineprrfix is mapped then using
wineserver -k
That usually shuts down the current wine precedes within the currently launched prefix
jwong
Level 2
Level 2
Posts: 27
Joined: Thu Feb 17, 2011 4:58 pm

Re: Running Wine as OSX app and file permissions

Post by jwong »

By wrapper I meant an OSX application bundle. I therefore created an application called notepad.app. The idea was to create a native OSX 'application' that would simply run Wine's version of Notepad.

In it, I placed the 64 bit Wine binaries that I compiled and built from the Wine source (so I am not using Wineskin).

The issue is if I click my notepad.app icon, notepad runs, but if I select file->open, no files are listed in dialog regardless of the file type and the directory. Directories however are listed which means I can navigate the hard drive. Basically, the dialog will only list directories and not files.

If on the other hand, I use Terminal.app (ie. unix shell), run 'wine64 notepad ' and then select file->open, the files are listed in the dialog.

So something about running via an OSX application bundle is stopping notepad from seeing the files on my system.
Gcenx
Level 6
Level 6
Posts: 709
Joined: Mon Dec 25, 2017 12:11 pm

Re: Running Wine as OSX app and file permissions

Post by Gcenx »

If that’s the case you should provide more information on how your launching wine from within the bundle you created as it can be done multiple different ways.

Catalina has a lot of gatekeeper restrictions I’ve got an open issue from someone running Catalina who is experiencing issues.


Depending how you compiled wine64 could have also affected how it functions, I’ve only briefly updated the macOS wiki building section it’s still rather lacking.
adamAC
Level 2
Level 2
Posts: 30
Joined: Mon Jun 22, 2020 9:56 am

Re: Running Wine as OSX app and file permissions

Post by adamAC »

Is there any update from anyone regarding this as I have exactly the same situation?

I have a Mac app bundle which contains Wine (64-bit only) and my Windows app. Running it from a command line works fine and you can see all files and folders but running the app directly will not shows files or folders in certain locations. This is obviously a permissions issue in Catalina but I cannot get to the bottom of it. It all works perfectly fine in Mojave, by the way.

So, my Mac app bundle is structured thusly:

Code: Select all

MacApp.app
- Contents
  |- Info.plist
  |- MacOS
  |  - MacAppBashScript
  |- Resources
    |- MacAppIcons.icns
    |- wine-home
    |  - usr
    |    |- bin
    |    |- include
    |    |- lib64
    |    |- share
    |- wine-prefix
The MacAppBashScript should execute when launching the app directly. Inside the script looks like this:

Code: Select all

#!/bin/sh

ROOT="$(cd "$(dirname "$0")" && pwd)"

RESOURCES="$ROOT/../Resources"

export WINEPREFIX="$RESOURCES/wine-prefix"
export WINEARCH="win64"
export LC_ALL="en_US.UTF-8"

APP='c:\Program Files\company/product/product.exe'
LAUNCHER="$RESOURCES/launcher.scpt"
WINE="$RESOURCES/wine-home/usr/bin/wine64"

if [ -f "$LAUNCHER" ]; then
  APP="$(osascript "$LAUNCHER")"
fi

f [ -n "$APP" ]; then
  if [ "${APP/\\}" = "$APP" ]; then
    "$WINE" "$APP"
  else
    WINEPATH="$RESOURCES/wine-home/usr/bin/winepath"
    APP="$("$WINEPATH" "$APP")"
    cd "$(dirname "$APP")"
    "$WINE" "$(basename "$APP")"
  fi
fi
Things I have tried to no avail:
  • Add the Mac app bundle to Full Disk Access
  • Add the MacAppBashScript to Full Disk Access
  • Add the wine64 binary to Full Disk Access
  • Removed the CFBundleSignature from the Info.plist file
  • Added CFBundleIdentifier to Info.plist file
adamAC
Level 2
Level 2
Posts: 30
Joined: Mon Jun 22, 2020 9:56 am

Re: Running Wine as OSX app and file permissions

Post by adamAC »

I have just read on https://github.com/Gcenx/WineskinServer/issues/23 that:
Apple now requires applications outside of the AppStore to be Signed & Notarized to function seamlessly.
Is this correct, as this would explain why I am having so much bad luck with this?

If we do need to do this, what elements of the Mac app need signing?

Can a Mac app with Wine inside (including the changing prefix) be notarized?

I have just read that Mac apps need "hardening" before they can be notarized. Is this correct?

Is there a way around all this to simply test your app on Catalina?
Gcenx
Level 6
Level 6
Posts: 709
Joined: Mon Dec 25, 2017 12:11 pm

Re: Running Wine as OSX app and file permissions

Post by Gcenx »

adamAC wrote: Mon Jul 20, 2020 8:12 am I have just read on https://github.com/Gcenx/WineskinServer/issues/23 that:
Apple now requires applications outside of the AppStore to be Signed & Notarized to function seamlessly.
Is this correct, as this would explain why I am having so much bad luck with this?

If we do need to do this, what elements of the Mac app need signing?

Can a Mac app with Wine inside (including the changing prefix) be notarized?

I have just read that Mac apps need "hardening" before they can be notarized. Is this correct?

Is there a way around all this to simply test your app on Catalina?
Apples official stance is that any app distributed outside of there App Store needs to be code-signed and notarized.

In practice that’s not entirely true, the most recent published wrapper beta I’d provided is not code-signed/notarized but does request the desired permissions, however an newer issues was opened stating the wrapper is unable to interact with iCloud stored documents/desktop due to it not being code-signed & notarized.

Self modifying app bundles code-signature won’t be valid once anything changes within the bundle
Locked