in reply to Re: Perl CGI - Viewing logfiles - Security Issues
in thread Perl CGI - Viewing logfiles - Security Issues

You exactly got the issue I have. Your approach will work fine but for one issue bcoz of my requirement.

I have a softlink to the user directories under /usr/local/apache/htdocs as follows:-

wd -> /usr/local/wd/

Then, I build the link using the 'soft link', 'username' & 'log file name' and present it in HTML format.

One of the requirement is that I show the log files as 'links' in the HTML page so that the user can click and view the file(s), if they want to. Hence, I coded like what I had explained in the original post.

Is there any way to still have the files as 'links' and also take care of the security issue?

Replies are listed 'Best First'.
Re^3: Perl CGI - Viewing logfiles - Security Issues
by wfsp (Abbot) on Jan 10, 2007 at 18:02 UTC
    "Is there any way to still have the files as 'links'..."
    You could consider linking to a CGI script similar to Melly's above. You could pass the script a query string identifying the particular log needed.

      Thanks Melly and wfsp

      It works fine now without showing the 'softlinks' in the url after I used wfsp's suggestion.

      However, I will have to figure out a way to avoid the 'softlinks' to the user directories in Apache settings, which is still a potential security issue.

        The point is that you don't need the softlink - indeed, as long as you keep it, your security will be compromised. Get rid of it.

        My script, for example, runs with links like:

        <a href="/cgi-bin/viewlogs.pl?log=1">Access log</a>

        Your links might look like:

        <a href="/cgi-bin/viewlogs.pl?username=foobar">Foobar's log</a>

        Once more with feeling, your perl-script can access files that are not accessable to the web-server directly, and that is the way to keep content secure.

        map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
        Tom Melly, pm@tomandlu.co.uk