in reply to How do I create files on the server?

This question is very vague. What are you trying to do? There aren't very many cases where you should be using setuid scripts under mod_perl.
Paris Sinclair    |    4a75737420416e6f74686572
pariss@efn.org    |    205065726c204861636b6572
I wear my Geek Code on my finger.
  • Comment on Re: How do I create files on the server?

Replies are listed 'Best First'.
RE: Re: How do I create files on the server?
by Anonymous Monk on Jul 16, 2000 at 19:57 UTC
    I've got a form going which is used to update/append a log of comments for the current day. I therefore build a filename based on the date and time and then check to see if it exists every time a browser request is made. If it doesn't I want to create it on the server. I have a command line script that does this but when I integrate it in the form script I figure it's a matter of permissions that does not allow me to do that.
      From the mod_perl FAQ:

      What if my script needs higher privileges?

      You will have to start a new process that runs under a suitable user-id (or group-id). If all requests handled by the script will need the higher privileges, you might as well write it as a suid CGI script. Read the documentation about suEXEC in the Apache documentation.

      Alternatively, pre-process the request with mod_perl and fork a suid helper process to handle the privileged part of the task.
      It sounds like the server is set up the same as mine; hands off anything created by Apache, unless you're in the same group. It simplifies security. Why not just create an empty file on the server, and copy it to the new name? So first you'd prepare it with: (assuming *nix)
      touch blank.file
      
      and in your code: (I haven't had my coffee yet, so this isn't Perl; it's psuedocode.)
      if ( need_new_file() ) { copy( blank.file, new.file ); } open( *NEW_FILE, ">>new.file" ); print NEW_FILE $stuff; close NEW_FILE;

      Okay, it's a kludge. But, it works. And without needing extra permissions.

      Paris Sinclair    |    4a75737420416e6f74686572
      pariss@efn.org    |    205065726c204861636b6572
      I wear my Geek Code on my finger.
      
        So the "touch" part is actually precreating the file? Not part of the script? This is exactly what I'm trying to avoid.