LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Apache Migration/Compatibility > cgi suexec / cPanel server

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2007, 09:58 PM
ffeingol ffeingol is offline
Senior Member
 
Join Date: Jul 2007
Location: /dev/null
Posts: 290
Default cgi suexec / cPanel server

Hello,

How do we enable/configure cgi (i.e. perl scripts) suexec when we're using a cPanel / Apache httpd.conf setup?

TIA,

Frank
Reply With Quote
  #2  
Old 08-02-2007, 06:54 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
It should be automatic if the virtual host has "User/Group" configuration or "SuexecUserGroup" configuration.
Reply With Quote
  #3  
Old 08-02-2007, 07:01 AM
ffeingol ffeingol is offline
Senior Member
 
Join Date: Jul 2007
Location: /dev/null
Posts: 290
Yep, it's there, but does not seem to be working:

Code:
<VirtualHost x.x.x.x>
ServerAlias www.xx.xx
ServerAdmin webmaster@xx.xx
DocumentRoot /home/xx/public_html
User xxx
Group xxx
ServerName xx.xx

<IfModule mod_suphp.c>
  suPHP_UserGroup xxx xxx
</IfModule>
<IfModule mod_php4.c>
  php_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/local/lib/php:/tmp:/opt/lsws/share/autoindex"
</IfModule>
<IfModule mod_php5.c>
  php_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/local/lib/php:/tmp:/opt/lsws/share/autoindex"
</IfModule>

User xxx
Group xxx
BytesLog /usr/local/apache/domlogs/xx.xx.xx-bytes_log
CustomLog /usr/local/apache/domlogs/xx.xx.xx combined
ScriptAlias /cgi-bin/ /home/xxx/public_html/cgi-bin/
</VirtualHost>
Here is the code we're running:

Code:
#! /usr/local/bin/perl

print "Content-type: text/html\n\n";
print "<html><body>\n";
print "hello word\n";
open(PASSW, "/var/cpanel/whmtheme");
while (<PASSW>)
{
  print "*$_ *\n";
}
print "</body></html>\n";
When we access the page we get:

hello world
*x *

So the script is able to open /var/cpanel/whmtheme which is well outside the sites "home directory" and I though would be unaccessible.

TIA,

Frank
Reply With Quote
  #4  
Old 08-02-2007, 07:13 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
If the user have read permission on that file, then the script can still read it. LSWS only guarantee itself won't be tricked to serve anything out side the document root, it has no control over a script unless the script is placed in a chroot jail.

You can make the script run slower and check the process uid.
Reply With Quote
  #5  
Old 08-02-2007, 07:47 AM
ffeingol ffeingol is offline
Senior Member
 
Join Date: Jul 2007
Location: /dev/null
Posts: 290
Quote:
Originally Posted by mistwang View Post
You can make the script run slower and check the process uid.
Can you explain this a bit more?

I ran a quick test and you are correct that Apache suexec can read outside the document root (something I did not think it could do). suexec, however, enforces that the uid/gid match or it won't run the script. Is this possible to do with LSWS when it's reading the Apache config?

TIA,

Frank
Reply With Quote
  #6  
Old 08-02-2007, 08:13 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Just add something like "sleep(60)", so you will have time to check the process uid with "ps" command. I believe that the script is run as the uid/gid of the owner of document root.
Reply With Quote
  #7  
Old 08-02-2007, 08:31 AM
ffeingol ffeingol is offline
Senior Member
 
Join Date: Jul 2007
Location: /dev/null
Posts: 290
Yes, the process is running at the proper id (the site owner). How about the uid/gid checks?

TIA,

Frank
Reply With Quote
  #8  
Old 08-02-2007, 09:37 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Quote:
How about the uid/gid checks?
What is this about?
Reply With Quote
  #9  
Old 08-02-2007, 09:43 AM
ffeingol ffeingol is offline
Senior Member
 
Join Date: Jul 2007
Location: /dev/null
Posts: 290
Well LSWS mimics Apache there are checks in place with suexec to insure that the uid/gid of a cgi script matches the uid/gid given in the vhost container.

Frank
Reply With Quote
  #10  
Old 08-02-2007, 09:56 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
LiteSpeed uses the uid/gid of the owner of the document root, instead of the owner of the script, in most cases, those two should match.
When they do not match, document root uid is preferred, as it is more secure to us.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:54 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.