Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Force permissions on files?

Force permissions on files?
Thread Tools
JLL
Professional Poster
Join Date: Apr 1999
Location: Copenhagen, Denmark
Status: Offline
Reply With Quote
Jul 21, 2003, 12:57 PM
 
We are running a server app that makes hires and lores images from original images, but the resulting files are written with 644 permissions (which is normal).

How do I force files written in certain directories to have different permissions?
JLL

- My opinions may have changed, but not the fact that I am right.
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Jul 21, 2003, 03:00 PM
 
You can't force it. However, you can set the umask (see umask in the man pages) which will set the default mask for the user creating the files.

If the files are being created by lots of different users, you could set up a cron job running every minute that fixed the permissions if they're incorrect. Alternately, start up a daemon process that does something similar (something like this):

Code:
#!/bin/sh dir="/uploads/" while [ true ]; do chmod -R 755 ${dir} sleep 60 done
Of course, you'd probably want to run something like that as root to avoid permissions issues.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Jul 23, 2003, 09:33 AM
 
Originally posted by Arkham_c:
You can't force it. However, you can set the umask (see umask in the man pages) which will set the default mask for the user creating the files.

If the files are being created by lots of different users, you could set up a cron job running every minute that fixed the permissions if they're incorrect. Alternately, start up a daemon process that does something similar (something like this):

Code:
#!/bin/sh dir="/uploads/" while [ true ]; do chmod -R 755 ${dir} sleep 60 done
Of course, you'd probably want to run something like that as root to avoid permissions issues.
Running something like that as root may fix the permissions errors, but would consitiute a security risk. Imagine someone being able to upload a file then know those permissions, then accessing it via the web or other to find a hole in your server. Its a possible entry point for hackers.
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Jul 26, 2003, 07:54 AM
 
This was copied from the macoshints forums:

Revise the ftp upload permissions in 10.2
_Mon, Sep 23 '02 at 08:54AM • from:
Anonymous
-----
For some reason in Mac OS X 10.2, the
default file permissions when uploading files via ftp
is set to 640. This results in the permission
"-rw-r-----". That is, the file can be read and
modified by the owner, read by those belonging to its
group, but others can't even read it. Naturally, this
causes problems when using ftp to upload files to a
web server.

In previous systems it defaulted to the more sensible
644, or "-rw-r--r--", which is also the system-wide
default. Apparently, ftpd does not follow the system's
UMASK setting. To change this for all users on the
machine you need to create a file in /etc/ called
ftpd.conf. In this file, add one line saying:
umask all 022
Save the file and restart the ftp server. This will
make uploaded files readable by all.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:20 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2