theCAT
  
Report a Problem:
Email: support@cat.pdx.edu
Phone: 503-725-5420
  USERS PLATFORMS SYSTEM RESOURCES    
Home Students Fac/Staff CS Tutors Guidelines Windows Linux Unix Mac Mail Network Software Web TheCAT Sitemap
arrowHome arrow Web arrow Writing to Files With PHP Saturday, 21 November 2009  
Web
Writing to Files With PHP Print
Written by Kim Howard   
Tuesday, 13 September 2005

How Do I Let PHP Scripts Write To Files Without Making Them World Writable?

The webserver runs as user www, as will your php scripts.
You can give just user www permission to write to a file or direcotory using extended acls (access control lists).

This will give www write perms to a file:

setfacl -r -m user:www:rwx filename

To see what extended perms are on the file, you can use the command:

getfacl filename

You'll see a list like this

# file: dispatch.file
# owner: kim
# group: them
user::rwx
user:www:rwx #effective:rw-
group::r-- #effective:r--
mask:rw-
other:---

The webserver can then write to the file.
(But so can everyone else running a php script, because their scripts will also run as user www!!) But regular users should not be able to write to it.

You can use the same commands on a directory.
Check the setfacl and getfacl man pages for more info.
Last Updated ( Tuesday, 13 September 2005 )
Looking out the window from EB502J
Looking out the window from EB502J
Upcoming Events
There are no upcoming events currently scheduled.
View Full Calendar

©1999 - 2009 TheCAT