You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Rob Giseburt <ro...@eatech.net> on 2000/08/01 20:27:25 UTC

User directive

I want to modify the User cofiguration directive in a perl handler ... for
example in a PerlTransHandler. I'm trying to use mod_perl to implement Named
Virtual Hosting, and I have everything I need done except User and Group
mapping so that SuEXEC will pick up the correct user and group to setuid the
non-mod_perl CGI execution to. I cannot find what variable to change. I know
that in a <Perl>...</Perl> section it's simple $User, but in a
PerlTransHandler context it seems you can only view it via $r->server->uid.
Any suggestions?

Thanks,
-Rob Giseburt

--------------------------------
Random Quote:
 "He who laughs last, thinks slowest."
 (author unknown)
--------------------------------


Re: User directive

Posted by George Sanderson <ge...@xorgate.com>.
At 10:20 PM 8/15/00 -0700, you wrote:
>>you want to change the uid at request time?  the patch below will let you
>say $r->server->uid($new_uid);
>
>you'll have to maintain changing it back yourself, like so:
>
>my $old_uid = $r->server->uid($new_uid);
>$r->register_cleanup(sub { shift->server->uid($old_uid) });
>
I want to set the UID of a file, perhaps as follows:
1) from within mod_perl (with the patch applied) call
$r->server->uid($new_uid).
2) change the UID of a file to $new_uid .
3) set the file permisions to 750, where the GID is Apache child GID.
3) call $r->server->uid($old_uid).

I have tried creating a new fill after a $r->server->uid($new_uid), but it
still has the original Apache child UID.

>i'm not sure if we should allow this or not, security implications?
>
>--- src/modules/perl/Server.xs  1999/08/20 08:34:43     1.6
>+++ src/modules/perl/Server.xs  2000/08/16 05:19:54
>@@ -151,11 +151,16 @@
>     RETVAL
> 
> uid_t
>-uid(server)
>+uid(server, id=0)
>     Apache::Server     server
>+    uid_t id
> 
>     CODE:
>     RETVAL = server->server_uid;
>+
>+    if (items > 1) {
>+        server->server_uid = id;
>+    }
> 
>     OUTPUT:
>     RETVAL
> 


Re: User directive

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 1 Aug 2000, Rob Giseburt wrote:

> I want to modify the User cofiguration directive in a perl handler ... for
> example in a PerlTransHandler. I'm trying to use mod_perl to implement Named
> Virtual Hosting, and I have everything I need done except User and Group
> mapping so that SuEXEC will pick up the correct user and group to setuid the
> non-mod_perl CGI execution to. I cannot find what variable to change. I know
> that in a <Perl>...</Perl> section it's simple $User, but in a
> PerlTransHandler context it seems you can only view it via $r->server->uid.
> Any suggestions?

you want to change the uid at request time?  the patch below will let you
say $r->server->uid($new_uid);

you'll have to maintain changing it back yourself, like so:

my $old_uid = $r->server->uid($new_uid);
$r->register_cleanup(sub { shift->server->uid($old_uid) });

i'm not sure if we should allow this or not, security implications?

--- src/modules/perl/Server.xs  1999/08/20 08:34:43     1.6
+++ src/modules/perl/Server.xs  2000/08/16 05:19:54
@@ -151,11 +151,16 @@
     RETVAL
 
 uid_t
-uid(server)
+uid(server, id=0)
     Apache::Server     server
+    uid_t id
 
     CODE:
     RETVAL = server->server_uid;
+
+    if (items > 1) {
+        server->server_uid = id;
+    }
 
     OUTPUT:
     RETVAL