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

Moved from Categorized Q&A by Q&AEditors.
Please do not vote for this node; the votes will affect the wrong user. Thank you.

I'm using RH 6 with Apache 1.3.12 and mod_perl/Perl 5.005. Something about "setuid" but I can't find documentation anywhere. Even the man page seems useless from a beginner's point of view.

Replies are listed 'Best First'.
Re: How do I create files on the server?
by Aighearach (Initiate) on Jul 16, 2000 at 10:40 UTC
    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.
    
      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.