Re: SetEnvIf failure or success?

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

 



Eric Covener wrote:
On Thu, Mar 22, 2012 at 10:18 AM, J.Lance Wilkinson <jlw12@xxxxxxx> wrote:
I'm trying to extract part of a URI into an environment variable to use in
an authorization scheme (let's skip talking about how I'll USED that
variable for the moment).

I have the following directives in my configuration:

LogFormat "%h %l %u %t \"%r\" %>s %b UMG=%{UMG}e" umgs
CustomLog logs/umg.log umgs
       ...
   <Location ~ "^/(.*)/umg/.(.*)(.html|/(.*)?)$">
       ...
   SetEnvIf REQUEST_URI "^/(.*)/umg/.(.*)(.html|/(.*)?)$" UMG=$2
       ...
   </Location>
>>
When I watch that log file, and hit resources that match that location, I'm
seeing entries in the log which suggest a value for the UMG variable is not
being extracted:

xxx.xxx.xxx.xxx - jlw12 [22/Mar/2012:09:31:13 -0400] "GET
       /umgs/umg.up.dlt.sslcerts.mgttool HTTP/1.1" 301 455 UMG=-
xxx.xxx.xxx.xxx - jlw12 [22/Mar/2012:09:31:25 -0400] "GET
       /umgs/umg.up.dlt.ul.gml.managers HTTP/1.1" 301 454 UMG=-

I'd expected to see UMG=up.dlt.sslcerts.mgttool and
UMG=up.dlt.ul.gml.managers on these two log lines.

Several thoughts come to mind:
1) Logging is taking place before the SetEnvIf takes place.

definitely not
	That's good to be certain of...

2) Miscoding of Location's regular expression is causing SetEnvIf to be
       bypassed.

easy to test, locationmatch not needed if you're already comparing
against the URI in the setenvif.

	I moved the SetEnvIf outside the <Location/> stanza.  No change.

3) Miscoding of SetEnvIf's regular expression is causing SetEnvIf to fail.

likely, the "pcretest" program says it doesn't match.

	I changed my regular expression to read
		
		@^/(.*)/umg-(.*)(.html|/(.*)?)$@

	(I can get away with this now, during development.)

	Thus I would want to match URIs like:

		/umgs/umg-up.dlt.sslcerts.mgttool/umgs.php

	By changing the period to a hyphen it eliminates the whole
	escaping thing I was doing with /. that I should have been
	doing with \. or just . that Mysterious Mose <webmaster@xxxxxxxxxxxxx>
	caught earlier.


This string would need either a .html or another / to match, right?

@^/(.*)/umg/.(.*)(.html|/(.*)?)$@
     /umgs
           /umg.up.dlt.sslcerts.mgttool  (never found .html or /)

Maybe you meant the ? to apply to the entire alternation and not the .*?
	
	I do.  It should never receive anything without either
	a .html or a trailing / (and probably other content) but I guess
	that's a separate excercise since I see without one of them the
	matching fails.

>> 4) Miscoding of SetEnvIf's value specification is causing failure.
>
> easy to test w/ a literal value, not likely the case though.
>
	$ pcretest
PCRE version 7.8 2008-09-05
  re>  @^/(.*)/umg-(.*)(.html|/(.*)?)$@
data> /umgs/umg-up.dlt.sslcerts.mgttool/umgs.php
 0: /umgs/umg-up.dlt.sslcerts.mgttool/umgs.php
 1: umgs
 2: up.dlt.sslcerts.mgttool
 3: /umgs.php
 4: umgs.ph
data> /long/arbitrary/prefix/umg-ul.dlt.ul.gml.managers/
 0: /long/arbitrary/prefix/umg-ul.dlt.ul.gml.managers/
 1: long/arbitrary/prefix
 2: ul.dlt.ul.gml.managers
 3: /
 4:
data> /long/arbitrary/prefix/umg-up.dlt.spamfratch.society/membership.report
 0: /long/arbitrary/prefix/umg-up.dlt.spamfratch.society/membership.report
 1: long/arbitrary/prefix
 2: up.dlt.spamfratch.society
 3: /membership.report
 4: membership.report
data>

	So, I want the UMG variable to match the #2 result.

	Transcribing these values into my config

	
	...
LogFormat "%h %l %u %t \"%r\" %>s %b UMG=%{UMG}e" umgs
CustomLog logs/umg.log umgs
	...
SetEnvIf REQUEST_URI "^/(.*)/umg-(.*)(.html|/(.*)?)$" UMG=$2

	I still see no value for the UMG variable, suggesting that it's still a
	regular expression issue OR miscoding of the value specification (or
	UMG)

xxx.xxx.xxx.xxx - - [22/Mar/2012:11:36:06 -0400] "GET 	
	/umgs/umg-up.dlt.sslcerts.mgttool/umgs.php HTTP/1.1" 401 1837 UMG=-

	So I change my SetEnvIf directive to specify an explict value for UMG
	to be equal to, I still see UMG=- in the log:

SetEnvIf REQUEST_URI "^/(.*)/umg-(.*)(.html|/(.*)?)$" UMG=arbitrary

	And I still see the same empty results (UMG=- logged).

	I try enclosing the assigned value as a text string:

SetEnvIf REQUEST_URI "^/(.*)/umg-(.*)(.html|/(.*)?)$" UMG="arbitrary"

	And I still see the same empty results (UMG=- logged).

This suggests the SetEnvIf pattern match is failing, because otherwise I SHOULD be getting a value of "arbitrary" assigned, right?

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




--
J.Lance Wilkinson ("Lance")		InterNet: Lance.Wilkinson@xxxxxxx
Systems Design Specialist - Lead	Phone: (814) 865-4870
Digital Library Technologies		FAX:   (814) 863-3560
E3 Paterno Library
Penn State University
University Park, PA 16802

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