FreeBSD chown and chmod

Posted by epistasis
Jan 28 2009

Problem: I was recently trying to use chmod and chown in PHP on a FreeBSD system. I found out that these two commands (for obvious) reasons, can only be used by the superuser, therefore I couldn’t change the owner of an uploaded file (via a website) from the www to the user who’s website it was. In Solaris you can just change rstchown to 0 in /etc/system – unfortunately I couldn’t find a similar way to do this in FreeBSD.

Solution: The main solution I have found to this is to just use a cron job as root to chown all the files  (by using an asterisk in the file path) in a certain directory (the upload directory) to the user.. This is also a lot safer than allowing other users to use chmod/chown.

Obviously, if anyone can think of a better way of doing this, please let me know.

You must be logged in to post a comment.

Trackback URL for this entry