Page 1 of 1
Make directory and create files in a different domain
Posted: Mon May 15, 2006 9:07 pm
by myitanalyst
Ok,
Have a client with domains and subdomains
http://www.mydomain1.com
sub.mydomain1.com
They have a script that process a form under
http://www.mydomain1.com, but need it to create a directory and file under the sub.mydomain1.com. These domains are under the same account, and the domain folders exist just like the domain name is setup.
I am trying the following from the
http://www.domain.com form:
Code: Select all
if (!file_exists('/sub.mydomain.com/newfolder'])) {
mkdir('/sub.mydomain.com/newfolder');
}
but I get the error: "mkdir(/sub.mydomain.com/newfolder): No such file or directory in"
So, is this error due to permissions or do I have to use something else to get to a different folder outside the form domain? Can this be done?
Thanks
Posted: Mon May 15, 2006 9:32 pm
by myitanalyst
Ok... I now found the correct path...
Code: Select all
if (!file_exists("/hsphere/local/home/username/sub.mydomain1.com/newfolder")) {
mkdir("/hsphere/local/home/username/sub.mydomain1.com/newfolder", 0777);
}
but still get "Permission denied in" error. Do I need to give 0777 or 0775 rights somewhere? I don't want to have a security hole either so what is the best way of doing this?
Ok... I had to put 0777 rights on the sub.mydomain1.com folder.
Am I causing a security whole by doing this? It is the only way I could get it to work.
Thanks
Posted: Mon May 15, 2006 10:21 pm
by velo
I usually have issues like this unless I specifically set permission via chmod
chmod($directoryName, 0777);
Also, and this IS a security hole, if the directory is underneath the web root, is that you will likely have to set the same permissions on all the parent diretories as well
Posted: Mon May 15, 2006 10:35 pm
by myitanalyst
velo wrote:I usually have issues like this unless I specifically set permission via chmod
chmod($directoryName, 0777);
Also, and this IS a security hole, if the directory is underneath the web root, is that you will likely have to set the same permissions on all the parent diretories as well
So how the heck do folks have their own scripts create files if it cause a big security hole? I know people have got to be doing this on a regular basis...
The other problem i am seeing is the script is setting the mode and making itself owner, but that owner name is httpd where the ftp primary user account is different. That is why my ftp client doesn't allow me the ability to delete the items after the script creates it.
I simply need to be able to create folders and files under the folder and the ability to update the files from the script... and I would like to still maintain access to alter the files via my primary ftp user account if possible.
Thanks!
Posted: Mon May 15, 2006 10:45 pm
by RobertGonzalez
myitanalyst wrote:So how the heck do folks have their own scripts create files if it cause a big security hole? I know people have got to be doing this on a regular basis...
The other problem i am seeing is the script is setting the mode and making itself owner, but that owner name is httpd where the ftp primary user account is different. That is why my ftp client doesn't allow me the ability to delete the items after the script creates it.
I simply need to be able to create folders and files under the folder and the ability to update the files from the script... and I would like to still maintain access to alter the files via my primary ftp user account if possible.
I ran into this same problem with an app that required write access for caching. I had to choose between setting the owner name of the directory to 'apache' or set the chmod to 0755. I ended up going with chmodding the directory because I ran into the same problem as you with not being able to FTP to the directories.
I am not sure you can have the script update the files without chmodding the directory if you still need FTP access to them. I could be wrong.