new ccgi permissions
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- new ccgi permissions
new ccgi permissions
16-03-2010 8:52 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Paranoid permissions are not quite as essential on the new ccgi server, but why give the hackers an inch?
Contrary to any remaining sources that recommend php files should have permissions set to 755 (0755: -rwx,r-x,r-x), this is not necessary on the ccgi platform. Setting group and other permissions on script files is potentially insecure.
The default permissions for php files should rather be 700 (0700: -rwx,---,---).
Bulk modifying all files and folders to 755 or 750 will allow sites to work, but this is potentially insecure and not best policy.
Permissions should be set selectively:
Folders 710 (0710: drwx,--x,---) is still recommended, or 750 if necessary. Some packages, like Wordpress, may encourage you to set some folder permissions to 777, but that would be imprudent. If 710 is insufficient, try 750 but no higher.
Scripts 700 (0700: -rwx,---,---) and no higher.
Static web content (html, css, js, etc.) and Apache files (htaccess, htpasswd) can be left at the default 640 (0640: -rw-,r--,---).
Files which are only read from and written to by scripts, but not served to browsers, such as log files, ini files and certificate files can be set to 600 (0600: -rw-,---,---).
Permissions can be set selectively using most FTP clients (control click in the file lists to select multiple files of the same type (or apple click on Macs)). For large numbers of files in deep folder trees, it may be easier to use a script, such as the one given below.
If nothing else, php files which contain login details, such as MySQL passwords, should be set to 700.
#!/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>"
(Give it a .cgi extension, load it to your web root, set its own permissions to 700 and call it with a web browser. You can change "chmod 710" to "chmod 750", but don't edit "! -perm 1710", which tells the script not to chmod your root folder.)
Gabe
Re: new ccgi permissions
16-03-2010 12:40 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator

I'll add that to the FAQ on the Community Library after I've had some lunch...
Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵
Re: new ccgi permissions
16-03-2010 4:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I kind of need this working reliably, as my business relies on one of my sites.
Re: new ccgi permissions
16-03-2010 9:29 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: geraldholdsworth However, sometimes I get Access forbidden,
I see the same. Sometimes the pages are fine, at other times I'll get Access forbidden for a while. Then it's okay again without me doing anything other than hitting reload again.
I'm not sure why, I wondered if there was some load balancing maybe with a misconfigured server in the pool?
Re: new ccgi permissions
17-03-2010 8:55 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Re: new ccgi permissions
17-03-2010 9:02 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: geraldholdsworth I get Access forbidden more often that not, and when I don't, I get an incomplete page.
Sounds like one for Plusnet.
Gabe
Re: new ccgi permissions
17-03-2010 1:29 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Really sorry if I'm being a pain with repeating the question, it's just that I'm completely running out of ideas. Our PHP environment simply does-not-work. I have deleted everything on our CGI webspace, and I have just uploaded a single 3-line php file containing
<?php
phpinfo();
?>
And still get "Error 500; Premature end of script headers: php_test.php".
This is just calling the phpinfo() function. What gives? I have tried changing the CHMOD settings to 777, 755, 750, 700, and probably few others, what should I do to get any sign of life from PHP?
Re: new ccgi permissions
17-03-2010 1:51 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Are you sure there isn't a hidden .htaccess file in the directory?
David
Re: new ccgi permissions
17-03-2010 1:54 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: spraxyt A PHP file with that content works for me - permissions 0700.
Are you sure there isn't a hidden .htaccess file in the directory?
David
I have just set it back to 0700 - nothing.
.htaccess is not there, I'm positive. Yesterday, I was trying everything, so I was reading the thread
http://community.plus.net/forum/index.php/topic,84267.16.html
where Gabe was suggesting changes to .htaccess file. I put in some general .htaccess file and tried to make the settings suggested, but when it didn't work, I removed it.
Re: new ccgi permissions
17-03-2010 2:08 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Re: new ccgi permissions
17-03-2010 2:14 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: Ben pcr - I've had a quick look on the filesystem and your home directory had the wrong group. I'm not sure how this happened but will look into that later. I've corrected it now, so your site should now work - the php_test.php page certainly does now.
Hello Ben,
Thank you very much for that. The PHP now indeed returns the output. Hope the Joomla installation will go smoothly as well.
Thank you again, we were slowly going crazy.
Re: new ccgi permissions
18-03-2010 3:34 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Premature end of script headers: permissions.cgi
I've copied the script into the root directory and set permissions to 700.
I've disabled my .htaccess file (just to make sure) but keep getting the same error.
Is there anything else I need to do?
thanks
Nick
Re: new ccgi permissions
18-03-2010 3:57 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote i'm trying to get Gabe's permissions script to work but keep running into the error:
Premature end of script headers: permissions.cgi
I've copied the script into the root directory and set permissions to 700.
I've disabled my .htaccess file (just to make sure) but keep getting the same error.
Is there anything else I need to do?
thanks
Nick
Managed to sort it - CR/LF issue.

Re: new ccgi permissions
25-06-2010 1:12 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
i already had this code before i upgraded....
help!
bethan
Re: new ccgi permissions
25-06-2010 1:31 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: fforchlas ..... what do you mean by "run the script"
Assuming the script (permissions.cgi, if that's what you called it) has its own permissions set to 0700, to run it you type
http://ccgi. … /permissions.cgi in your browser's address line and press enter.
That executes (runs) the script and the results should be displayed in the browser window.
David
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page