This is a discussion on mod_userdir getpwnam override? within the Apache Web Server forums, part of the Web Server and Related Forums category; Back in the day when I was the webmaster, I hacked the apache code to call a custom getpwnam routine ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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/mod/mod_rewrite.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 |
|
|||
|
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: > 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/mod/mod_rewrite.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 |
|
|||
|
Yes, I know MapType needs to be dbm.
Dave dbarstis@gmail.com wrote: > 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: > > 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/mod/mod_rewrite.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 |
|
|||
|
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: > Yes, I know MapType needs to be dbm. > > Dave > > dbarstis@gmail.com wrote: > > 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: > > > 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/mod/mod_rewrite.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 |