cancel
Showing results for 
Search instead for 
Did you mean: 

new ccgi permissions

Ponds
Dabbler
Posts: 20
Registered: ‎19-10-2007

Re: new ccgi permissions

I am trying to set the proper permissions on my Wordpress files, using Gabe's script in a file called permissions.cgi . I've got the server error ("Premature end of script headers: permissions.cgi")  Does anyone know what the cr/lf error is, as mentioned by ninjanik?
Here's what I did - can anyone tell me what am I doing wrong? It might be something very basic, as I am not too knowledgeable about Unix/Linux.
1. On a Windows PC, I copied the 9 lines of script in Gabe's message and pasted them into a text file.
2. I transferred the file to ccgi.<myusername>.force9.co.uk, using FireFTP
3. I renamed the file to permissions.cgi, using FireFTP
4. I checked/set the permissions on permissions.cgi, using FireFTP. They are Owner Read, Write Execute. 0700
5. I looked at the permissions.cgi file - it has the 9 lines. The lines terminate in hex 0d0a, except for the last one.
6. I looked for .htaccess and found none. (I can see other files beginning with a "." - .bash_history  .swp  and  .viminfo)
7. Using Firefox, I  went to http://ccgi.<myusername>.force9.co.uk/permissions.cgi but got the error.
Thanks,
Brian
Gabe
Grafter
Posts: 767
Registered: ‎29-10-2008

Re: new ccgi permissions

Not sure, but try uploading again with the transfer mode set to ascii.
Gabe
Ponds
Dabbler
Posts: 20
Registered: ‎19-10-2007

Re: new ccgi permissions

Gabe,
You're a star! That was the answer.
Many thanks,
Brian
For anyone else using FireFTP:  it has three modes of transfer  -  binary, ASCII and automatic. You select the mode from Tools->Options->Downloads/Uploads
oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Re: new ccgi permissions

That script's been a big help, seemed to be the ONLY way I could set file permissions recursively
TomMelly
Grafter
Posts: 86
Registered: ‎23-08-2007

Re: new ccgi permissions

Hmm, now I'm having problems... Pretty much everything is returning "premature end of script headers" with the exception of simple html files.
I've put gabe's script at: http://ccgi.tomandlu.plus.com/perms.cgi (uploaded as ascii, perms 700), but it won't run either. Even this cut-down version for testing won't work (http://ccgi.tomandlu.plus.com/permsb.cgi):
#!/bin/bash
echo "Content-type: text/html"
echo
echo "<table border='1'><tr><th>Type</th><th>Name</th><th>User, Group</th><th>Permissions</th></tr>"
echo "</table>"

Oh, edit to add, I've no .htaccess files...
oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Re: new ccgi permissions

I don't know if this helps but I found I could only get bash scripts to run in the cgi-bin folder, so I typically put them there and edited in a "cd .. " at the beginning so they'd act on the whole tree not just the cgi-bin branch.
TomMelly
Grafter
Posts: 86
Registered: ‎23-08-2007

Re: new ccgi permissions

Hmm, nope - no difference...  Cry
Just for completeness, here's the full script...
#!/bin/bash
echo "Content-type: text/html"
echo
find . -type d ! -perm 1710 -print0 | xargs -0 chmod 710
find . -type f -regextype posix-extended -regex '.*\.(php|pl|cgi)$' -print0 | xargs -0 chmod 700
echo "<table border='1'><tr><th>Type</th><th>Name</th><th>User, Group</th><th>Permissions</th></tr>"
find . -type d -printf '<tr><td>Folder</td><td>%p</td><td>%u, %g</td><td>%M</td></tr>'
find . -type f -printf '<tr><td>File</td><td>%p</td><td>%u, %g</td><td>%M</td></tr>'
echo "</table>"

And I've checked running it under a shell on an Ubuntu install, and it seems fine (not via a browser, just command line).
Edit to add - I'm going to back up my legacy stuff, and turn off cgi, then turn it on again to see if that fixes things at all. Something seems screwy at the mo'
Gabe
Grafter
Posts: 767
Registered: ‎29-10-2008

Re: new ccgi permissions

Yup. Something is screwy at the mo'. You have group write permission set on your web root folder. That'll stop you running anything from there. The safest thing to do is to ask PN to reset it for you, but if you're feeling bold you can try creating a folder in your home/root folder, set its perms to 710 using ftp; place this script, with .cgi extension
#!/bin/bash
echo "Content-type: text/html"
echo
chmod 1710 .. && echo "done"

in that folder and set its perms to 700, then call it in a browser.
Gabe
TomMelly
Grafter
Posts: 86
Registered: ‎23-08-2007

Re: new ccgi permissions

Ah - thought it might be something like that (I saw a couple of other posts where people had run into similar issues). Anyway, I deactivated and have now reactivated cgi which I suspect will fix it.
Interestingly, some scripts did run on an intermittent basis, but it was all a bit flaky to say the least.
Anyway, many thanks...