RE: [users@httpd] how to alter and use environmanet vaaiables with mod_rewrite

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

 



Here it goes:

   # Initialise an environment variable with some stuff
   RewriteCond %{ENV:DN}        =""
   RewriteRule .*               -               [E=DN:/A/B/C/D]

   # Substitute a / in DN with _ and start over again (N-flag) until there are no more /
   RewriteCond %{ENV:DN}        (.*)/(.*)
   RewriteRule .*               -               [N,E=DN:%1_%2]
 
   # Insert other rules to rewrite the URI using %{ENV:DN} below

You will need to modify the initialisation of DN in order for %{ENV:SSL_CLIENT_S_DN} to be the initial value, and write the rules that rewrite the URI...

-ascs

-----Original Message-----
From: Tilman Baumann [mailto:tilman.baumann@xxxxxxxxxx] 
Sent: Thursday, June 09, 2005 2:18 PM
To: users@xxxxxxxxxxxxxxxx
Subject: [users@httpd] how to alter and use environmanet vaaiables with mod_rewrite

Hi,

i have a problem which is seem to be swamped with.
I want to make a substitute on a variable for later use in mod_rewrite.

I have users which are Authorizing themselves via ssl cleint auth  
(mod_ssl and +FakeBasicAuth)
These users access all the same url (they are relatively dump  
scripts) and each has to get a file which is specialy stored for him.

My plan was to make each user a directory which is constructet out of  
the DN of his certificate. It would be easy to map a request from / 
licenses/ to /licenses/%{ENV:SSL_CLIENT_S_DN}/

But unfortunately a DN contains slashes like this:
/C=DE/L=Freiburg/O=Pyramid Computer GmbH/OU=Solutions Update Service/ 
CN=6281
Well, so i have to change the slashes in %{ENV:SSL_CLIENT_S_DN} to  
something different.
Maybe underlines.

I have no idea to change the slashes in this variable (or better a  
copy of it) and then use it in mod_rewrite.
Any ideas how to make this?


I also tried a rewrite_program, but all happens is that apache does  
not accept any connection after that. :)
But i am verry unhappy with the idea to call a programm each request.  
So i like to do it in another way.

Here my buggy script:
#!/usr/bin/perl
#   disable buffered I/O which would lead
#   to deadloops for the Apache server
$| = 1;
#   read URLs one per line from stdin and
#   generate substitution URL on stdout

while (<>) {
                 my $dn = $ENV{'SSL_CLIENT_S_DN'};
                 $dn =~ s|/|\\|;
                 s|(.*)|$1/$dn|;
print $_;
}


Thanks for any help.
--
Tilman Baumann
Pyramid Computer
Tel: +49 (7 61) 46 14-837


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-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