Mark James wrote:
Stas Bekman wrote:

Mark James wrote:

Some of my scripts break when running under mp2 (cvs) because the UID
is set as root rather than the Apache user (which for me is "web").
The problem manifests with RCS file locking. Is there some switch
to set so that I can run scripts as "web"?


Eh? Are you talking about 'make test' or installed mod_perl? If the former, use the latest cvs where this should work if the latter, modify httpd.conf.


The latter. Turned out to be a caused by the perl ENV not being
propogated to forked programs:
http://perl.apache.org/docs/2.0/user/troubleshooting/troubleshooting.html#C_Libraries_Don_t_See_C__ENV__Entries_Set_by_Perl_Code

Well, actually this is not the case. It behaves exactly the same as in modperl 1.0. You can use Env::C module (available from CPAN) to easily debug this:


The following snippet prints the same under mp1 and mp2 (assuming that they are started under the same username)
print map { "Perl: $ENV{$_} C: " . Env::C::getenv($_) . "\n"} qw(USER);
print "$< ", scalar getpwuid($<), "\n";


Fixed by adding:

$ENV{'USER'} = 'web';
$ENV{'LOGNAME'} = 'web';

to the start-up script.

Indeed. The point is that ENV is not passed from shell, you have to explicitly do that and this is an Apache thing. So you can do:


SetEnv USER web

or as you did, in perl.

In any case you probably want to rely on getpwuid($<), rather than $ENV{USER} if applicable.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to