Search Webmaster Help and Solution

PHP file management -- chown / chmod

Most of the times when I use PHP to handle files there are the same issues I run into:

- security because of default 0777 chmod
- files not editable/deletable through FTP (owner issue?)

I want to extend a custom framework so that I have a GUI that would create simple files for me. These would function as a template, not requiring manual editing but should be possible. This editing would then go through FTP.

The trick is, this should work not only on one server, but on multiple.

I am not a sys admin so I dont know too much about rights, but I was thinking about the following steps:

- per framework install I would need to be able to write files, which could be done by setting a specific dir + subfolders/files to 0777, which feels extremely dirty and prone to attacks on shared servers. I think however that before writing/deleting a file, the 0777 can be set, and afterwards restored to the original value.

- to effectively be able to edit a file through FTP, Id say I need to set the owner to whatever owner it should be, which value I can maybe get from a original FTP file.
- the same goes for the chmod value.


If there are better ways to achieve this, Id sure be happy to find out.

Any help greatly appreciated Most of the times when I use PHP to handle files there are the same issues I run into:

- security because of default 0777 chmod
- files not editable/deletable through FTP (owner issue?)

I want to extend a custom framework so that I have a GUI that would create simple files for me. These would function as a template, not requiring manual editing but should be possible. This editing would then go through FTP.

The trick is, this should work not only on one server, but on multiple.

I am not a sys admin so I dont know too much about rights, but I was thinking about the following steps:

- per framework install I would need to be able to write files, which could be done by setting a specific dir + subfolders/files to 0777, which feels extremely dirty and prone to attacks on shared servers. I think however that before writing/deleting a file, the 0777 can be set, and afterwards restored to the original value.

- to effectively be able to edit a file through FTP, Id say I need to set the owner to whatever owner it should be, which value I can maybe get from a original FTP file.
- the same goes for the chmod value.


If there are better ways to achieve this, Id sure be happy to find out.

Any help greatly appreciated

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).