Plasma icon indicating copy to clipboard operation
Plasma copied to clipboard

Fix for plFileSystem not finding self on Mac

Open colincornaby opened this issue 3 years ago • 6 comments

The code as written should have worked - but Apple seems to have changed the way they do things. There are other reports of /proc/curproc/file disappearing from macOS. I'm not sure when that happened.

This code gets called as part of the patching process - which is why I wrote this change. Patching did not work without this change.

I defined a new implementation - but I realized this will only work if the current process is an app bundle. For a flat executable (like your command line patcher @dpogue), this probably isn't going to work. I'm open to other suggestions - this take is very AppKit centric.

colincornaby avatar Aug 09 '22 05:08 colincornaby

This returns the path to the bundle, so I'm guessing that's the .app "file" and not the actual executable within it?

dpogue avatar Aug 09 '22 05:08 dpogue

How cursed is _NSGetExecutablePath? https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html

dpogue avatar Aug 09 '22 05:08 dpogue

How cursed is _NSGetExecutablePath? https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html

Seems workable to me, I wasn't aware it existed.

I'm not sure if it should be the executable path or the bundle path in the case of the Mac client. That might be a question we're not ready for. In since Mac apps are folders that have to be replaced completely in order to not break code signing - we probably don't want the patcher crawling into the bundle. So we'd have to get the patcher to treat the bundle like it was a file, which might require some rethink and extensions to the patcher. I don't know if we could even do something fancy like store the app as a zipfile on the server and have the patcher decompress it into place.

colincornaby avatar Aug 09 '22 05:08 colincornaby

I'm not sure if it should be the executable path or the bundle path in the case of the Mac client.

It might make sense to use the bundle path if it's a bundle, and the executable path if not?

dpogue avatar Aug 09 '22 06:08 dpogue

I'm not sure if it should be the executable path or the bundle path in the case of the Mac client.

It might make sense to use the bundle path if it's a bundle, and the executable path if not?

That could be a good path forward. I can implement that. If it doesn't work out when it comes time to actually do patching of the Mac client that could always be changed.

colincornaby avatar Aug 09 '22 06:08 colincornaby

That sounds like a good path forward to me.

Hoikas avatar Aug 09 '22 22:08 Hoikas

I just remembered this one is still open. I'll get back around to implementing the changes.

colincornaby avatar Aug 16 '22 01:08 colincornaby

FYI - this code is no longer being called in the latest version of the Mac patcher. Likely because I've opted out of self patching. But that means it'll likely come back into use. I manually called the function for testing.

colincornaby avatar Aug 16 '22 02:08 colincornaby

Code suggestions have been applied. Waiting to see if they build on CI in since it's difficult for me to build these on Mac without a full client exercising things.

colincornaby avatar Aug 17 '22 01:08 colincornaby

@colincornaby It looks good to me - are you ready for a merge?

Hoikas avatar Aug 17 '22 21:08 Hoikas

Yep! This is ready for merge.

colincornaby avatar Aug 17 '22 23:08 colincornaby