[squid-users] Squid regex grammar

Amos Jeffries squid3 at treenet.co.nz
Fri Oct 27 14:32:03 UTC 2017


On 28/10/17 02:59, Yuri wrote:
> 
> 
> 27.10.2017 12:01, Amos Jeffries пишет:
>> On 27/10/17 13:06, Yuri wrote:
>>> Just for clarify (it is not well-documented. At least I can't find any
>>> documentation about):
>>>
>>> Squid's regex supports only POSIX Basic grammar?
>>>
>>
>> The specific grammar depends on your regex library used to build
>> Squid, so YMMV.
>>
>> Basic POSIX is the only portable grammar that *all* regex libraries
>> can be expected to support. So Squid does not officially support other
>> grammars (yet) even if they work in your particular build.
> That's why I'm asking that the POSIX Extended in the Squid does not
> work. And it is not well documented anywhere. And there is no easy way
> to check what regex library Squid uses.
> 
> I'm trying to find it in configuration, found that:
> root @ cthulhu /patch/squid-5.0.0-patched-v2.26 # ./configure
> --help|grep regex
>    --enable-gnuregex       Compile GNUregex. Unless you have reason to
> use this
>                            Unix boxes which do not have their own regex
> library
> 

The full text there is:
  "
   --enable-gnuregex

   Compile GNUregex. Unless you have reason to use this
   option, you should not enable it. This library file
   is usually only required on Windows and very old
   Unix boxes which do not have their own regex library
   built in.
"

If you *dont* override the local environment by setting that build 
option Squid uses whatever your build tools link to with "-lregex".

> Then see ldd:
> 
> root @ cthulhu /patch/squid-5.0.0-patched-v2.26 # ldd
> /usr/local/squid/sbin/squid        libpthread.so.1 =>
> /lib/64/libpthread.so.1
>          libnettle.so.6 =>        /opt/csw/lib/amd64/libnettle.so.6
>          libmd5.so.1 =>   /lib/64/libmd5.so.1
>          libecap.so.3 =>  /usr/local/lib/libecap.so.3
>          libatomic.so.1 =>        /opt/csw/lib/amd64/libatomic.so.1
>          libssl.so.1.0.0 =>       /opt/csw/lib/amd64/libssl.so.1.0.0
>          libcrypto.so.1.0.0 =>    /opt/csw/lib/amd64/libcrypto.so.1.0.0
>          libkrb5.so.1 =>  /usr/lib/64/libkrb5.so.1
>          libstdc++.so.6 =>        /opt/csw/lib/amd64/libstdc++.so.6
>          libsocket.so.1 =>        /lib/64/libsocket.so.1
>          libresolv.so.2 =>        /lib/64/libresolv.so.2
>          libnsl.so.1 =>   /lib/64/libnsl.so.1
>          libltdl.so.7 =>  /opt/csw/lib/amd64/libltdl.so.7
>          libm.so.2 =>     /lib/64/libm.so.2
>          librt.so.1 =>    /lib/64/librt.so.1
>          libgcc_s.so.1 =>         /opt/csw/lib/amd64/libgcc_s.so.1
>          libc.so.1 =>     /lib/64/libc.so.1
>          libmp.so.2 =>    /lib/64/libmp.so.2
>          libmd.so.1 =>    /lib/64/libmd.so.1
>          libscf.so.1 =>   /lib/64/libscf.so.1
>          libaio.so.1 =>   /lib/64/libaio.so.1
>          libdoor.so.1 =>  /lib/64/libdoor.so.1
>          libuutil.so.1 =>         /lib/64/libuutil.so.1
>          libgen.so.1 =>   /lib/64/libgen.so.1
>          mech_krb5.so.1 =>        /usr/lib/64/gss/mech_krb5.so.1
>          libgss.so.1 =>   /usr/lib/64/libgss.so.1
>          libpkcs11.so.1 =>        /usr/lib/64/libpkcs11.so.1
>          libcmd.so.1 =>   /lib/64/libcmd.so.1
>          libcryptoutil.so.1 =>    /usr/lib/64/libcryptoutil.so.1
> 
>  From this output, you can not determine the regular expression library
> that is being used. Although maybe I'm just not looking there.
> 

I believe the -lregex ABI is presented by libstdc++ nowdays since regex 
was made part of the C++11 standard library. So quite difficult to see.

OR, if that Squid was built with the GNUregex setting it will show up in 
"squid -v" output rather than the ldd dependency list.


> Experimentally, I was able to find out that the grammar of POSIX
> Extended does not work in any case.
> 
> However, I believe that such things should be well documented, otherwise
> the regular expression is simply silently ignored and it is extremely
> difficult to detect.

That sounds like a library problem. If Squid receives a regex error code 
from the library when compiling any regex from your squid.conf it logs 
the relevant error to cache.log.

Amos


More information about the squid-users mailing list