CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

Tool Permission fixer for Mac and Linux

5.00 star(s) 1 Vote

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,695
You download a new version of a game, go to run it, and it won't run. Ugh.

Archivers like WinRar and 7zip don't preserve Mac and Linux executable permissions, so if a game is compressed with one of them it won't run until the permissions are restored.

This script will fix those permissions for Mac games and for Linux Ren'Py games.

Usage:
Launch the script.
On a Mac, drag the app to the terminal window that opens up and hit enter.
On a Mac or Linux you can type or copy/paste the path to the game.
You can also run it from the command line with the path as the first argument.

The script will run chmod -x on:
  • Contents/MacOS recursively
  • *.sh
  • lib/linux-i686 recursively
  • lib/linux-x86_64 recursively

Thanks to @joel69 for the idea.

Linux users, if you have another game engine you want added, please let me know what directories/files to chmod.

You don't have permission to view the spoiler content. Log in or register now.
 

joel69

Newbie
Mar 30, 2018
15
13
thanks! i may have two suggestions
  • rename the thread to reflect that it fixes permissions for ren'py games, not games in general
  • instead of giving all the files in the lib/linux-* directories execution rights, give it solely to the executable file. you could do e.g. this:
Bash:
execfile=`basename -s .py "$appdir"/*.py`
#then, instead of e.g. chmod -R +x lib/linux-x86_64:
chmod u+x lib/linux-x86_64/"$execfile"
the example works based on the assumption that there is only 1 .py file in the appdir. i haven't seen any case where that wasn't true but exceptions are possible. a simple measure is to e.g. match the first few letters of the main executable file with those of the appdir, like so:
Bash:
execfile=`basename -s .py "$appdir"/${appdir:0:3}*.py`
it's not a foolproof measure but it may considerably reduce the risk of things going wrong. that said, there are more sophisticated ways of doing that.
 
  • Like
Reactions: MasterEggHead

MrBree

Member
Jun 9, 2017
171
157
This is a godsend, since the permissions problems are super annoying.

With a tiny bit more work, you probably can make this into a full fledged Mac app. I think Automator can manage Shell scripts. You can automate finding the file before hand, then run the script with the data.
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,695
thanks! i may have two suggestions
  • rename the thread to reflect that it fixes permissions for ren'py games, not games in general
  • instead of giving all the files in the lib/linux-* directories execution rights, give it solely to the executable file. you could do e.g. this:
Bash:
execfile=`basename -s .py "$appdir"/*.py`
#then, instead of e.g. chmod -R +x lib/linux-x86_64:
chmod u+x lib/linux-x86_64/"$execfile"
the example works based on the assumption that there is only 1 .py file in the appdir. i haven't seen any case where that wasn't true but exceptions are possible. a simple measure is to e.g. match the first few letters of the main executable file with those of the appdir, like so:
Bash:
execfile=`basename -s .py "$appdir"/${appdir:0:3}*.py`
it's not a foolproof measure but it may considerably reduce the risk of things going wrong. that said, there are more sophisticated ways of doing that.
It fixes permissions for any Mac app. Just Linux Ren'Py for now.

I went with everything in the lib directories because there are more than 1 executable. Ecchi Sensei Day 4 has EcchiSensei, python, pythonw, zsync, zsyncmake and a bunch of .so files. Not to mention lib and eggs subdirectories. I figured it was easier than trying to figure out which files really needed +x.
 
  • Like
Reactions: waffel and Phoeniix

MrBree

Member
Jun 9, 2017
171
157
It fixes permissions for any Mac app. Just Linux Ren'Py for now.

I went with everything in the lib directories because there are more than 1 executable. Ecchi Sensei Day 4 has EcchiSensei, python, pythonw, zsync, zsyncmake and a bunch of .so files. Not to mention lib and eggs subdirectories. I figured it was easier than trying to figure out which files really needed +x.
Permissions fix usually applies to just the 2 files with the app name. The python et al files seem to not require being fixed. (I can see that their file icon and thus permissions are wrong, but ignoring them usually doesn't hurt. )

I'm not familiar enough with Automator to make it fully work. But upon taking a look at it, it seems very doable. I just have to figure out how to tell it to open the folder for the app you give it. And yes, one line.

Screen Shot 2019-01-18 at 9.36.50 PM.png
 

_Sloth_

Newbie
Donor
Mar 9, 2018
31
73
Permissions fix usually applies to just the 2 files with the app name. The python et al files seem to not require being fixed. (I can see that their file icon and thus permissions are wrong, but ignoring them usually doesn't hurt. )

I'm not familiar enough with Automator to make it fully work. But upon taking a look at it, it seems very doable. I just have to figure out how to tell it to open the folder for the app you give it. And yes, one line.

View attachment 227300
Change "pass input" to "as argument".
Argument list is received in "$@".

I made an automator app that does the fix.
Simply unzip it and drag the .app misbehaving on "Fix RenPy.app".
You don't have permission to view the spoiler content. Log in or register now.
 

MrBree

Member
Jun 9, 2017
171
157
Change "pass input" to "as argument".
Argument list is received in "$@".

I made an automator app that does the fix.
Simply unzip it and drag the .app misbehaving on "Fix RenPy.app".
You don't have permission to view the spoiler content. Log in or register now.
Awesome. I knew I was missing something simple. I would change one thing though. As is, your app needs people to drag and drop to make it work. I added a finder search request (as I originally showed). That makes it easier to use. But you solved it when I couldn't so who am I to complain ;-)
 

picobyte

Active Member
Oct 20, 2017
638
708
Maybe it suffices to chmod only files with a shebang on line 1? i.e. in your Ren'py dir:
Bash:
grep -RIom1 '^.\?.\?' *|grep ':#!$'|cut -d: -f1|xargs -d "\n" chmod u+x
on macos sed may be called gnu-sed.
 

_Sloth_

Newbie
Donor
Mar 9, 2018
31
73
Maybe it suffices to chmod only files with a shebang on line 1? i.e. in your Ren'py dir:
Bash:
grep -RInom1 '^..' *|sed -n 's/:1:#!$//p'|xargs chmod u+x
on macos sed may be called gnu-sed.
You're right it's cleaner to only +x the files with a shebang :)
Bash:
find . -type f -exec grep -Il "#\!" {} \; | xargs chmod u+x
does the trick on macOS.
 

picobyte

Active Member
Oct 20, 2017
638
708
You're right it's cleaner to only +x the files with a shebang :)
Bash:
find . -type f -exec grep -Il "#\!" {} \; | xargs chmod u+x
does the trick on macOS.
The way you match the "#!" sequence can be present anywhere in the file for a match, so you're likely to chmod too many files.

My intent was to make sure only the first line(s) were read:
-m1: stop after the first match
-R recurse directories
-o: return only the match
-I: ignore binary files
matching '^..' should match if the first line consisting of at least 2 characters - actually I changed this to also match if less than 2 characters are present. Mismatches are filtered in the second part, that checks whether we actually observed the shebang. The sed functioned also to only return the filename, now cut does this keeps up to the colon. Finally I changed xargs (-d "\n") to make sure whitespace in filenames is not an issue anymore.

Probably way to elaborate explanation.
 

_Sloth_

Newbie
Donor
Mar 9, 2018
31
73
The way you match the "#!" sequence can be present anywhere in the file for a match, so you're likely to chmod too many files.

My intent was to make sure only the first line(s) were read:
-m1: stop after the first match
-R recurse directories
-o: return only the match
-I: ignore binary files
matching '^..' should match if the first line consisting of at least 2 characters - actually I changed this to also match if less than 2 characters are present. Mismatches are filtered in the second part, that checks whether we actually observed the shebang. The sed functioned also to only return the filename, now cut does this keeps up to the colon. Finally I changed xargs (-d "\n") to make sure whitespace in filenames is not an issue anymore.

Probably way to elaborate explanation.
You're totally right.

I think it would actually be best to not grep the content of any file at all. The script missing execution always has the same name as the ".app" directory (on macOS) so something like:
Bash:
find . | grep `basename $PWD | sed 's/.app//'`$ | xargs chmod u+x
would not need to read any file.
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,695
You're totally right.

I think it would actually be best to not grep the content of any file at all. The script missing execution always has the same name as the ".app" directory (on macOS) so something like:
Bash:
find . | grep `basename $PWD | sed 's/.app//'`$ | xargs chmod u+x
would not need to read any file.
The problem isn't just a script missing the executable bit; it could be python or an actual binary executable.
 

picobyte

Active Member
Oct 20, 2017
638
708
On linux the `file' command could indicate whether it's an executable. Maybe something like this?

Bash:
find * -type f -exec file -i {} \+|grep executable|cut -d: -f1|xargs -d "\n" chmod u+x
 
May 16, 2017
74
41
You download a new version of a game, go to run it, and it won't run. Ugh.

Archivers like WinRar and 7zip don't preserve Mac and Linux executable permissions, so if a game is compressed with one of them it won't run until the permissions are restored.

This script will fix those permissions for Mac games and for Linux Ren'Py games.

Usage:
Launch the script.
On a Mac, drag the app to the terminal window that opens up and hit enter.
On a Mac or Linux you can type or copy/paste the path to the game.
You can also run it from the command line with the path as the first argument.

The script will run chmod -x on:
  • Contents/MacOS recursively
  • *.sh
  • lib/linux-i686 recursively
  • lib/linux-x86_64 recursively

Thanks to @joel69 for the idea.

Linux users, if you have another game engine you want added, please let me know what directories/files to chmod.

You don't have permission to view the spoiler content. Log in or register now.
Hi i have a problem where the script says cant find the file and then it jumps straight to logout. have any solution??
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,695
Hi i have a problem where the script says cant find the file and then it jumps straight to logout. have any solution??
Tell me exactly how you launched it and told it to find the game, and give me the exact error message.

Go into detail - remember, I can't see what you're doing on your machine! :)
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,695

taler

Well-Known Member
Oct 5, 2017
1,626
1,248
Thanks got
com.apple.quarantine: 0181;5dd0843d;Chrome;FDA2E7C6-5947-4006-B0FD-2857C850A2D7

Ran the next thing as instructed but still the same cannot be opened. Thanks for your help.
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,695
Thanks got
com.apple.quarantine: 0181;5dd0843d;Chrome;FDA2E7C6-5947-4006-B0FD-2857C850A2D7

Ran the next thing as instructed but still the same cannot be opened. Thanks for your help.
run the xattr -l again. Is the quarantine still there?

What happens when you run
open <app>
from Terminal?
 
5.00 star(s) 1 Vote