Security Question

This is a discussion on Security Question within the PHP General forums, part of the PHP Programming Forums category; Does anyone know a good way to protect a directory that a php script NEEDS to write too? What I'...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-17-2007
Andrew Peterson
 
Posts: n/a
Default Security Question

Does anyone know a good way to protect a directory that a php script NEEDS
to write too?

What I'm doing now:

1. create a directory manually "myDir"
2. chmod 777 myDir
3. password protect the directory with htaccess

Is this the best way, or is there something better?

Also, is there a way to mkdir or fopen a file dynamically, without
pre-creating a directory with 777 permissions?

Thanks for the help,
Andrew

Reply With Quote
  #2 (permalink)  
Old 10-17-2007
Richard Heyes
 
Posts: n/a
Default Re: [PHP] Security Question

> Does anyone know a good way to protect a directory that a php script NEEDS
> to write too?
>
> What I'm doing now:
>
> 1. create a directory manually "myDir"
> 2. chmod 777 myDir
> 3. password protect the directory with htaccess
>
> Is this the best way, or is there something better?


You could chmod the file/directory to 700 and change the owner to that
of the webserver (presumably the script is being run via the webserver).
This has the drawback that anything run from the webserver will have
write access to the files.

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support
Reply With Quote
  #3 (permalink)  
Old 10-17-2007
Jim Lucas
 
Posts: n/a
Default Re: [PHP] Security Question

Andrew Peterson wrote:
> Does anyone know a good way to protect a directory that a php script NEEDS
> to write too?
>
> What I'm doing now:
>
> 1. create a directory manually "myDir"
> 2. chmod 777 myDir
> 3. password protect the directory with htaccess
>
> Is this the best way, or is there something better?
>
> Also, is there a way to mkdir or fopen a file dynamically, without
> pre-creating a directory with 777 permissions?
>
> Thanks for the help,
> Andrew
>

Along with what Richard said, you could also move the directory outside of the webroot and not have
to worry about the .htaccess file. Nothing but PHP could access the directory contents, and only
through your interface could it be access.

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:51 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0