Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    4

    Default Customizing the directory path for FTP Users

    Moving my dedicated server to a CPanel server, so far love everything about it.

    One question:

    is there a way to remove the "public_html/" path that is automatically filled in by CPanel when a client adds a new FTP User.

    for instance when when creating FTP User "testing" I just want the
    directory to be "/testing" and not "/public_html/testing"

    is there a file I can edit, or?

    any help is much appreciated,
    Joe

  2. #2
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,892
    cPanel/Enkompass Access Level

    Root Administrator

    Lightbulb

    When creating the additional FTP account have you tried removing the part about public_html? I just tested this and it can be removed (the path can be edited on creation)
    Fav cPlinks this week: Blog - cPanel & WHM 11.32 we love it! | cPanel University study for it! | Attracta is coming! we want this!

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    4

    Default

    Hello, yes I can do this. It's just that I have hundreds of FTP users and they all want their folders to be non-web-accessible so I was hoping to hard-code this into the cpanel templates. I was hoping there was a file that controls this and I could just remove the "public_html" portion.

    Do you know the path to the cpanel files, or the file that controls FTP users?

    thanks for your help

  4. #4
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,892
    cPanel/Enkompass Access Level

    Root Administrator

    Lightbulb

    Have a peek at the users file in /etc/proftpd/cpanelaccountusernamehere

    That file should show all of your ftp accounts for that account that you might edit.

    As for editing this default behavior on addon FTP accounts creation, I'll leave that to the developers to help you out with. Sorry I can't help more than that.
    Fav cPlinks this week: Blog - cPanel & WHM 11.32 we love it! | cPanel University study for it! | Attracta is coming! we want this!

  5. #5
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default

    Hi Joe,

    The quickest and least invasive hack for this is to modfiy the template page, /usr/local/cpanel/base/frontend/x3/ftp/accounts.html , at line 40. Remove the 'onchange="suggest_homedir()"' attribute or place your own JavaScript function call there (and include your function via a <script></script> somewhere in the template).

    ex: add custom function and mod line 40.
    Code:
    <script>
      //simply removed the static "public_html/" string in the concatenation//
      var suggest_homedir_custom=function(){YAHOO.util.Dom.get("homedir").value=YAHOO.util.Dom.get("login").value;ADD_VALID.dir.verify()};
    </script>
    <td style="width: 150px">
      <input type="text" name="login" id="login" style="width: 150px" onchange="suggest_homedir_custom()" />
    </td>
    This is not a permenant solution, but would work for the meantime.

    If you're having to create these accounts manually, I'd just create them with the API1 'Ftp::addftp' call via the xml-api. Here's an example using the xml-api PHP client class to perform the request:
    Code:
    include("xmlapi.php");
    
    $ip = "10.1.1.1";
    $root_user = "root";
    $root_pass = "s3cr3tPass!";
    $cpuser = 'dave';
    
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth( $root_user, $root_pass );
    $xmlapi->set_output('xml');
    $xmlapi->set_port('2087');
    //$xmlapi->set_debug(1);
    
    //Ftp::addftp( user, pass, homedir, quota, disallowdot, homedir2 )
    $args = array( 'ftpuser1', 'pass1', '../testdir1', '', '', 'testdir1' );
    
    //those are create homedir: /home/$cpuser/testdir1
    //the third variable is relative to /home/$cpuser/public_html
    //the sixth variable is relative to /home/$cpuser
    //  as far as I know, you'll need to provide both for cPanel and the FTP
    //   sub-system to function properly.
    
    $xmlapi->api1_query($cpuser, 'Ftp', 'addftp', $args);
    There are many threads about how to use the xml-api and make requests via Perl, PHP or other languages. Check out docs.cpanel.net and/or give a shout if you need anything.

    Best Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  6. #6
    Registered User
    Join Date
    Aug 2010
    Posts
    4

    Default

    thank you for your help, what's strange is I don't see a line 40 or even the text "onchange" in:
    /usr/local/cpanel/base/frontend/x3/ftp/accounts.html

    i also tried a grep for "suggest_homedir" in the whole "ftp" folder and did not see anything.

    my version is the new cpanel, anything i might be doing wrong?

    thanks,
    Joe

  7. #7
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default

    doh! my bad, sorry Joe. My suggested change for file would be specific to cPanel 11.25.1. In cPanel 11.25.0, accounts.html is a redirect to one of two files depending on which FTP server your system is running. Both have the same change, just in different files and line numbers.

    If you're using Pure-FTP, then modify accounts_pure-ftpd.html, approximately line 159.

    If you're using ProFTP, then modify add_ftp_form.html, approximately line 72.

    The change is to the JavaScript
    Code:
    // old value '= "public_html/" + YAHOO.util.Dom.get("login").value;' 
    // new value removes '"public_html/" +'
    YAHOO.util.Dom.get("homedir").value = YAHOO.util.Dom.get("login").value;
    Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  8. #8
    Registered User
    Join Date
    Aug 2010
    Posts
    4

    Smile Thank you DavidN!

    Hello DavidN, just wanted to thank you -- it worked like a charm!

    cpanel is lucky to have people like you onboard, hope i can contribute back in the future to this forum

    this technique allows people to have the ftp users private by default, which is something ftp hosting providers especially would want, and I'm sure others will reference.

    I guess the only thing is I will have to re-edit this change each time CPanel upgrades (?), but that's ok.

    best regards, Joe

  9. #9
    Member
    Join Date
    Nov 2010
    Posts
    16

    Default Re: Customizing the directory path for FTP Users

    I'm looking to do a similar thing, but with the added complication of making the files in users directories read and writable by the PHP process set to DSO.

    Example:

    domain administrator = 'mysite'

    /public_html/clientarea/ftp/client1
    /public_html/clientarea/ftp/client2
    /public_html/clientarea/ftp/client3
    etc...

    The clients can upload files via FTP but they get assigned the user "mysite:mysite" for UID:GID.

    It seems like in order for PHP running as DSO to have move/delete capabilities over the files uploaded, either the UID or GID must be 'nobody'.

    I changed the file in /etc/proftpd/mysite so that the group is '99' for the client users.

    This allows the files uploaded to the directory to have the correct UID:GID as "mysite:nobody", but the permissions are 644 and they would need to be 664 in order for group 'nobody' to move or delete the files.

    How do I get the files uploaded to be 'rw' for the group 'nobody' by default?

  10. #10
    Member
    Join Date
    Nov 2010
    Posts
    16

    Default Re: Customizing the directory path for FTP Users

    Sort of figured it out for anybody interested, but would like a confirmation that what I did will work long term. I'm somewhat concerned that the /etc/proftpd.conf file will get overwritten by cPanel at some point.

    Inside proftpd.conf I added the following directive:

    Umask 0002

    in the <Virtual Host 123.123.123.123> container for the site in question. Fortunately it's a IP based site anyways.

    thus by changing the 'mysite' password file such that the client users are set to group 'nobody' and the umask to 0002 instead of 0022, when a file is uploaded I'm getting:


    rw_rw_r__ mysite:nobody mytest_file.txt

    which seems to allow PHP scripts to move or delete the file as necessary.

    Question: While I put my changes in /etc/proftpd.conf, I really suspect that they're going to get whacked if I add another virtual host inside cpanel.

    I'm thinking I should put another file in /etc/proftpd.d/ called 'mysite_custom_directives' and add the directives there. Any thoughts?

Similar Threads & Tags
Similar threads

  1. Replies: 14
    Last Post: 05-26-2011, 10:08 AM
  2. cPanel dropping begining of directory path
    By madscientist in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 02-19-2009, 11:09 AM
  3. Change default FTP home directory for users
    By dagurk in forum New User Questions
    Replies: 2
    Last Post: 06-12-2008, 03:39 PM
  4. Customizing User FTP Accounts
    By spyle in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 03-08-2008, 07:59 PM
  5. users path
    By rich2 in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 07-17-2002, 04:32 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube