1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice

Changing Default FTP directory permissions?

Discussion in 'Plesk for Linux - 8.x and Older' started by Marquis, Aug 10, 2005.

  1. Marquis

    Marquis Guest

    0
     
    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?
     
  2. jamesyeeoc

    jamesyeeoc Guest

    0
     
    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?
     
  3. Marquis

    Marquis Guest

    0
     
    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.
     
  4. mikk

    mikk Basic Pleskian

    23
    73%
    Joined:
    Jan 29, 2005
    Messages:
    83
    Likes Received:
    0
    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)
     
  5. michaellunsford

    michaellunsford Regular Pleskian

    25
    90%
    Joined:
    Jul 25, 2005
    Messages:
    131
    Likes Received:
    0
    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?
     
  6. mikk

    mikk Basic Pleskian

    23
    73%
    Joined:
    Jan 29, 2005
    Messages:
    83
    Likes Received:
    0
    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)
     
Loading...