You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2006/01/17 02:11:19 UTC

[mp2 patch] accessors for User and Group directives in httpd.conf

I've added accessors to Group and User directives in httpd.conf, so that 
now you can get that info via:

   my $user_id  = Apache2::ServerUtil->user_id;
   my $group_id = Apache2::ServerUtil->group_id;

the patch is inlined and attached (due to long lines).

Please let me know if you are happy with this approach or you want it to 
be different. (including the test).

Another concern is windows - so if someone can try to build with this 
patch on windows that would be great.

Thank you.

Index: xs/maps/modperl_functions.map
===================================================================
--- xs/maps/modperl_functions.map	(revision 367390)
+++ xs/maps/modperl_functions.map	(working copy)
@@ -87,6 +87,8 @@

  MODULE=Apache2::ServerUtil   PACKAGE=Apache2::ServerUtil
   server_rec *:DEFINE_server | | SV *:classname=Nullsv
+ uid_t:DEFINE_user_id       | | SV *:classname=Nullsv
+ gid_t:DEFINE_group_id      | | SV *:classname=Nullsv

  MODULE=Apache2::Connection
   mpxs_Apache2__Connection_client_socket | | c, s=NULL
Index: xs/Apache2/ServerUtil/Apache2__ServerUtil.h
===================================================================
--- xs/Apache2/ServerUtil/Apache2__ServerUtil.h	(revision 367390)
+++ xs/Apache2/ServerUtil/Apache2__ServerUtil.h	(working copy)
@@ -13,6 +13,8 @@
   * limitations under the License.
   */

+#include "unixd.h"
+
  #define mpxs_Apache2__ServerUtil_restart_count modperl_restart_count

  #define mpxs_Apache2__ServerRec_method_register(s, methname)     \
@@ -151,6 +153,9 @@

  #define mpxs_Apache2__ServerUtil_server(classname) 
modperl_global_get_server_rec()

+#define mpxs_Apache2__ServerUtil_user_id(classname) unixd_config.user_id
+#define mpxs_Apache2__ServerUtil_group_id(classname) unixd_config.group_id
+
  static MP_INLINE
  int mpxs_Apache2__ServerRec_is_perl_option_enabled(pTHX_ server_rec *s,
                                                 const char *name)
Index: t/response/TestApache/daemon.pm
===================================================================
--- t/response/TestApache/daemon.pm	(revision 0)
+++ t/response/TestApache/daemon.pm	(revision 0)
@@ -0,0 +1,34 @@
+package TestApache::daemon;
+
+# Apache2::ServerUtil tests
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache2::ServerUtil ();
+
+use Apache::TestUtil;
+use Apache::Test;
+
+use Apache2::Const -compile => 'OK';
+
+sub handler {
+    my $r = shift;
+
+    plan $r, tests => 2;
+
+    my $user_id = Apache2::ServerUtil->user_id;
+    ok t_cmp $user_id, $<, "user id";
+
+    my $group_id = Apache2::ServerUtil->group_id;
+    my ($expected_gid) = ($( =~ /^(\d+)/);
+
+    ok t_cmp $group_id, $expected_gid, "group id";
+
+    Apache2::Const::OK;
+}
+
+1;
+
+__END__
+

-- 
_____________________________________________________________
Stas Bekman mailto:stas@stason.org  http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book       http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/


Re: [mp2 patch] accessors for User and Group directives in httpd.conf

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>+#include "unixd.h"
>>+
> 
> 
> the only concern I have is this part.  mod_rewrite does this
> 
> #if !defined(OS2) && !defined(WIN32) && !defined(BEOS)  && !defined(NETWARE)
> #include "unixd.h"
> #define MOD_REWRITE_SET_MUTEX_PERMS /* XXX Apache should define something */
> #endif
> 
> similarly with mod_userdir, etc.  so I'd say we probably need to ifdef out
> the include and calls to unixd_config, providing some sort of default
> implementation for the above platforms.

Thanks Geoff. Fixed and committed.

-- 
_____________________________________________________________
Stas Bekman mailto:stas@stason.org  http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book       http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2 patch] accessors for User and Group directives in httpd.conf

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> +#include "unixd.h"
> +

the only concern I have is this part.  mod_rewrite does this

#if !defined(OS2) && !defined(WIN32) && !defined(BEOS)  && !defined(NETWARE)
#include "unixd.h"
#define MOD_REWRITE_SET_MUTEX_PERMS /* XXX Apache should define something */
#endif

similarly with mod_userdir, etc.  so I'd say we probably need to ifdef out
the include and calls to unixd_config, providing some sort of default
implementation for the above platforms.

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2 patch] accessors for User and Group directives in httpd.conf

Posted by Stas Bekman <st...@stason.org>.
 >>> Another concern is windows - so if someone can try to build with this
 >>> patch on windows that would be great.
 >
 >
 >> Patch looks good, at least on Linux/OSX it passes all tests 100%.
 >> It certainly would be nice to get feedback for win32 platforms before
 >> checking it in. Otherwise, I think it's a good idea.
 >
 > It should probably return 0 and 0 on win32.

The attached patch hopefully has it right.

But my main concern is the API, if everybody happy about it, I'll just 
commit it and then we will polish the corners...

-- 
_____________________________________________________________
Stas Bekman mailto:stas@stason.org  http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book       http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/


Re: [mp2 patch] accessors for User and Group directives in httpd.conf

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> 
>> Stas Bekman wrote:
>>
>>> I've added accessors to Group and User directives in httpd.conf, so that
>>> now you can get that info via:
>>>
>>>  my $user_id  = Apache2::ServerUtil->user_id;
>>>  my $group_id = Apache2::ServerUtil->group_id;
>>>
>>> the patch is inlined and attached (due to long lines).
>>>
>>> Please let me know if you are happy with this approach or you want it to
>>> be different. (including the test).
>>
>>
>>
>> I am not sure why the test is called apache/deamon ?
> 
> 
> oops, should have been apache/daemon. 

Doh! it's called apache/daemon

> The reason I've chosen it, is 
> because all the relevant code in httpd-land lives in unixd (unix daemon).
> 
> Feel free to suggest a better name.


-- 
_____________________________________________________________
Stas Bekman mailto:stas@stason.org  http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book       http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2 patch] accessors for User and Group directives in httpd.conf

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> Stas Bekman wrote:
> 
>>I've added accessors to Group and User directives in httpd.conf, so that
>>now you can get that info via:
>>
>>  my $user_id  = Apache2::ServerUtil->user_id;
>>  my $group_id = Apache2::ServerUtil->group_id;
>>
>>the patch is inlined and attached (due to long lines).
>>
>>Please let me know if you are happy with this approach or you want it to
>>be different. (including the test).
> 
> 
> I am not sure why the test is called apache/deamon ?

oops, should have been apache/daemon. The reason I've chosen it, is 
because all the relevant code in httpd-land lives in unixd (unix daemon).

Feel free to suggest a better name.

>>Another concern is windows - so if someone can try to build with this
>>patch on windows that would be great.

> Patch looks good, at least on Linux/OSX it passes all tests 100%.
> It certainly would be nice to get feedback for win32 platforms before
> checking it in. Otherwise, I think it's a good idea.

It should probably return 0 and 0 on win32.

-- 
_____________________________________________________________
Stas Bekman mailto:stas@stason.org  http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book       http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2 patch] accessors for User and Group directives in httpd.conf

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Stas Bekman wrote:
> I've added accessors to Group and User directives in httpd.conf, so that
> now you can get that info via:
> 
>   my $user_id  = Apache2::ServerUtil->user_id;
>   my $group_id = Apache2::ServerUtil->group_id;
> 
> the patch is inlined and attached (due to long lines).
> 
> Please let me know if you are happy with this approach or you want it to
> be different. (including the test).

I am not sure why the test is called apache/deamon ?

> Another concern is windows - so if someone can try to build with this
> patch on windows that would be great.

Patch looks good, at least on Linux/OSX it passes all tests 100%.
It certainly would be nice to get feedback for win32 platforms before
checking it in. Otherwise, I think it's a good idea.

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5