You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Paul Flinders <pa...@dawa.demon.co.uk> on 2003/11/27 23:40:09 UTC

mod_perl2, Apache::PageKit and $s->uid

I'm currently investigating using Apache::PageKit to develop
a web application.

I'm more-or-less constrained to use Apache 2 by the environmental
requirements for the project which means mod_perl2 and libapreq2.
I realise that this is something of an experimental brew, especially
as PageKit doesn't claim to support mod_perl2 yet.

At present I'm not getting much further than the start-up code. The
sequence

  my $s = Apache->server;

  my $uid = $s->uid;
  my $gid = $s->gid;

gives me

Syntax error at /etc/httpd/conf.d/perl.conf:66
   Can't locate object method "uid" via package "Apache::Server"
   at /usr/lib/perl5/site_perl/5.8.0/Apache/PageKit.pm line 61.

Neither Apache::compat, Apache::porting nor the migration documentation
seem to have any hints.

How do I accomplish the above in mod_perl2?

(this is with Apache 2.0.47, perl 5.8.0, mod_perl 1.99_11 and 
Apache::PageKit 1.12)


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: mod_perl2, Apache::PageKit and $s->uid

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>>>> my $uid = $s->uid;
>>>>> my $gid = $s->gid;
> 
> 
>>Include yes, but how should it be coded.
> 
> 
> is apr_uid_current equivalent to the old s->server_uid/gid?  if so, we could
> open up part of APR::User.

No, it's not. It gives you the same as perl's $< and $(.

s->server_uid/gid give you the User/Group setting for that server. Therefore 
at the server startup, if running as 'root' and the setting is 'User nobody', 
you want to get this 'nobody' value, and not 'root'. $< and apr_uid_current 
will both give you root's uid.

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


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: mod_perl2, Apache::PageKit and $s->uid

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>>>  my $uid = $s->uid;
>>>>  my $gid = $s->gid;

> Include yes, but how should it be coded.

is apr_uid_current equivalent to the old s->server_uid/gid?  if so, we could
open up part of APR::User.

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: mod_perl2, Apache::PageKit and $s->uid

Posted by Stas Bekman <st...@stason.org>.
Paul Flinders wrote:
> Stas Bekman wrote:
> 
>> Paul Flinders wrote:
>>
>>> At present I'm not getting much further than the start-up code. The
>>> sequence
>>>
>>>  my $s = Apache->server;
>>>
>>>  my $uid = $s->uid;
>>>  my $gid = $s->gid;
>>>
>>> gives me
>>>
>>> Syntax error at /etc/httpd/conf.d/perl.conf:66
>>>   Can't locate object method "uid" via package "Apache::Server"
>>>   at /usr/lib/perl5/site_perl/5.8.0/Apache/PageKit.pm line 61.
>>>
>>
>> Paul, you've just spotted two methods that we have forgotten to port 
>> to mp2.
> 
> 
> Ah, good (in the sense that it wasn't something that I missed
> in the documentation).
> 
> Actually PageKit doesn't seem to use the values - will have a more
> detailed look after the W/E and check on the PageKit mailing lists.
> 
> I definitely think that Apache::compat (and Apache::porting) should include
> these methods.

Include yes, but how should it be coded. Once we figure out that part it'll be 
in Apache::porting as well.


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


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: mod_perl2, Apache::PageKit and $s->uid

Posted by Paul Flinders <pa...@dawa.demon.co.uk>.
Stas Bekman wrote:

> Paul Flinders wrote:
>
>> At present I'm not getting much further than the start-up code. The
>> sequence
>>
>>  my $s = Apache->server;
>>
>>  my $uid = $s->uid;
>>  my $gid = $s->gid;
>>
>> gives me
>>
>> Syntax error at /etc/httpd/conf.d/perl.conf:66
>>   Can't locate object method "uid" via package "Apache::Server"
>>   at /usr/lib/perl5/site_perl/5.8.0/Apache/PageKit.pm line 61.
>>
>
> Paul, you've just spotted two methods that we have forgotten to port 
> to mp2.

Ah, good (in the sense that it wasn't something that I missed
in the documentation).

Actually PageKit doesn't seem to use the values - will have a more
detailed look after the W/E and check on the PageKit mailing lists.

I definitely think that Apache::compat (and Apache::porting) should include
these methods.



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: mod_perl2, Apache::PageKit and $s->uid

Posted by Stas Bekman <st...@stason.org>.
Paul Flinders wrote:
> I'm currently investigating using Apache::PageKit to develop
> a web application.
> 
> I'm more-or-less constrained to use Apache 2 by the environmental
> requirements for the project which means mod_perl2 and libapreq2.
> I realise that this is something of an experimental brew, especially
> as PageKit doesn't claim to support mod_perl2 yet.
> 
> At present I'm not getting much further than the start-up code. The
> sequence
> 
>  my $s = Apache->server;
> 
>  my $uid = $s->uid;
>  my $gid = $s->gid;
> 
> gives me
> 
> Syntax error at /etc/httpd/conf.d/perl.conf:66
>   Can't locate object method "uid" via package "Apache::Server"
>   at /usr/lib/perl5/site_perl/5.8.0/Apache/PageKit.pm line 61.
> 
> Neither Apache::compat, Apache::porting nor the migration documentation
> seem to have any hints.
> 
> How do I accomplish the above in mod_perl2?

Paul, you've just spotted two methods that we have forgotten to port to mp2.

I've looked at the sources of apache-1.3 and httpd-2.0 and here is what 
happening: apache-1.3 had server_rec records for server_uid and server_gid. 
httpd-2.0 doesn't have them, because httpd-2.0 the directives User and Group 
are platform specific. And only UNIX supports it, as you can see:
http://httpd.apache.org/docs-2.0/mod/mpm_common.html#user

Therefore it looks like we can't support these functions in mp2.

I guess we could try adding to compat.pm

sub Apache::Server::uid { $< }
sub Apache::Server::gid { $( }

Can anybody see problems with this approach?

I'm not sure we will be able emulate it correctly if you were relying on 
User/Group setting for suexec, which now uses a new directive SuexecUserGroup.
http://httpd.apache.org/docs-2.0/mod/mod_suexec.html#suexecusergroup
You can always get the real uid of the process with $< and real gid with $(.

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


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html