OEMike has asked for the wisdom of the Perl Monks concerning the following question:

Trying to write a simple Cookie/user SID display routine and I am getting a Permission Denied - any ideas? I've tried multple entries in the directory line as I figured that is where the error is originating from, and settled on the current ../../http-docs which I know to be "accessable".
#!/usr/bin/perl use CGI; use Apache::Session::File; my $query = new CGI; my %session; my $id = undef; $id = $query->cookie(-name=>"SID01"); tie %session, 'Apache::Session::File', $id, { Directory => "../../http-docs/", LockDirectory =>"../../http-docs/"}; if ($id == undef) { $cookie = $query->cookie( -name=>'SID01', -value=>$session{_session_id}, -expires=>'+1y', -path=>'/session'); print $query->header(-cookie=>$cookie); print "Assigned session ID<br>n"; } else { print $query->header(); print "Not assigned session ID<br>n"; }; $id = $session{_session_id}; print "Content-type: text/html\n\n"; print "<html>n"; print " <head><title>Session ID</title></head>n"; print " <body bgcolor=#ffffff>n"; print " Your session ID is $idn"; print " </body>n"; print "</html>n";

Replies are listed 'Best First'.
Re: Apache and Permission Denied
by fuzzyping (Chaplain) on Jul 17, 2002 at 14:34 UTC
    Are you absolutely positive that the Apache process has the correct permissions to write to the directory? Sure sounds like it doesn't.

    -fp
      This may be a dumb question --- CUT HERE---- Can I cange the Apache process to have the correct permissions, or do I need root? -------- Thank you - OEMike
        The directory in question must have write permissions for the Apache process (apache?). Whether this means that the directory is owned by apache, or simply that apache is part of a group with write permissions matters not. But yes, you're going to need root permissions to change the permissions on that directory.

        I suggest you do some research on unix file permissions. Basically, files and directories have User, Group, and Other permission bits (Read/Write/eXecute)...
        [fuzzy@jason fuzzy]$ ls -l testfile -rw-rw-r-- 1 fuzzy fuzzy 0 Jul 17 11:07 testfile
        As you can see, my User and Group sections have both Read and Write permissions turned on. Everyone else that isn't part of these two entities (Other) only has Read permissions. The file is owned by my user (fuzzy) and the respective group (fuzzy). If you want your directory to be writeable by the Apache process, the directory must either be owned by apache with Write permissions turned on, or apache must be a part of the Group entity, with Write permissions turned on.

        Hope this helps!

        -fp