Path to private directory

Discussion in 'General' started by trigar, Mar 20, 2013.

  1. trigar

    trigar New Member

    I have just installed a new ISPConfig 3.0.5.1 server, and I am trying to get to grips with the fact that I can no longer read or write to the parent of the web root (via "../").

    Searching the forums I understand that this was a security hazard and rightly blocked, and I should be using /var/www/domain.net/private instead. That works fine, except that that will need hard coding into a lot of scripts across many sites.

    What I would like is an easy way of doing this, either by programmatically determining the current site, or by having a standard path that works across all sites. Failing that I could just add a "sitename" file in the webroot and read that in every script, but again that is not ideal.

    I am using Perl, not PHP.

    Any suggestions gratefully received!

    Thanks,
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There are sevarl options to get that path, e.g. in php:

    realpath('../provate');

    or

    realpath('/var/www/domain.tld/private');

    Or if your scripts are working correctly with symlinks (which should be ok in most cases), then use:

    /var/www/domain.tld/private/
     
  3. trigar

    trigar New Member

    Thanks Till, but I am using Perl not PHP. Using the equivalent realpath command in Perl...

    Code:
    use Cwd 'realpath';
    my $dir = realpath("../private");
    print $dir;
    
    ... returns "/private", which is not correct or usable, as it would require private to be a subdir off the web root. Whether this is a Perl issue, or something peculiar to ISPConfig, I have no idea.

    Which works, but would need hardcoding into every script on every site. I need a way of programmatically calculating the path to the private directory.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    This des not require hardcoding as this path contains the domain name and you should be able to get it for the local site from within your script e.g. from apache server variables or you get the path your current script is running in and use this as basis to calculate the private dir path.
     
  5. trigar

    trigar New Member

    Yes, you're right, the environment variables have it.

    Thank you!
     

Share This Page