• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Changing Default FTP directory permissions?

M

Marquis

Guest
Hi,

I use FTP to allow users of my site upload txt files for 'parsing'. Php needs to be able to read these files and delete bad ones. Currently it is no problem as long as the web user doesn't put the files in a folder. If he does, php doesn't have permission since the default folder permission given by the ftp doesn't allow php to edit this.

The folders are the web users folders, but belong to a PSA group. Should I make php a member of that group?

Or..

Can I change the default folder permissions for the ftp so that web user's folders are all readable. How do I do that?
 
What about using su phpsuexec to call your parsing script? Or a less elegant solution, run a cron job to reset the ownership of new folders/files?
 
phpsuexec doesn't really work for my application partially because there are many .htaccess directives that are being used.

I've considered creating a sudo batch type command that when run via a phpexec command will change the file permissions. Is this an acceptable way? (I've actually never had much luck getting phpexec commands to run, so I'm hestitant to try this.)

I still think this is a brutal solution to what is really an FTP issue that should be fixable at that source.
 
Untried!!!

but in /usr/local/psa/ftpd/etc/proftpd.conf (may differ on other platforms)

You can see

<Directory /usr/local/psa/home/vhosts>
GroupOwner psacln
</Directory>


Maybe if you added your own directory tags to your own specific directories you could set the GroupOwner to psaserv (that is what you are trying to do isnt it?)

(remember to restart inetd or whatever runs your ftp daemon for the change to take place)
 
ftp permissions still a question

I am having similar frustration with the default ftp folder permissions.

On one site, we upload a folder full of pictures and other media. Once accessed from the web end, PHP will attempt to create a directory and move some stuff around -- HOWEVER, the default permissions won't allow PHP to create a directory in that newly created directory. An attempt to CHMOD on the PHP side also fails.

Workaround I have been using is cron; which sets all directories to 777 -- but that doesn't help on the same day the folder was created.

So, is there a way to make the default ftp directory permissions 777?
 
If you dont mind putting your ftp user/pass into a script you can create a directory via sockets in php (or i guess you could use the ftp functions if you have the compiled in)

PHP:
<?php
   $ftp_host="YOURDOMAIN.EXT";
   $ftp_user="FTPUSERNAME";
   $ftp_pass="FTPPASSWORD";
   $basepath="/httpdocs/";
   $name="my_new_directory";
   $ftp=fsockopen("$ftp_host",21);
   fputs($ftp,"USER $ftp_user\r\n");
   fputs($ftp,"PASS $ftp_pass\r\n");
   fputs($ftp,"CWD $basepath\r\n");
   fputs($ftp,"MKD $name\r\n");
   fputs($ftp,"SITE CHMOD 777 $name\r\n");
   fputs($ftp,"QUIT\r\n");
   fclose($ftp);
?>

(you could easily wrap the above into a function and call it phpmkdir or something similar)


But i really wouldnt change the ftp daemon to chmod all directories as standard to 777 that would be just asking for trouble (in my opinion anyway)
 
Back
Top