Brandon Amaro | 5 Oct 00:12 2009
Picon

On and Off "Premature end of script headers" errors

I've been getting a lot of "Premature end of script headers" errors on 
my website after I installed suPHP. My website is a heavily modified 
PHPNuke and sometimes the pages load fine and other times they don't 
(the give the ever so meaningful Internal Server Error) so that rules 
out what the cause being using the command line version of PHP rather 
than the CGI one. Any idea of what is causing this on and off problem 
and how to fix it because it is really, really annoying since it happens 
so often...

--

-- 
omega13a
Owner and Founder of UFT
http://www.fedtrek.com
Giuseppe Iannello | 14 Oct 17:57 2009

suphp 0.7.1 + chroot

Hello everybody.
I have a big problem with my suphp setup. The environment is a debian 
lenny server, with jails for users.
I installed suphp using debian sid packages, because I wanted 0.7.1 version
The jails are in /var/jail/$USERNAME, and contains a base filesystem and 
the user's home directory in /home/$USERNAME.

my suphp configuration is the following
--
;Path all scripts have to be in
docroot=/var/www:${HOME}/public_html

;Path to chroot() to before executing script
chroot=/var/jail/${USERNAME}
--
the php files are in the jail, under /home/$USERNAME/public_html/www/

when I try to load the page with a browser, i get this 
(/var/log/apache2/error.log - username is "test")
--
[Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] SoftException 
in Application.cpp:537: Could not execute script 
"/var/jail/test/home/test/public_html/www/index.php"
[Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] Caused by 
SystemException in API_Linux.cpp:465: chdir() failed: No such file or 
directory
[Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] Premature end 
of script headers: index.php
--

(Continue reading)

Hugo Monteiro | 14 Oct 18:31 2009
Picon

Re: suphp 0.7.1 + chroot

Giuseppe Iannello wrote:
> Hello everybody.
> I have a big problem with my suphp setup. The environment is a debian 
> lenny server, with jails for users.
> I installed suphp using debian sid packages, because I wanted 0.7.1 version
> The jails are in /var/jail/$USERNAME, and contains a base filesystem and 
> the user's home directory in /home/$USERNAME.
>
> my suphp configuration is the following
> --
> ;Path all scripts have to be in
> docroot=/var/www:${HOME}/public_html
>
> ;Path to chroot() to before executing script
> chroot=/var/jail/${USERNAME}
> --
> the php files are in the jail, under /home/$USERNAME/public_html/www/
>
> when I try to load the page with a browser, i get this 
> (/var/log/apache2/error.log - username is "test")
> --
> [Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] SoftException 
> in Application.cpp:537: Could not execute script 
> "/var/jail/test/home/test/public_html/www/index.php"
> [Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] Caused by 
> SystemException in API_Linux.cpp:465: chdir() failed: No such file or 
> directory
> [Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] Premature end 
> of script headers: index.php
> --
(Continue reading)

Hugo Monteiro | 14 Oct 18:33 2009
Picon

Re: suphp 0.7.1 + chroot

Hugo Monteiro wrote:
> Giuseppe Iannello wrote:
>> Hello everybody.
>> I have a big problem with my suphp setup. The environment is a debian 
>> lenny server, with jails for users.
>> I installed suphp using debian sid packages, because I wanted 0.7.1 
>> version
>> The jails are in /var/jail/$USERNAME, and contains a base filesystem 
>> and the user's home directory in /home/$USERNAME.
>>
>> my suphp configuration is the following
>> -- 
>> ;Path all scripts have to be in
>> docroot=/var/www:${HOME}/public_html
>>
>> ;Path to chroot() to before executing script
>> chroot=/var/jail/${USERNAME}
>> -- 
>> the php files are in the jail, under /home/$USERNAME/public_html/www/
>>
>> when I try to load the page with a browser, i get this 
>> (/var/log/apache2/error.log - username is "test")
>> -- 
>> [Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] 
>> SoftException in Application.cpp:537: Could not execute script 
>> "/var/jail/test/home/test/public_html/www/index.php"
>> [Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] Caused by 
>> SystemException in API_Linux.cpp:465: chdir() failed: No such file or 
>> directory
>> [Wed Oct 14 15:39:57 2009] [error] [client 92.243.1.112] Premature 
(Continue reading)

Giuseppe Iannello | 14 Oct 21:52 2009

Re: suphp 0.7.1 + chroot

In data mercoledì 14 ottobre 2009 18:33:35, Hugo Monteiro ha scritto:
> Hugo Monteiro wrote:
> > Hi Giuseppe,
> >
> > From what i know, that has always been suphp's default behaviour. Also
> > I don't understand why can't the path be rewritten since suphp already
> > knows it's a chroot it's dealing with. Also I would like to be able to
> > use it without having to symblink back.

That's true. It happened also with 0.6.3, but the patch you talked about 
solved it.

> > I also take this chance to ask once again[1] about a patch proposal
> > sent February 2006, by Jan Ahrens.[2]

I partially agree. that patch adds a (imho) useless way to load different 
config files based on the apache vhost configuration.
Is it so 

> > The proposed approach would allow greater flexibility, and i don't see
> > any technical reason why not to be like that.

Well, actually I don't any reason to NOT do that.
Looking through the code, it seems that a method to clean up the path is 
there, but...does it actually work?

> > Could someone clarify please?
> >
> > Best regards,
> >
(Continue reading)

Hugo Monteiro | 14 Oct 23:00 2009
Picon

Re: suphp 0.7.1 + chroot

Giuseppe Iannello wrote:
> In data mercoledì 14 ottobre 2009 18:33:35, Hugo Monteiro ha scritto:
>   
>> Hugo Monteiro wrote:
>>     
>>> Hi Giuseppe,
>>>
>>> From what i know, that has always been suphp's default behaviour. Also
>>> I don't understand why can't the path be rewritten since suphp already
>>> knows it's a chroot it's dealing with. Also I would like to be able to
>>> use it without having to symblink back.
>>>       
>
> That's true. It happened also with 0.6.3, but the patch you talked about 
> solved it.
>
>   
>>> I also take this chance to ask once again[1] about a patch proposal
>>> sent February 2006, by Jan Ahrens.[2]
>>>       
>
> I partially agree. that patch adds a (imho) useless way to load different 
> config files based on the apache vhost configuration.
> Is it so 
>
>   

Why useless? It allows you to have multiple suphp configurations. True 
that the suphp.conf file will reside inside the chroot, but maybe that 
can be changed.
(Continue reading)

Giuseppe Iannello | 14 Oct 23:18 2009

Re: suphp 0.7.1 + chroot + (not working) patch

In data mercoledì 14 ottobre 2009 21:52:20, Giuseppe Iannello ha scritto:
> Looking through the code, it seems that a method to clean up the path is
> there, but...does it actually work?

After looking at it...well, there is NO method to clean scriptFilename.
here it is, in all the diff -Naur glory

----CUT HERE----
--- suphp-0.7.1/src/Application.cpp     2009-03-14 17:55:25.000000000 +0000
+++ suphp-0.7.1-edit/src/Application.cpp        2009-10-14 20:18:04.000000000 
+0000
 <at>  <at>  -106,6 +106,7  <at>  <at> 
             PathMatcher pathMatcher = PathMatcher(targetUser, targetGroup);
             std::string chrootPath = 
pathMatcher.resolveVariables(config.getChrootPath());
             api.chroot(chrootPath);
+           scriptFilename = 
pathMatcher.rewriteChrootedScriptPath(scriptFilename, chrootPath);
         }

         this->changeProcessPermissions(config, targetUser, targetGroup);

--- suphp-0.7.1/src/PathMatcher.cpp     2008-03-31 00:15:54.000000000 +0000
+++ suphp-0.7.1-edit/src/PathMatcher.cpp        2009-10-14 20:32:12.000000000 
+0000
 <at>  <at>  -175,3 +175,10  <at>  <at> 
     }
     return out;
 }
+
(Continue reading)

Giuseppe Iannello | 14 Oct 23:22 2009

Re: suphp 0.7.1 + chroot

In data mercoledì 14 ottobre 2009 23:00:39, Hugo Monteiro ha scritto:
> Why useless? It allows you to have multiple suphp configurations. True
> that the suphp.conf file will reside inside the chroot, but maybe that
> can be changed.
> The benifits are clear, i think...

Sorry, I was talking about my own case. You're right, btw

> It does. I've used that patch several times before and the path does get
> translated.

Version 0.6.3
I'm talking about 0.7.1, which allows to have a different chroot() directory 
for every user.

>  From what i could tell, everything worked as advertised by the patch
> author.

Yep, 0.6.3 works.

--
Giuseppe Iannello
System administrator
Speakage s.r.l.
Kai | 15 Oct 15:02 2009
Picon

Re: force all php.ini to /home/user/

Hello,
 
you can set the location of the php.ini in your httpd.conf in each VirtualHost:
 
<Files *.php>
SetEnv PHPRC /path/to/your/php/ini
</Files>
 
Please, use only the path to the location e.g. /home/user/user1 and not the complete path like /home/user/user1/php.ini.
If you or your users user different files than *.php you need to add for each fileending an entry in your httpd.conf.
 
Regards
 
Kai
----- Original Message -----
Sent: Tuesday, September 22, 2009 9:21 AM
Subject: [suPHP] force all php.ini to /home/user/

Hello,

is it possible to set the default location for php.ini for all the users in the users home directory
like
application/x-httpd-php5=/usr/local/lib/
but the path to be /home/user/
so the user cannot create other php.ini files

regards,
Cosmin

_______________________________________________
suPHP mailing list
suPHP-qhrM8SXbD5JCREYaNQg7v0EOCMrvLtNR@public.gmane.org
https://lists.marsching.com/mailman/listinfo/suphp
_______________________________________________
suPHP mailing list
suPHP@...
https://lists.marsching.com/mailman/listinfo/suphp
cyp | 15 Oct 15:34 2009
Picon

Re: force all php.ini to /home/user/

Kai wrote:
> Hello,
>  
> you can set the location of the php.ini in your httpd.conf in each
> VirtualHost:
>  
> <Files *.php>
> SetEnv PHPRC /path/to/your/php/ini
> </Files>
>  
> Please, use only the path to the location e.g. /home/user/user1 and not
> the complete path like /home/user/user1/php.ini.
> If you or your users user different files than *.php you need to add for
> each fileending an entry in your httpd.conf.
>  
> Regards
>  
> Kai
> 

Hi Kai,

http://www.suphp.org/DocumentationView.html?file=apache/CONFIG

suPHP_ConfigPath (expects a path name)
  ^^^^^^^^^^

This option tells mod_suphp which path to pass on to the PHP-interpreter
(by setting the PHPRC environment variable).
Do *NOT* refer to a file but to the directory the file resists in.

E.g.: If you want to use "/path/to/server/config/php.ini", use
"suPHP_ConfigPath /path/to/server/config".

For you

suPHP_ConfigPath /home/user/user1/
suPHP_ConfigPath /home/user/user2/
suPHP_ConfigPath /home/user/userx/

Regards
--

-- 

++

Cyp

Smilie: using tomorrow's energy today.

Gmane