pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_ident.conf + regular expressions issue
10+ messages / 3 participants
[nested] [flat]
* pg_ident.conf + regular expressions issue
@ 2024-10-21 09:43 Alexey Shishkin <alexey.shishkin.01@gmail.com>
0 siblings, 2 replies; 10+ messages in thread
From: Alexey Shishkin @ 2024-10-21 09:43 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
Dear all,
Pls. find attached the results of my tests regarding the topic.
I'm not 100% sure it's a bug, but at least it doesn't work as expected.
It might be the issue with the documentation which is not clear for this
particular topic.
Anyway, your clarification about my tests results is highly appreciated.
best regards,
Alexey Shishkin
alexey.shishkin.01@gmail.com
Attachments:
pg_ident-reg_expr-tests.txt (text/plain, 7.5K) download
https://www.postgresql.org/docs/16/auth-peer.html
https://www.postgresql.org/docs/16/auth-ident.html
https://www.postgresql.org/docs/16/auth-username-maps.html
My setup is PostgreSQL 16.4 (ubuntu 22.04).
'oidentd' daemon is up and running.
I have two OS users:
smokeybear
SMOKEYBEAR
groupadd -g 131 smokeybear
useradd -u 131 -d /tmp -g 131 -s /bin/bash smokeybear
groupadd -g 132 SMOKEYBEAR
useradd -u 132 -d /tmp -g 132 -s /bin/bash SMOKEYBEAR
tee /tmp/.bash_profile << EOF
export PGHOME=/usr/lib/postgresql/16
export PATH=\$PGHOME/bin:\$PATH
export PGDATABASE=postgres
EOF
chmod 0666 /tmp/.bash_history
I have one DB user:
smokeybear
psql -c "create user smokeybear"
1a) 'local' connection method without regular expressions
The first connect is under OS 'smokeybear' user:
test01 - connection success
-pg_ident.conf with one line:
rule01 smokeybear smokeybear
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule01
smokeybear@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" via socket in "/var/run/postgresql" at port "5432".
The second connect is under OS 'SMOKEYBEAR' user:
test02 - connection success
-pg_ident.conf with one line:
rule02 SMOKEYBEAR smokeybear
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule02
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" via socket in "/var/run/postgresql" at port "5432".
So, test01 and test02 results are expected and according to documentation.
1b) 'local' connection method with regular expressions
The first connect is under OS 'smokeybear' user:
test03 - connection success
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule03
smokeybear@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" via socket in "/var/run/postgresql" at port "5432".
test04 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule04
smokeybear@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "smokeybear"
Based on test03 and test04 results, it looks like (?i) and (?c) worked as expected.
The second connect is under OS 'SMOKEYBEAR' user:
test05 - connection failure
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all ident map=rule03
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "smokeybear"
test06 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all ident map=rule04
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "smokeybear"
So, it looks like the result of test06 is expected.
But what about the result of test05 ?
Its 'pg_ident.conf' file is identical to the 'pg_ident.conf' file of test03.
But (?i) didn't seem to work in test05.
I can be totally wrong in my expectations, of course.
So, my question is why there was a connection failure in test05 ?
2a) 'host' connection method without regular expressions
The first connect is under OS 'smokeybear' user:
test07 - connection success
-pg_ident.conf with one line:
rule01 smokeybear smokeybear
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule01
smokeybear@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" on host "localhost" (address "127.0.0.1") at port "5432".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
The second connect is under OS 'SMOKEYBEAR' user:
test08 - connection success
-pg_ident.conf with one line:
rule02 SMOKEYBEAR smokeybear
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule02
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" on host "localhost" (address "127.0.0.1") at port "5432".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
So, test07 and test08 results are expected and according to documentation.
2b) 'host' connection method with regular expressions
The first connect is under OS 'smokeybear' user:
test09 - connection success
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule03
smokeybear@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" on host "localhost" (address "127.0.0.1") at port "5432".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
test10 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule04
smokeybear@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
Based on test09 and test10 results, it looks like (?i) and (?c) worked as expected.
The second connect is under OS 'SMOKEYBEAR' user:
test11 - connection failure
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule03
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
test12 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule04
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
So, it looks like the result of test12 is expected.
But what about the result of test11 ?
Its 'pg_ident.conf' file is identical to the 'pg_ident.conf' file of test09.
But (?i) didn't seem to work in test11.
I can be totally wrong in my expectations, of course.
So, my question is why there was a connection failure in test11 ?
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 14:51 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alexey Shishkin <alexey.shishkin.01@gmail.com>
1 sibling, 1 reply; 10+ messages in thread
From: Tom Lane @ 2024-10-21 14:51 UTC (permalink / raw)
To: Alexey Shishkin <alexey.shishkin.01@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org
Alexey Shishkin <alexey.shishkin.01@gmail.com> writes:
> Pls. find attached the results of my tests regarding the topic.
> I'm not 100% sure it's a bug, but at least it doesn't work as expected.
There is something wrong with your test procedure. For example,
in test05 the log message clearly shows that peer authentication
failed, although you claimed to be testing ident authentication.
You haven't given enough detail to determine why that happened;
perhaps failure to do "pg_ctl reload" after changing config files?
One point worth noting is that ident auth only works on TCP
connections, not connections via a Unix socket.
regards, tom lane
^ permalink raw reply [nested|flat] 10+ messages in thread
* pg_ident.conf + regular expressions issue
@ 2024-10-21 15:09 David G. Johnston <david.g.johnston@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 10+ messages in thread
From: David G. Johnston @ 2024-10-21 15:09 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alexey Shishkin <alexey.shishkin.01@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Monday, October 21, 2024, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alexey Shishkin <alexey.shishkin.01@gmail.com> writes:
> > Pls. find attached the results of my tests regarding the topic.
> > I'm not 100% sure it's a bug, but at least it doesn't work as expected.
>
> There is something wrong with your test procedure. For example,
> in test05 the log message clearly shows that peer authentication
> failed, although you claimed to be testing ident authentication.
>
>
The OP never said they were using the ident auth-method. The test involves
peer authentication with a user name mapping file, pg_ident.conf. Not
specifically the ident authentication type (which devolves to peer anyway
if the connection is local).
The test seems like it needs some heavy simplification but at a glance it
seems to have the necessary elements buried in it somewhere.
David J.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 15:37 David G. Johnston <david.g.johnston@gmail.com>
parent: Alexey Shishkin <alexey.shishkin.01@gmail.com>
1 sibling, 0 replies; 10+ messages in thread
From: David G. Johnston @ 2024-10-21 15:37 UTC (permalink / raw)
To: Alexey Shishkin <alexey.shishkin.01@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org
On Mon, Oct 21, 2024 at 4:33 AM Alexey Shishkin <
alexey.shishkin.01@gmail.com> wrote:
> I'm not 100% sure it's a bug, but at least it doesn't work as expected.
>
>
You seem to be expecting regular expressions to be able to turn what is a
case-sensitive login matching process into a case-insensitive one. A
regular expression cannot do that - well, not one that uses \1.
The value of \1 is going to be in whatever case the OS user name is. So if
you try and login with a case that doesn't match the case of the role
supplied with -U the login attempt will fail. If they do match, it will
succeed. You have to get rid of the \1 and hardcode "smokeybear" as the PG
user name if you want any random capitalization of smokeybear to be able to
login using that role name (not tested...).
David J.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 15:49 Tom Lane <tgl@sss.pgh.pa.us>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Tom Lane @ 2024-10-21 15:49 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Alexey Shishkin <alexey.shishkin.01@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> The OP never said they were using the ident auth-method. The test involves
> peer authentication with a user name mapping file, pg_ident.conf. Not
> specifically the ident authentication type (which devolves to peer anyway
> if the connection is local).
Ah, right, -ENOCAFFEINE: I'd forgotten that "ident" is automatically
converted to "peer" for a Unix-socket connection. So that explains
the phrasing of the error message.
Given that, I don't see anything wrong with the behavior of test05.
The OS user name SMOKEYBEAR successfully matches the rule, sure,
and then the \1 says that that user can log in as role SMOKEYBEAR.
But the request is to log in as smokeybear (lower case), so it fails.
The "(?i)" option only makes the regex able to match different casings
of the OS name, it doesn't make matching of the \1 result to the
requested role name be case-insensitive.
test11 seems to be the same thing, only with actual ident auth.
regards, tom lane
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 19:16 Alexey Shishkin <alexey.shishkin.01@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 10+ messages in thread
From: Alexey Shishkin @ 2024-10-21 19:16 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Dear all,
Thank you for your prompt reply !
Some clarifications regarding the tests:
- I did "pg_ctl reload" after changing config files
- test01-test06 are really about 'peer' authentication instead of 'ident'
authentication
- so, lets concentrate on test07-test12
Let me rephrase my question about regular expressions + pg_ident.conf:
- why test09 is successful, while test10 fails ?
best regards,
Alexey Shishkin
alexey.shishkin.01@gmail.com
On Mon, Oct 21, 2024 at 5:49 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > The OP never said they were using the ident auth-method. The test
> involves
> > peer authentication with a user name mapping file, pg_ident.conf. Not
> > specifically the ident authentication type (which devolves to peer anyway
> > if the connection is local).
>
> Ah, right, -ENOCAFFEINE: I'd forgotten that "ident" is automatically
> converted to "peer" for a Unix-socket connection. So that explains
> the phrasing of the error message.
>
> Given that, I don't see anything wrong with the behavior of test05.
> The OS user name SMOKEYBEAR successfully matches the rule, sure,
> and then the \1 says that that user can log in as role SMOKEYBEAR.
> But the request is to log in as smokeybear (lower case), so it fails.
> The "(?i)" option only makes the regex able to match different casings
> of the OS name, it doesn't make matching of the \1 result to the
> requested role name be case-insensitive.
>
> test11 seems to be the same thing, only with actual ident auth.
>
> regards, tom lane
>
Attachments:
pg_ident-reg_expr-tests.txt (text/plain, 7.5K) download
https://www.postgresql.org/docs/16/auth-peer.html
https://www.postgresql.org/docs/16/auth-ident.html
https://www.postgresql.org/docs/16/auth-username-maps.html
My setup is PostgreSQL 16.4 (ubuntu 22.04).
'oidentd' daemon is up and running.
I have two OS users:
smokeybear
SMOKEYBEAR
groupadd -g 131 smokeybear
useradd -u 131 -d /tmp -g 131 -s /bin/bash smokeybear
groupadd -g 132 SMOKEYBEAR
useradd -u 132 -d /tmp -g 132 -s /bin/bash SMOKEYBEAR
tee /tmp/.bash_profile << EOF
export PGHOME=/usr/lib/postgresql/16
export PATH=\$PGHOME/bin:\$PATH
export PGDATABASE=postgres
EOF
chmod 0666 /tmp/.bash_history
I have one DB user:
smokeybear
psql -c "create user smokeybear"
1a) 'local' connection method without regular expressions
The first connect is under OS 'smokeybear' user:
test01 - connection success
-pg_ident.conf with one line:
rule01 smokeybear smokeybear
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule01
smokeybear@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" via socket in "/var/run/postgresql" at port "5432".
The second connect is under OS 'SMOKEYBEAR' user:
test02 - connection success
-pg_ident.conf with one line:
rule02 SMOKEYBEAR smokeybear
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule02
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" via socket in "/var/run/postgresql" at port "5432".
So, test01 and test02 results are expected and according to documentation.
1b) 'local' connection method with regular expressions
The first connect is under OS 'smokeybear' user:
test03 - connection success
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule03
smokeybear@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" via socket in "/var/run/postgresql" at port "5432".
test04 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all peer map=rule04
smokeybear@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "smokeybear"
Based on test03 and test04 results, it looks like (?i) and (?c) worked as expected.
The second connect is under OS 'SMOKEYBEAR' user:
test05 - connection failure
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all ident map=rule03
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "smokeybear"
test06 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
local all all ident map=rule04
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h /var/run/postgresql -c "\conninfo"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "smokeybear"
So, it looks like the result of test06 is expected.
But what about the result of test05 ?
Its 'pg_ident.conf' file is identical to the 'pg_ident.conf' file of test03.
But (?i) didn't seem to work in test05.
I can be totally wrong in my expectations, of course.
So, my question is why there was a connection failure in test05 ?
2a) 'host' connection method without regular expressions
The first connect is under OS 'smokeybear' user:
test07 - connection success
-pg_ident.conf with one line:
rule01 smokeybear smokeybear
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule01
smokeybear@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" on host "localhost" (address "127.0.0.1") at port "5432".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
The second connect is under OS 'SMOKEYBEAR' user:
test08 - connection success
-pg_ident.conf with one line:
rule02 SMOKEYBEAR smokeybear
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule02
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" on host "localhost" (address "127.0.0.1") at port "5432".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
So, test07 and test08 results are expected and according to documentation.
2b) 'host' connection method with regular expressions
The first connect is under OS 'smokeybear' user:
test09 - connection success
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule03
smokeybear@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
You are connected to database "postgres" as user "smokeybear" on host "localhost" (address "127.0.0.1") at port "5432".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
test10 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule04
smokeybear@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
Based on test09 and test10 results, it looks like (?i) and (?c) worked as expected.
The second connect is under OS 'SMOKEYBEAR' user:
test11 - connection failure
-pg_ident.conf with one line:
rule03 /(?i)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule03
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
test12 - connection failure
-pg_ident.conf with one line:
rule04 /(?c)^(.*SMOKEYBEAR)$ \1
-pg_hba.conf with two lines:
local all postgres peer
host all all 0.0.0.0/0 ident map=rule04
SMOKEYBEAR@wsl2:~$ psql -U smokeybear -h localhost -c "\conninfo"
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "smokeybear"
So, it looks like the result of test12 is expected.
But what about the result of test11 ?
Its 'pg_ident.conf' file is identical to the 'pg_ident.conf' file of test09.
But (?i) didn't seem to work in test11.
I can be totally wrong in my expectations, of course.
So, my question is why there was a connection failure in test11 ?
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 19:39 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alexey Shishkin <alexey.shishkin.01@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Tom Lane @ 2024-10-21 19:39 UTC (permalink / raw)
To: Alexey Shishkin <alexey.shishkin.01@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Alexey Shishkin <alexey.shishkin.01@gmail.com> writes:
> Let me rephrase my question about regular expressions + pg_ident.conf:
> - why test09 is successful, while test10 fails ?
I don't see why that one surprises you. "/(?c)^(.*SMOKEYBEAR)$" does
not match "smokeybear".
regards, tom lane
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 20:58 Alexey Shishkin <alexey.shishkin.01@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 10+ messages in thread
From: Alexey Shishkin @ 2024-10-21 20:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
OK, what we have is:
"(?c)^(.*SMOKEYBEAR)$" does not match "smokeybear"
and at the same time:
"(?i)^(.*SMOKEYBEAR)$" does match "smokeybear"
How the latter is possible ?
best regards,
Alexey Shishkin
alexey.shishkin.01@gmail.com
On Mon, Oct 21, 2024 at 9:39 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alexey Shishkin <alexey.shishkin.01@gmail.com> writes:
> > Let me rephrase my question about regular expressions + pg_ident.conf:
> > - why test09 is successful, while test10 fails ?
>
> I don't see why that one surprises you. "/(?c)^(.*SMOKEYBEAR)$" does
> not match "smokeybear".
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 21:04 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alexey Shishkin <alexey.shishkin.01@gmail.com>
1 sibling, 0 replies; 10+ messages in thread
From: Tom Lane @ 2024-10-21 21:04 UTC (permalink / raw)
To: Alexey Shishkin <alexey.shishkin.01@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Alexey Shishkin <alexey.shishkin.01@gmail.com> writes:
> OK, what we have is:
> "(?c)^(.*SMOKEYBEAR)$" does not match "smokeybear"
> and at the same time:
> "(?i)^(.*SMOKEYBEAR)$" does match "smokeybear"
> How the latter is possible ?
Uh, that's the entire point of the "i" flag, no?
See about embedded options here:
https://www.postgresql.org/docs/current/functions-matching.html#POSIX-METASYNTAX
regards, tom lane
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_ident.conf + regular expressions issue
@ 2024-10-21 21:12 David G. Johnston <david.g.johnston@gmail.com>
parent: Alexey Shishkin <alexey.shishkin.01@gmail.com>
1 sibling, 0 replies; 10+ messages in thread
From: David G. Johnston @ 2024-10-21 21:12 UTC (permalink / raw)
To: Alexey Shishkin <alexey.shishkin.01@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Monday, October 21, 2024, Alexey Shishkin <alexey.shishkin.01@gmail.com>
wrote:
> OK, what we have is:
>
> "(?c)^(.*SMOKEYBEAR)$" does not match "smokeybear"
>
> and at the same time:
>
> "(?i)^(.*SMOKEYBEAR)$" does match "smokeybear"
>
> How the latter is possible ?
>
I suggest you explain in your own words what those two regular expressions
are attempting to do. Why do you expect the second one to not match? Why
does the first one not match?
David J.
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2024-10-21 21:12 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-21 09:43 pg_ident.conf + regular expressions issue Alexey Shishkin <alexey.shishkin.01@gmail.com>
2024-10-21 14:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-21 15:09 ` David G. Johnston <david.g.johnston@gmail.com>
2024-10-21 15:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-21 19:16 ` Alexey Shishkin <alexey.shishkin.01@gmail.com>
2024-10-21 19:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-21 20:58 ` Alexey Shishkin <alexey.shishkin.01@gmail.com>
2024-10-21 21:04 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-21 21:12 ` David G. Johnston <david.g.johnston@gmail.com>
2024-10-21 15:37 ` David G. Johnston <david.g.johnston@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox