mod_rewrite racing condition problem ?

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

 



Greetings apache users - I hope I selected the right list for this question:


I have a wierd mod_rewrite problem, that I need new eyes on.

What I try to do accomplish:

I am implementing “Userdirs” using mod_rewrite, with users in LDAP

The filepath is fetched from LDAP using a perl map program (with
ram-caching, for fast response, the programs does 20k responses in
0.2s, so it’s not a bottleneck)

Mod_rewrite config:


RewriteEngine on
RewriteLog /var/log/rewriter-log
RewriteLogLevel 9

#userdir via mod-rewrite via ldap via perl
RewriteMap    lowercase    int:tolower
# rewrite script with ldap lookup
RewriteMap    uid-til-user prg:/home/scripts/users.homepage.pl
# rewrite on host match
RewriteCond   ${lowercase:%{HTTP_HOST}|NONE}  ^users\.example\.tld$
#get userid and path and rewrite
RewriteRule ^/~(.*?)/(.*?)$ /${uid-til-user:$1|fejl}$2


I have a simple static HTML page, with 20 images

<pre>

 1<img src="image1.jpg">

 2<img src="image2.jpg">

…etc…

19<img src="image19.jpg">

20<img src="image20.jpg">

</pre>


Fetching this page gives this rewritelog (| cut -d"/" -f4- for shorter line)

sid#80161a730][rid#8017ca0a0/initial] (2) init rewrite engine with
requested uri /~ccc2404/example/image11.jpg

sid#80161a730][rid#8017ca0a0/initial] (3) applying pattern
'^/~(.*?)/(.*?)$' to uri '/~ccc2404/example/image11.jpg'

sid#80161a730][rid#8017c80a0/initial] (2) rewrite
'/~ccc2404/example/image9.jpg' -> '/2404/example/image9.jpg'

sid#80161a730][rid#8017c80a0/initial] (2) local path result:
/2404/example/image9.jpg

sid#80161a730][rid#8017c80a0/initial] (2) prefixed with document_root
to /home/www/data/2404/example/image9.jpg

sid#80161a730][rid#8017ce0a0/initial] (2) rewrite
'/~ccc2404/example/image10.jpg' ->
'//mail/7/1/0/1/0/442//web/ccc/mail/7/1/0/1/0/442//web/ccc2404/example/image10.jpg'

sid#80161a730][rid#8017c80a0/initial] (1) go-ahead with
/home/www/data/2404/example/image9.jpg [OK]



image9 is loaded fine !



then comes TWO inits with SAME rid (8017c80a0)



the map program returns

//mail/7/1/0/1/0/442//web/ccc/mail/7/1/0/1/0/442//web/ccc2404/
//mail/7/1/0/1/0/442//web/ccc/mail/7/1/0/1/0/442//web/ccc2404/

But somehow the two answers get “mixed”

'/~ccc2404/example/image13.jpg' -> '/ml7101042/eb/ccc2404/example/image13.jpg'

'/~ccc2404/example/image18.jpg' ->
'//ai//////4/w/mail/7/1/0/1/0/442//web/ccc2404/example/image18.jpg'



Full log here:



sid#80161a730][rid#8017c80a0/initial] (2) init rewrite engine with
requested uri /~ccc2404/example/image13.jpg

sid#80161a730][rid#8017c80a0/initial] (2) init rewrite engine with
requested uri /~ccc2404/example/image18.jpg

sid#80161a730][rid#8017c80a0/initial] (3) applying pattern
'^/~(.*?)/(.*?)$' to uri '/~ccc2404/example/image18.jpg'

sid#80161a730][rid#8017c80a0/initial] (3) applying pattern
'^/~(.*?)/(.*?)$' to uri '/~ccc2404/example/image13.jpg'

sid#80161a730][rid#8017c80a0/initial] (2) rewrite
'/~ccc2404/example/image13.jpg' ->
'/ml7101042/eb/ccc2404/example/image13.jpg'

sid#80161a730][rid#8017c80a0/initial] (2) local path result:
/ml7101042/eb/ccc2404/example/image13.jpg

sid#80161a730][rid#8017c80a0/initial] (2) prefixed with document_root
to /home/www/data/ml7101042/eb/ccc2404/example/image13.jpg

sid#80161a730][rid#8017c80a0/initial] (1) go-ahead with
/home/www/data/ml7101042/eb/ccc2404/example/image13.jpg [OK]

sid#80161a730][rid#8017c80a0/initial] (2) rewrite
'/~ccc2404/example/image18.jpg' ->
'//ai//////4/w/mail/7/1/0/1/0/442//web/ccc2404/example/image18.jpg'

sid#80161a730][rid#8017c80a0/initial] (2) local path result:
//ai//////4/w/mail/7/1/0/1/0/442//web/ccc2404/example/image18.jpg

sid#80161a730][rid#8017c80a0/initial] (2) prefixed with document_root
to /home/www/data/ai/4/w/mail/7/1/0/1/0/442/web/ccc2404/example/image18.jpg

sid#80161a730][rid#8017c80a0/initial] (1) go-ahead with
/home/www/data/ai/4/w/mail/7/1/0/1/0/442/web/ccc2404/example/image18.jpg
[OK]



Why does this happen ? How is “rid” calculated ?



And How do I fix the problem ?



Any hints is appreciated – I am kind of stuck here.



/Søren Schrøder



--
Søren Schrøder.
Obey Gravity - It's the law !

---------------------------------------------------------------------
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