Dynamic Images and File Permissions
| From: | Adam Hubscher | Date: | Thu, 14 Jul 2005 00:53:30 +0000 |
| Subject: | Dynamic Images and File Permissions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-218654@lists.php.net to get a copy of this message | ||
I have a script that generates, creates, and updates dynamic banner images for users of a service.
Recently I have run into a problem with file permissions... that has thoroughly annoyed me. I found a solution to fix the problem, however, it was then hit with another problem, and I'm not sure how secure I find my solution to be.
During the image creation process, the files are given the normal image permission of 644 (rw-r--r--). Of course, this makes updating impossible.
I attempted to use a simple chmod();, however, the script didnt have the permissions to do this. I couldnt figure out a way to fix this, so I moved on to looking for other solutions.
I ended up with somethign that worked, slightly, but did not provide me with an actual fix due to another problem. I would connect to the folder via local FTP, then using ftp_site run a direct CHMOD on the files.
However, in doing this, I feel that the script itself is insecure. Also, it didnt work in the end. After running the update script, to test out my new solution, I was confronted with a new problem that I didnt understand.
The FTP command returned "Bad File Descriptor" after executing the CHMOD. After attempting in a few other of my own FTP clients, I ran into -exactly- the same problem.
My questions are this:
A) Is there any way to set the permissions on the file on creation of the image?
B) If no, is there a way I can do the CHMOD, even though chmod(); returned insufficient permissions to do so?
C) If no, is there a way I can fix the bad file descriptor, to fix the ftp solution I have?
Any other solutions would be able as well, given that they're somewhat secure.