• The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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