Tutorial :how do I set default permissions when copying a file from Windows -> OSX



Question:

I am developing a ruby on rails app on OSX and I am logged in as an admin user.

On my Windows box I am creating my images, but every time I copy them to the OSX box, the permissions are weak (understandably I guess).

So per photo I keep having to right click, info and give everyone permissions to read and write, or my web server wont serve em up.

What is the easiest solution? an Applescript to auto give it full permission? is there a setting perhaps cause it's annoying to do it 25 times a day.

and yes I can use the shell with a chmod, but that's still annoying.


Solution:1

Each process on Unix-like systems has a field called "umask" that controls the default permissions. It's normally octal 0022, which means deny write permission to group and other. If you're using a Terminal window to copy over your files, try typing

umask 0000  

beforehand. Alternatively, leave a Terminal window open with the following bash command running:

while true; do chmod 0666 *; sleep 1; done  


Solution:2

If all of the images are going into the same directory, you could add an inheritable access control list (ACL) to the directory; then any files (i.e. the images) copied into it would get that ACL automatically. Set this up with something like:

chmod +a "group:_www allow read,write,readattr,writeattr,file_inherit" /path/to/imagedir  

Note that you may have to play around with the access to get the web server everything it needs. e.g. if it needs to read/write extended attributes, delete files, etc you'll need to add the appropriate permissions to the ACL. Similarly, if you need it to inherit to files added to subdirectories as well, you'll need to add more types of inheritance (and maybe recreate the subdirs so they pick up the change). Also, I'm assuming this is the standard OS X 10.5 Apache install, running as the _www user, which is a member of the _www group; if not, adjust accordingly. See the man page for chmod for details.


Solution:3

If you are copying many files/dirs, pack them in a zip in windows, and decompress it in mac. The files extracted will have proper permissions (at least, works with unarchiver)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »