Go Back   Web Server Hosting Forum by BODHost > Support > Control Panel Forum
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-06, 17:36
BOD Member
 
Join Date: Jul 2006
Posts: 4
Default Wrapper - subdomain

Bodhost.com hosting comes with the simple cgi wrapper which enables cgi scripts to run under the user id, rather than as the webserver. However, when activated in the control panel this creates a scgi-bin directory in the root public_html directory only. Is there any way to set the wrapper up for a subdomain (i.e. create public_html/sub_domain/scgi-bin)? Obviously it's possible to simply place the few scripts requiring such rights in the root scgi-bin folder even for subdomains, but I'd prefer not to have files from different subdomains mixed together if at all possible.

Thanks,

Enigma
Reply With Quote
  #2 (permalink)  
Old 07-06-06, 03:55
Administrator
 
Join Date: Sep 2005
Posts: 68
Send a message via AIM to bodhost.com Send a message via MSN to bodhost.com
Default

When you add a subdomain from control panel, a cgi-bin is created by default in directory of that subdomain. You can put your scripts for respective subdomain name in that particular cgi-bin.
Reply With Quote
  #3 (permalink)  
Old 07-06-06, 05:43
BOD Member
 
Join Date: Jul 2006
Posts: 4
Default

Thanks for your reply.

The problem is that scripts placed in the subdomain's cgi-bin are run by the webserver under its own user id (user: nobody). Since this is different from the user id of the owner of the site and in a different group if any of the scripts need to write to the filesystem the directories written to must be world writable. The simple CGI wrapper wraps scripts so that they run under the user id of the site owner, not of the webserver. This way directories that are written to need only be user writable, not world writable.
Reply With Quote
  #4 (permalink)  
Old 07-06-06, 06:42
Administrator
 
Join Date: Sep 2005
Posts: 68
Send a message via AIM to bodhost.com Send a message via MSN to bodhost.com
Default

Scripts that you upload remain under your ownership but the scripts generated by some other script in your account is generated under ownership of nobody. If you have problems with the ownership of nobody then you should contact our helpdesk immediately to get your ownership on those scripts as ownership of nobody and permission 777 is open invitation to hackers / crackers to play and modify contents of those scripts.
__________________
Dedicated Server Hosting best Dedicated Servers
VPS Hosting Virtual Private Servers
Toll Free : 866 662 0909
MSN : sales @ bodhost.com
AIM : bodsupport
Reply With Quote
  #5 (permalink)  
Old 07-06-06, 07:11
BOD Member
 
Join Date: Jul 2006
Posts: 4
Default

I don't think you're quite understanding my issue.

Suppose we have the following website directory structure (with unix permissions shown):
Code:
[d] 755 website/
[d] 755         public_html/
[d] 755                     cgi-bin/
[f] 755                            root-domain-script.cgi
[d] 755                     scgi-bin/
[f] 755                              root-domain-wrapped-script.cgi
[d] 755                     subdomain/
[d] 755                               cgi-bin/
[f] 755                                       subdomain-script.cgi
[d] 755                               safe-user-writable-folder/
[d] 777                               unsafe-world-writable-folder/
And the cgi scripts are identical perl scripts containing the following code (forgive me if the perl is incorrect - I'm not that experienced with it - but the intent should be clear):
Code:
#!/usr/bin/perl -w

open(SAFEFILE, ">", "/website/public_html/subdomain/safe-user-writable-folder/temp");
open(UNSAFEFILE, ">", "/website/public_html/subdomain/unsafe-world-writable-folder/temp");

while (read (STDIN, $LINE, 4096))
{
	if (SAFEFILE)
	{
		print SAFEFILE $LINE;
	}
	if (UNSAFEFILE)
	{
		print UNSAFEFILE $LINE;
	}
}
close (SAFEFILE);
close (UNSAFEFILE);

exit(0);
Now root-domain-script.cgi will successfully create the file /website/public_html/subdomain/unsafe-world-writable-folder/temp, but will fail to create the file /website/public_html/subdomain/safe-user-writable-folder/temp. This is because scripts, regardless of who owns the script file, are run by the webserver and therefore are run by default with the webservers user id, which is "nobody" and "nobody" does not have permission to write to the folder safe-user-writable-folder.

This situation is exactly the same for subdomain-script.cgi.

root-domain-wrapped-script.cgi however will run not with the webserver user id but with the script owner's user id, thanks to simple CGI wrapper, and will therefore successfully create both files.

What I would like is to be able to have a directory structure like:
Code:
[d] 755 website/
[d] 755         public_html/
[d] 755                     cgi-bin/
[f] 755                            root-domain-script.cgi
[d] 755                     scgi-bin/
[f] 755                              root-domain-wrapped-script.cgi
[d] 755                     subdomain/
[d] 755                               cgi-bin/
[f] 755                                       subdomain-script.cgi
[d] 755                               scgi-bin/
[f] 755                                        subdomain-wrapped-script.cgi
[d] 755                               safe-user-writable-folder/
With the additional scgi-bin directory and subdomain-wrapped-script.cgi in the subdomain folder.
Reply With Quote
  #6 (permalink)  
Old 07-06-06, 11:23
BOD Member
 
Join Date: Jul 2006
Posts: 4
Default

Strangely my script seems to be working now even when I move it out of the scgi-bin directory, which I can't explain.
Reply With Quote
  #7 (permalink)  
Old 07-06-06, 15:28
Administrator
 
Join Date: Sep 2005
Posts: 68
Send a message via AIM to bodhost.com Send a message via MSN to bodhost.com
Default

Probablly you have code in your .htaccess to allow cgi scripts to execute outside cgi-bin. If you wish to execute cgi scripts outside cgi-bin then you add following code to your .htaccess :-

Options +ExecCGI
AddHandler cgi-script cgi pl
__________________
Dedicated Server Hosting best Dedicated Servers
VPS Hosting Virtual Private Servers
Toll Free : 866 662 0909
MSN : sales @ bodhost.com
AIM : bodsupport
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 01:09.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.