Re: Get UID/GID from a username string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> Well, it is one option to extend mod_rewrite. What I meant
>> specifically was that any module can implement a rewritemap internal
>> function.
> 
> Yes, the feature seems to be a bit too specific for general implementation in mod_rewrite.

I was thinking about mod_rewrite because these functions would have then been easily available to everyone.
And quite easy to develop, as it only requires to extend the existing functions catalog :)
But quite specific I agree.

> Ben: have a look at how mod_rewrite accesses its own ap_register_rewrite_mapfunc via
> 
> map_pfn_register = APR_RETRIEVE_OPTIONAL_FN(ap_register_rewrite_mapfunc);
> 
> Any module can access the function using this construct. And then mod_rewrite registers builtin rewrite map functions e.g. like
> 
> map_pfn_register("escape", rewrite_mapfunc_escape);
> 
> Your own module can also register your own functions like myuid and mygid:
> 
> map_pfn_register("myuid", my_mapfunc_uid);
> 
> Then you can configure a RewriteMap to use these functions and they will call directly the my_mapfunc_uid function in your module to get the uid without the need of an external process with locking etc.

Many thanks Rainer for this howto !
I have never written a module from scratch, but I found the documentation :
https://httpd.apache.org/docs/2.4/developer/modguide.html
Does not seems so difficult to just register some new rewritemap functions.

> In short: the list of builtin functions for RewriteMap is extensible and can be extended by 3rd-arty modules using the above method.
> 
> If uid and gid alone isn't powerful enough, you can code whatever logic you need in your map function and register it with a name that is reasonable for you and doesn't clash with what's already there in mod_rewrite.

Sounds perfect, again, many thanks Rainar !

>> On Fri, Apr 15, 2016 at 12:19 PM, Ben RUBSON <ben.rubson@xxxxxxxxx> wrote:
>>>>> I can't think of any solution that would work out of the box, but
>>>>> you can always write your own apache module in C.
>>>> 
>>>> 
>>>> Which could provide nothing but a new internal rewritemap type.
>>> 
>>> Rainer, Eric,
>>> Thank you very much for your feedback.
>>> 
>>> Yes a new rewritemap seems to be the solution.
>>> type name : usr
>>> functions : uid, gid
>>> parameter : name or #uid
>>> 
>>> For example :
>>> RewriteMap getuid usr:uid
>>> RewriteMap getgid usr:gid
>>> 
>>> C functions getpwnam and getpwuid would do the job.
>>> 
>>> Is a pull request here the right method to proceed ?
>>> https://github.com/apache/httpd/blob/trunk/modules/mappers/mod_rewrite.c
>>> 
>>> Thank you very much,
>>> 
>>> Ben


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux