Setuid and setgid and similar settings

so im writing a script for a android system. these types of systems are not the typical unix systems.

what i need to do is basic. i have a script which I put in a directory and then zipped up the directory in a zip file. that way, when the script is unzipped, the person unzipping will see this:

unzip myscript.zip
Archive: myscript.zip
     inflating: MyScript/myscript.sh

now, when i take that zip file to a android system and i unzip it, the directory (MyScript) of the script in the zip file and the script itself (myscript.sh) loses their read and execute permissions which was assigned to them when they were zipped on the other system.

why is this happening?

first conclusion was to look into the permissions of the directory on the android system where the zip file is being unzipped.

when i do that, i see this:

drwsrwsrwt

The directory that is created from the zipped file has these permissions:

drwx--S---

now, ive searched online for info on setuid and setgid but the explanations i come across and the real life application of them dont seem to work out for me.

what i basically want to do is have my script retain all of its original permissions whenever it is unzipped on any system.

the MyScript directory, after it is unzipped should have this:

drwxrwxrwx

and the script inside it should have:

-rwxrwxrwx

I have the opposite problem - to accommodate the format's lack of permissions handling, when I extract a zip, it usually turns everything executable, just in case. This is because ZIP files, originating in MS-DOS, cannot encode executable bits... or permissions... or owners... Or really anything.

Use TAR if you expect permissions to be respected.

1 Like