http://www.perlmonks.org?node_id=1189378


in reply to Re: Opening files to write in browser returns Permission denied
in thread Opening files to write in browser returns Permission denied

I am talking about a script, one called sitemap.pl, that opens in my browser and displays html content. At the end of the script, I have it write a list created in the script to a file. sitemap.pl, opened in the browser, can not write to sitemap.txt in the same directory as sitemap.pl unless the text file's permissions are set to 666.

So, from what I am gathering here, I have to set write files to 666 so that the output from scripts running in the browser can write to them.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena
  • Comment on Re^2: Opening files to write in browser returns Permission denied

Replies are listed 'Best First'.
Re^3: Opening files to write in browser returns Permission denied
by huck (Prior) on May 03, 2017 at 01:23 UTC

    How do you open sitemap.pl in your browser?

    You may find it of interest to run this

    my $user = `whoami`; chomp $user; my $groups = `groups $user`; chomp $groups; print "<br>I am running as $user in groups $groups\n";
    I suspect that the user you get back is not what you expected. I also suspect it is the last 6 in 666 that is fixing your problem. You are setting up a file that anyone can write into. Knowing what groups you are in and the perl process is running you may be able to determine what groups you may have in common. Setting that file (or directory) to be a member of that common group may mean you dont need to let anyone write to that file, but limit it to only userids in that common group.

      I did as you specified and was surprised by the result. I will have to dig into apache2 to see how can make my "localhost" local to me. Thank you huck!

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena

        For server-wide apache process ownership see User and Group.

        For per-vhost user/group assignments see SuexecUserGroup and the suexec tutorial.

        Make sure you fully understand the implications of using these directives before invoking them on any publicly-accessible server.

      Whether it is the first, the second, or the third... That seems to work.

      P.S. Would it be better to set the file permissions to 777? Why does evil win here?