HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   General (http://www.howtoforge.com/forums/forumdisplay.php?f=25)
-   -   Path to private directory (http://www.howtoforge.com/forums/showthread.php?t=61033)

trigar 20th March 2013 12:34

Path to private directory
 
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,

till 20th March 2013 13:07

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/

trigar 20th March 2013 13:39

Quote:

Originally Posted by till (Post 294341)
There are sevarl options to get that path, e.g. in php:

realpath('../provate');

or

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

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.

Quote:

Originally Posted by till (Post 294341)
Or if your scripts are working correctly with symlinks (which should be ok in most cases), then use:

/var/www/domain.tld/private/

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.

till 20th March 2013 13:42

Quote:

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.
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.

trigar 20th March 2013 13:55

Quote:

Originally Posted by till (Post 294349)
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.

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

Thank you!


All times are GMT +2. The time now is 15:56.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.