in reply to Re: Re: Why does this crash? (Error 500)
in thread Why does this crash? (Error 500)

You need 777 if you just want it to work!

4 Read 2 Write 1 Execute ie 5 = R+X (4+1) 6 = R+W (4+2) 7 = R+W+X (4+2+1) 7 5 5 owner group everyone-else

Your CGI will run as the user apache or nobody. So for your script to write to a dir user apache/nobody needs to be able to WRITE to the dir (it will probably be falling into the everyone-else user cat). Assuming you own it (the 7) you either need to change the ownership and or the perms. Something like this will work: chmod -R 777 /path/to/dir/ but is pretty crude. You probably want something like chown you:nobody /path/to/dir && chmod 775 /path/to/dir which will make you the owner, nobody (or apache if req) the group and then give the group write perms. You may want 770 if the data is senstive.

Oh, and the usual text message you have in a die_nice goes like ;-)

Sorry the system is currently unable to fulfil you request due to: 1) Routine Maintenance 2) Unusually high load 3) Transient network hiccups and miscalaneous flatulence 4) Being on strike cause of the 24/7 working hours, low pay and total lack of appreciation from my programmers. .....

cheers

tachyon

Replies are listed 'Best First'.
Re: Re: Re: Re: Why does this crash? (Error 500)
by sgifford (Prior) on Jan 02, 2004 at 16:42 UTC

    You should be aware that using mode 777 means that anybody on the system can read and write that file or directory. If you're on a shared system, anybody else on the system can edit or delete files in a mode 777 directory. Even if you have a system to yourself, giving permissions to everybody to write someplace can make a minor security problem (like disk access as user nobody) into a big one.

    If you really don't care about the files or directories with mode 777 being changed by random users, those permissions are fine. Sometimes that's true, as in /tmp. Mostly, though, it's not true, and you should find a more restrictive set of permissions that allows your script to write to that directory, without allowing the rest of the world as well.

      Thanks for the advice - I am only using this as a back up so it will be a question of chmod in the script to 777 then back again after the file is created.

      I totally agree that 777 is generally bad which is why I went on to suggest the chown user:nobody and chmod 775 or 770.

      cheers

      tachyon

        I know you suggested it, tachyon. I was concerned the OP had skipped over that part of your post, since he seemed to just try mode 777 and be happy with it. But it sounds like he's taking some precautions, so hopefully all will be well. :-)
Re: Re: Re: Re: Why does this crash? (Error 500)
by Anonymous Monk on Jan 02, 2004 at 12:22 UTC
    Ah, 777 did it!! Thanks tachyon, and the text message is copied too! :)