| Author |
mod_userdir getpwnam override?
|
|
| dbarstis@gmail.com 2006-11-20, 7:23 pm |
| Back in the day when I was the webmaster, I hacked the apache code to
call a custom getpwnam routine that retrieved the user's home directory
from a dbm file we generated nightly (we have over 30,000 users we
didn't want in the /etc/passwd file).
Now I find myself back in the position and want to know if there's a
module or configuration option that will allow me to override the
getpwnam function call to /etc/passwd without having to hack the code.
Any and all help would be greatly appreciated.
Thanks,
Dave
| |
| petersprc 2006-11-21, 1:31 am |
| Hi,
You could probably use mod_rewrite's RewriteMap directive. It can map
URLs based on a dbm file or other data sources. Some more info is here:
<http://httpd.apache.org/docs/1.3/mo...html#RewriteMap>
dbarstis@gmail.com wrote:
> Back in the day when I was the webmaster, I hacked the apache code to
> call a custom getpwnam routine that retrieved the user's home directory
> from a dbm file we generated nightly (we have over 30,000 users we
> didn't want in the /etc/passwd file).
>
> Now I find myself back in the position and want to know if there's a
> module or configuration option that will allow me to override the
> getpwnam function call to /etc/passwd without having to hack the code.
>
> Any and all help would be greatly appreciated.
>
> Thanks,
> Dave
| |
| dbarstis@gmail.com 2006-11-21, 1:20 pm |
| Thanks for the information. Do you know where I might find a specific
example? I've found:
RewriteEngine On
RewriteMap user-dir txt:/usr/local/apache2/conf/userdir.txt
RewriteRule ^/~([^/]+)/(.*)$ ${user-dir:$1}/$2
RewriteLog /usr/local/apache2/logs/rewrite.log
RewriteLogLevel 2
/usr/local/apache2/conf/userdir.txt looks like this:
user1 /export/home/user1
Also:
RewriteMap user-dir txt:usr/local/apache2/conf/userdir.txt
RewriteEngine On
RewriteCond ${user-dir txt:$1|lookupfailed} (.*)
RewriteCond %1 !lookupfailed
RewriteRule ^/~([^/]+)/(.*)$ /%1/$2 [L]
# Trailing-Slash Redirect
RewriteCond ${user-dir txt:$1|lookupfailed} (.*)
RewriteCond %1 !lookupfailed
RewriteRule ^/~([^/]+)$ /~$1/
[L,R=301]
Anything special needed for dbm's?
petersprc wrote:[vbcol=seagreen]
> Hi,
>
> You could probably use mod_rewrite's RewriteMap directive. It can map
> URLs based on a dbm file or other data sources. Some more info is here:
>
> <http://httpd.apache.org/docs/1.3/mo...html#RewriteMap>
>
>
> dbarstis@gmail.com wrote:
| |
| dbarstis@gmail.com 2006-11-21, 1:20 pm |
| Yes, I know MapType needs to be dbm.
Dave
dbarstis@gmail.com wrote:[vbcol=seagreen]
> Thanks for the information. Do you know where I might find a specific
> example? I've found:
>
> RewriteEngine On
> RewriteMap user-dir txt:/usr/local/apache2/conf/userdir.txt
> RewriteRule ^/~([^/]+)/(.*)$ ${user-dir:$1}/$2
> RewriteLog /usr/local/apache2/logs/rewrite.log
> RewriteLogLevel 2
>
> /usr/local/apache2/conf/userdir.txt looks like this:
> user1 /export/home/user1
>
> Also:
>
> RewriteMap user-dir txt:usr/local/apache2/conf/userdir.txt
> RewriteEngine On
> RewriteCond ${user-dir txt:$1|lookupfailed} (.*)
> RewriteCond %1 !lookupfailed
> RewriteRule ^/~([^/]+)/(.*)$ /%1/$2 [L]
> # Trailing-Slash Redirect
> RewriteCond ${user-dir txt:$1|lookupfailed} (.*)
> RewriteCond %1 !lookupfailed
> RewriteRule ^/~([^/]+)$ /~$1/
> [L,R=301]
>
> Anything special needed for dbm's?
>
>
> petersprc wrote:
| |
| dbarstis@gmail.com 2006-11-21, 1:20 pm |
| The RewriteRule is working but the UserDir variable is ignored so I'll
have to append that to the rule.
Just an FYI for anyone else that wants to implement this.
dbarstis@gmail.com wrote:[vbcol=seagreen]
> Yes, I know MapType needs to be dbm.
>
> Dave
>
> dbarstis@gmail.com wrote:
|
|
|
|