pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed"peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
13+ messages / 6 participants
[nested] [flat]
* "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-29 00:26 Bryn Llewellyn <bryn@yugabyte.com>
0 siblings, 2 replies; 13+ messages in thread
From: Bryn Llewellyn @ 2022-10-29 00:26 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general list <pgsql-general@lists.postgresql.org>
Adrian, thank you for your reply to my « Seeking the correct term of art for the (unique) role that is usually called "postgres"... » thread here:
https://www.postgresql.org/message-id/e75abfa8-72af-701c-cf6f-5336a1a35c92@aklaver.com <https://www.postgresql.org/message-id/e75abfa8-72af-701c-cf6f-5336a1a35c92@aklaver.com;
I'm starting a new thread because my question, now, has nothing to do with the role whose interim name was deemed to be best spelled "bootstrap super user" for the time being.
This question is about "peer" authentication. I am able to make it work as long as my O/S user's name (what "pg_ident.conf" calls the "SYSTEM-USERNAME") is spelled identically to my partner cluster role's name (what "pg_ident.conf" calls the "PG-USERNAME"). But the doc for this file explains that you can define a mapping in "pg_ident.conf", give it any "MAPNAME" that you want, and map a "SYSTEM-USERNAME"to a differently spelled "PG-USERNAME". Or, as you put it, Adrian"
> The purpose of mapping would be to do something like map OS user foo to PG user usr.
I want to get this to work because I want to use a role-name that has a dollar-sign in it (I don't care that this isn't in line with the Standard) and because the O/S uses dollar-sign in a reserved way and I don't want to go against the convention there by escaping things.
Here, I simply used o/s user "bob" and cluster role "alice".
And, yes, I did read the two doc sections "The pg_hba.conf File" and "User Name Maps" (for Version 11 'cos that's what I'm using). The latter shows this example:
# MAPNAME SYSTEM-USERNAME PG-USERNAME
...
omicron robert bob
And I simply decided to follow its spirit with "bob" mapping to "alice", thus:
# MAPNAME SYSTEM-USERNAME PG-USERNAME
...
bllewell bob alice
Here's my "pg_hba.conf":
...
local all postgres peer # See the essay at the start.
local all alice peer
local all bob peer
local all all peer
...
For reasons that will become clear in a moment, the file has entries for both "bob" and "alice".
Here's how I created the O/S user:
adduser bob # Password «x»
usermod -g postgres bob
And here's how I created the cluster role:
create role alice with
nosuperuser
createrole
createdb
noreplication
nobypassrls
connection limit -1
login password 'x';
(You can see that my plan is to follow the advice from the section "Role Attributes".) Again, for reasons that will become clear in a moment, I also created the role "bob" using an otherwise identically spelled "create role" statement.
Then I bounced the cluster thus (as my "postgres" O/S user):
sudo systemctl stop postgresql
sudo systemctl start postgresql
pg_ctl reload -D /etc/postgresql/11/main/
(I know that I could've used "systemctl restart ".) Like I said elsewhere, the "reload" seems to be superfluous. But it costs nothing to do it.
Then I did "su bob" and first did this sanity test:
psql -h localhost -p 5432 -d postgres -U alice
That worked fine—and "select current_role" showed "alice".
Then I did the spelling for "peer", to authorize explicitly as "bob":
psql -d postgres -U bob
That worked too so that "select current_role" now showed "bob". Finally, I omitted "bob" here in the belief that this would make my mapping kick in and authorize using the cluster role "alice":
psql -d postgres
It got me in without error. (And, as hoped for, there was no password challenge.) But "select current_role" showed that the mapping had been ignored and that I was connected again as "bob".
What am I doing wrong?
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-29 01:09 Jeremy Smith <jeremy@musicsmith.net>
parent: Bryn Llewellyn <bryn@yugabyte.com>
1 sibling, 0 replies; 13+ messages in thread
From: Jeremy Smith @ 2022-10-29 01:09 UTC (permalink / raw)
To: Bryn Llewellyn <bryn@yugabyte.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; David G. Johnston <david.g.johnston@gmail.com>; pgsql-general list <pgsql-general@lists.postgresql.org>
>
>
>
> *sudo systemctl stop postgresql**sudo *
> *systemctl start postgresql**pg_ctl reload -D /etc/postgresql/11/main/*
>
> (I know that I could've used "systemctl restart ".) Like I said elsewhere,
> the "reload" seems to be superfluous. But it costs nothing to do it.
>
>
Actually, you only needed the reload, you don't need to restart postgres
for changes to pg_hba.conf.
> Then I did "su bob" and first did this sanity test:
>
> *psql -h localhost -p 5432 -d postgres -U alice*
>
> That worked fine—and "select current_role" showed "alice".
>
> Then I did the spelling for "peer", to authorize explicitly as "bob":
>
>
> *psql -d postgres -U bob*
> That worked too so that "select current_role" now showed "bob". Finally, I
> omitted "bob" here in the belief that this would make my mapping kick in
> and authorize using the cluster role "alice":
>
>
> *psql -d postgres*
>
> It got me in without error. (And, as hoped for, there was no password
> challenge.) But "select current_role" showed that the mapping had been
> ignored and that I was connected again as "bob".
>
> *What am I doing wrong?*
>
>
>
I think maybe you are considering psql and the postgres cluster to be more
tightly integrated than they actually are. The psql process does not know
anything about your pg_hba.conf or your identity map.
Remember that if you don't specify a username for psql, psql (not
postgres!) will default to using your system user. So, if you are the user
bob, these two commands are equivalent:
*psql -d postgres -U bob*
*psql -d postgres*
You can read more about the connection negotiation here:
https://www.postgresql.org/docs/current/protocol-flow.html#id-1.10.6.7.3
Importantly, the frontend (psql in this case) sends both the username and
the database name as part of the first message, so it has to figure out
what username and db name to use before initiating any communication with
the database.
-Jeremy
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-29 02:28 David G. Johnston <david.g.johnston@gmail.com>
parent: Bryn Llewellyn <bryn@yugabyte.com>
1 sibling, 0 replies; 13+ messages in thread
From: David G. Johnston @ 2022-10-29 02:28 UTC (permalink / raw)
To: Bryn Llewellyn <bryn@yugabyte.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general list <pgsql-general@lists.postgresql.org>
On Fri, Oct 28, 2022 at 5:26 PM Bryn Llewellyn <bryn@yugabyte.com> wrote:
>
> And I simply decided to follow its spirit with "bob" mapping to "alice",
> thus:
>
> *# MAPNAME SYSTEM-USERNAME PG-USERNAME*
>
>
> *...bllewell bob alice*
> Here's my "pg_hba.conf":
>
>
> *...*
>
>
>
>
>
> *local all postgres peer #
> See the essay at the start.local all alice
> peerlocal all bob
> peerlocal all all
> peer...*
>
So, none of those make use of the mapping (named bllewell) that you created
since you don't have a map option as described here:
https://www.postgresql.org/docs/current/auth-username-maps.html
"To use user name mapping, specify map=map-name in the options field in
pg_hba.conf."
> Then I did "su bob" and first did this sanity test:
>
> *psql -h localhost -p 5432 -d postgres -U alice*
>
I don't see how that worked given the above observation...
>
> Finally, I omitted "bob" here in the belief that this would make my
> mapping kick in and authorize using the cluster role "alice":
>
>
> *psql -d postgres*
>
> It got me in without error. (And, as hoped for, there was no password
> challenge.) But "select current_role" showed that the mapping had been
> ignored and that I was connected again as "bob".
>
> *What am I doing wrong?*
>
>
As noted elsewhere, the name you specify on the psql command line, whether
chosen by default or explicitly, will be the name you end up connected as
should your connection attempt be accepted.
The mapping file simply allows the DBA to accept a role name that you
specify that, in the case of peer, is different than the o/s user name you
are physically establishing the connection over. In short, bob can request
to login as alice but the database is not going to peer authenticate that
request unless the pg_ident.conf file says that it ok for bob (o/s) to be
alice (system).
David J.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-29 17:14 Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 13+ messages in thread
From: Adrian Klaver @ 2022-10-29 17:14 UTC (permalink / raw)
To: Bryn Llewellyn <bllewell@icloud.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general list <pgsql-general@lists.postgresql.org>
On 10/28/22 17:23, Bryn Llewellyn wrote:
> Adrian, thank you for your reply to my « Seeking the correct term of art
> for the (unique) role that is usually called "postgres"... » thread here:
>
> It got me in without error. (And, as hoped for, there was no password
> challenge.) But "select current_role" showed that the mapping had been
> ignored and that I was connected again as "bob".
>
> *What am I doing wrong?*
You skipped over this part of my post and the documentation:
Section 21.2
"The map-name is an arbitrary name that will be used to refer to this
mapping in pg_hba.conf."
This example below id for the ident auth method but the same syntax
applies to peer.
https://www.postgresql.org/docs/current/auth-pg-hba-conf.html
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.0.0/16 ident
map=omicron
pg_ident.conf and pg_hba.conf are two separate files and the only way
information gets from the former to the latter is if you explicitly
include the map name under METHOD for the the auth line.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 03:20 Bryn Llewellyn <bryn@yugabyte.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 4 replies; 13+ messages in thread
From: Bryn Llewellyn @ 2022-10-30 03:20 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general list <pgsql-general@lists.postgresql.org>
> adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> wrote:
>
>> bryn@yugabyte.com <mailto:bryn@yugabyte.com> wrote:
>>
>> ...What am I doing wrong?
>
> You skipped over this part of my post and the documentation (Section 21.2):
> https://www.postgresql.org/docs/current/auth-pg-hba-conf.html <https://www.postgresql.org/docs/current/auth-pg-hba-conf.html;
>
> "The map-name is an arbitrary name that will be used to refer to this mapping in pg_hba.conf."
>
> This example below is for the ident auth method but the same syntax applies to peer.
>
> # TYPE DATABASE USER ADDRESS METHOD
> host all all 192.168.0.0/16 ident map=omicron
>
> pg_ident.conf and pg_hba.conf are two separate files and the only way information gets from the former to the latter is if you explicitly include the map name under METHOD for the the auth line.
Yes, Adrian, I see that I did slip up. Thanks, David, for pointing out this same error in your separate reply. I’m advertising my stupidity in this area rather effectively. My problem stems from the fact that the goal statement that my inner voice expresses seems so simple to state. This is what I want:
1. I want to do this at the O/S prompt on the machine where my PG cluster has been started: "su mary".
2. Then I want to start a session (I use "psql" here an an example) like this: "psql -d postgres".
3. Then, at the "psql" prompt, I want "select session_user" to show "bob".
It would have seemed to me, knowing just that the goal is achievable, that I could express this declaratively in one place—without needing to name the mapping between the system user's name and the cluster role's name, thus:
authentication type: local
authentication method: peer
system user: mary
cluster role: bob
I know that it isn't like this. But I have no intuition for why it could not be like this—and so it's easy for me to get muddled.
For the purpose of the tests that follow, I set up the O/S users "bob" and "mary" so that "id bob mary postgres" shows this:
id=1002(bob) gid=1001(postgres) groups=1001(postgres)
uid=1003(mary) gid=1001(postgres) groups=1001(postgres)
uid=1001(postgres) gid=1001(postgres) groups=1001(postgres),27(sudo),114(ssl-cert)
And I set up the cluster-roles "bob" and "mary" so that "\du" shows this:
bob | | {}
mary | | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Then I started with this in "pg_hba.conf":
...
# TYPE DATABASE USER METHOD [auth-options]
# ---- -------------- -------------- ------ ----------------------------
local all bob peer
local all mary peer
...
together with en empty "pg_ident.conf". So far, after either "su bob" or "su mary", i was able to confirm that the bare "psql -d postgres" worked fine and that then "select session_user" showed, respectively, "bob" or "mary", too.
Then I changed "pg_hba.conf" to add a mapping for "mary" thus:
# TYPE DATABASE USER METHOD [auth-options]
# ---- -------------- -------------- ------ ----------------------------
local all bob peer
local all mary peer map=bllewell
But I left "pg_ident.conf" deliberately empty. I expected, now, that "psql -d postgres" would still work fine for "bob" but that if would fail for "mary". With this deliberate error in place, I found that after "su bob", the bare "psql -d postgres" worked fine. But after "su mary", the same command caused this error:
Peer authentication failed for user "mary"
I assume that the phrase « user "mary" » means the O/S user "mary".
It seems to me that the message « no entry for the mapping "bllewell" in "pg_ident.conf" » would be more helpful. But maybe that would need psychic powers.
Next, I put an identity mapping in for "mary" in "pg_ident.conf" thus:
# MAPNAME SYSTEM-USERNAME PG-USERNAME
# ------- --------------- -----------
bllewell mary mary
So, "bob" is the simple case. And "mary" is one step harder. Now, the unqualified "psql -d postgres" works again for "mary" (and it still works, of course, for "bob").
So far, so good. Now for the test, I mapped "mary" to "bob" in "pg_ident.conf" thus:
# MAPNAME SYSTEM-USERNAME PG-USERNAME
# ------- --------------- -----------
bllewell mary bob
As I'd expect, O/S "bob" still works fine and ends up as cluster-role "bob". But now, the attempt by O/S "mary" to connect using "psql -d postgres" fails, as it had ealier, with what boils sown to "computer says No":
Peer authentication failed for user "mary"
I still don't have a mental model that can explain this. As I reason it, the name "mary" is passed to the step that's informed by "pg_hba.conf" because it's available from the facts about the O/S user that's running the shell. Then, seeing "map=bllewell", the name "mary" is looked up in "pg_ident.conf" (just as it was in the previous test). Only now, instead of mapping it to the cluster-role "mary", which had worked, it now maps it to the role "bob". Why can it not connect, now, as "Bob"?
Clutching at straws, I reversed the mutual order of "mary" and "bob" in "pg_ident.conf"—even though that seemed wrong. It made no difference to the spelling of the « Peer authentication failed for user "mary" » error.
I've read the two relevant doc sections as carefully as I can. I can't see what I'm missing. I also confirmed with this query
select name, setting
from pg_settings
where category = 'File Locations';
that the files that I've been editing are indeed the files that the server uses.
Do I have to grant permission in some way to allow O/S "mary" to connect as cluster-role "bob". I though that I had exactly done this by the facts in "pg_hba.conf" and "pg_ident.conf".
I'm still missing something. What is it?
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 03:38 David G. Johnston <david.g.johnston@gmail.com>
parent: Bryn Llewellyn <bryn@yugabyte.com>
3 siblings, 2 replies; 13+ messages in thread
From: David G. Johnston @ 2022-10-30 03:38 UTC (permalink / raw)
To: Bryn Llewellyn <bryn@yugabyte.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general list <pgsql-general@lists.postgresql.org>
On Sat, Oct 29, 2022 at 8:20 PM Bryn Llewellyn <bryn@yugabyte.com> wrote:This
is what I want:
>
> 1. I want to do this at the O/S prompt on the machine where my PG cluster
> has been started: *"su mary"*.
>
> 2. Then I want to start a session (I use "psql" here an an example) like
> this: *"psql -d postgres"*.
>
> 3. Then, at the "psql" prompt, I want *"select session_user"* to show
> "bob".
>
I seriously do not understand why in the world you want an authentication
system where you tell the server "my user name is mary" and expect the
server to then say "ok, but I'm going to log you in as bob just for the fun
of it". The way I see it, when I tell the server "my user name is mary",
upon successful completion of the login I am logged in as, wait for
it........., mary.
> *Peer authentication failed for user "mary"*
>
> I assume that the phrase « user "mary" » means the O/S user "mary".
>
No, the server is never going to give you an error message with your o/s
user name showing. It is going to tell you "no, you may not login as mary,
because your name is bob and I have not been informed that you, bob, are
allowed to login as the user mary in this cluster".
> Next, I put an identity mapping in for "mary" in "pg_ident.conf" thus:
>
> *# MAPNAME SYSTEM-USERNAME PG-USERNAME*
>
>
> *# ------- --------------- ----------- bllewell mary
> mary*
>
As has been said numerous times, it is utterly pointless to define a
mapping like this - you get mary-is-mary for free just by saying peer.
> So, "bob" is the simple case. And "mary" is one step harder. Now, the
> unqualified "psql -d postgres" works again for "mary" (and it still works,
> of course, for "bob").
>
> So far, so good. Now for the test, I mapped "mary" to "bob" in
> "pg_ident.conf" thus:
>
>
>
>
> *# MAPNAME SYSTEM-USERNAME PG-USERNAME# -------
> --------------- ----------- bllewell mary bob*
>
Now you are saying mary is allow to claim she is bob. Which requires the
o/s user to be mary and her psql command line have "-U bob"
It is not possible to make an alias mapping work without specifying "-U" on
the psql command line. Period. The -U is precisely how you tell the
server you are using an alias - without it the server expects that the o/s
user is logging in using their own name as the requested login role. In
that case either a peer entry for the user exists - and thus authentication
is successful - or it doesn't - and authentication will fail.
David J.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 04:15 Adrian Klaver <adrian.klaver@aklaver.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 13+ messages in thread
From: Adrian Klaver @ 2022-10-30 04:15 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; Bryn Llewellyn <bryn@yugabyte.com>; +Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
On 10/29/22 20:38, David G. Johnston wrote:
> On Sat, Oct 29, 2022 at 8:20 PM Bryn Llewellyn <bryn@yugabyte.com
> <mailto:bryn@yugabyte.com>> wrote:This is what I want:
>
>
> 1. I want to do this at the O/S prompt on the machine where my PG
> cluster has been started: *"su mary"*.
>
> 2. Then I want to start a session (I use "psql" here an an example)
> like this: *"psql -d postgres"*.
>
> 3. Then, at the "psql" prompt, I want *"select session_user"* to
> show "bob".
>
>
> I seriously do not understand why in the world you want an
> authentication system where you tell the server "my user name is mary"
> and expect the server to then say "ok, but I'm going to log you in as
> bob just for the fun of it". The way I see it, when I tell the server
> "my user name is mary", upon successful completion of the login I am
> logged in as, wait for it........., mary.
>
> *Peer authentication failed for user "mary"*
>
> I assume that the phrase « user "mary" » means the O/S user "mary".
>
>
> No, the server is never going to give you an error message with your o/s
> user name showing. It is going to tell you "no, you may not login as
> mary, because your name is bob and I have not been informed that you,
> bob, are allowed to login as the user mary in this cluster".
>
> Next, I put an identity mapping in for "mary" in "pg_ident.conf" thus:
>
> *# MAPNAME SYSTEM-USERNAME PG-USERNAME*
> *# ------- --------------- -----------
> bllewell mary mary
> *
>
>
> As has been said numerous times, it is utterly pointless to define a
> mapping like this - you get mary-is-mary for free just by saying peer.
+1
>
> **
> So, "bob" is the simple case. And "mary" is one step harder. Now,
> the unqualified "psql -d postgres" works again for "mary" (and it
> still works, of course, for "bob").
>
> So far, so good. Now for the test, I mapped "mary" to "bob" in
> "pg_ident.conf" thus:
>
> *# MAPNAME SYSTEM-USERNAME PG-USERNAME
> # ------- --------------- -----------
> bllewell mary bob
> *
>
>
> Now you are saying mary is allow to claim she is bob. Which requires
> the o/s user to be mary and her psql command line have "-U bob"
>
> It is not possible to make an alias mapping work without specifying "-U"
> on the psql command line. Period. The -U is precisely how you tell the
> server you are using an alias - without it the server expects that the
> o/s user is logging in using their own name as the requested login
> role. In that case either a peer entry for the user exists - and thus
> authentication is successful - or it doesn't - and authentication will fail.
+1
>
> David J.
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 09:47 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 0 replies; 13+ messages in thread
From: Peter J. Holzer @ 2022-10-30 09:47 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2022-10-29 20:38:07 -0700, David G. Johnston wrote:
> Next, I put an identity mapping in for "mary" in "pg_ident.conf" thus:
>
> # MAPNAME SYSTEM-USERNAME PG-USERNAME
> # ------- --------------- -----------
> bllewell mary mary
>
>
> As has been said numerous times, it is utterly pointless to define a mapping
> like this - you get mary-is-mary for free just by saying peer.
If this is the only line in pg_ident.conf I agree. But identity mappings
do serve a purpose. Consider this excerpt from one of our database
clusters:
localusers hjp hjp
localusers hjp wdsimp
localusers hjp wdsro
localusers hjp wdsacct
It says that I can login as hjp, wdsimp, wdsro and wdsacct without a
password. If the first entry wasn't there I wouldn't be able to log in
as myself.
> It is not possible to make an alias mapping work without specifying "-U" on the
> psql command line. Period. The -U is precisely how you tell the server you
> are using an alias - without it the server expects that the o/s user is logging
> in using their own name as the requested login role.
I think that's not quite correct. The -U option affects which user name
psql uses to connect to the server. It is psql which defaults to the
OS user name in the absence of the -U option (or the PGUSER environment
variable). The server has nothing to do with it.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 09:50 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: Bryn Llewellyn <bryn@yugabyte.com>
3 siblings, 0 replies; 13+ messages in thread
From: Peter J. Holzer @ 2022-10-30 09:50 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2022-10-29 20:20:50 -0700, Bryn Llewellyn wrote:
> My problem stems from the fact that the goal statement that my inner
> voice expresses seems so simple to state. This is what I want:
>
> 1. I want to do this at the O/S prompt on the machine where my PG cluster has
> been started: "su mary".
>
> 2. Then I want to start a session (I use "psql" here an an example) like this:
> "psql -d postgres".
>
> 3. Then, at the "psql" prompt, I want "select session_user" to show "bob".
Set the PGUSER=bob in mary's environment.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 10:04 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: Bryn Llewellyn <bryn@yugabyte.com>
3 siblings, 0 replies; 13+ messages in thread
From: Peter J. Holzer @ 2022-10-30 10:04 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2022-10-29 20:20:50 -0700, Bryn Llewellyn wrote:
> For the purpose of the tests that follow, I set up the O/S users "bob" and
> "mary" so that "id bob mary postgres" shows this:
>
> id=1002(bob) gid=1001(postgres) groups=1001(postgres)
> uid=1003(mary) gid=1001(postgres) groups=1001(postgres)
This has nothing to do with your problem, but don't do this. Normal
users should not be in group "postgres". That gives them access to some
files which are not readable by the public. It might be useful for
administrators, but AFAICS your test users aren't supposed to be that.
> uid=1001(postgres) gid=1001(postgres) groups=1001(postgres),27(sudo),114
> (ssl-cert)
And is there a reason for posgres to be in group sudo?
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 16:11 Karsten Hilbert <Karsten.Hilbert@gmx.net>
parent: Bryn Llewellyn <bryn@yugabyte.com>
3 siblings, 0 replies; 13+ messages in thread
From: Karsten Hilbert @ 2022-10-30 16:11 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am Sat, Oct 29, 2022 at 08:20:50PM -0700 schrieb Bryn Llewellyn:
> For the purpose of the tests that follow, I set up the O/S users "bob" and "mary" so that "id bob mary postgres" shows this:
>
> id=1002(bob) gid=1001(postgres) groups=1001(postgres)
> uid=1003(mary) gid=1001(postgres) groups=1001(postgres)
> uid=1001(postgres) gid=1001(postgres) groups=1001(postgres),27(sudo),114(ssl-cert)
>
> And I set up the cluster-roles "bob" and "mary" so that "\du" shows this:
>
> bob | | {}
> mary | | {}
> postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Just a hint: you may want to use "mary_os" and "mary_db",
respectively, such that error messages can become less
ambivalent... (same for bob*).
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 16:16 Karsten Hilbert <Karsten.Hilbert@gmx.net>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 13+ messages in thread
From: Karsten Hilbert @ 2022-10-30 16:16 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am Sat, Oct 29, 2022 at 09:15:08PM -0700 schrieb Adrian Klaver:
> > *# MAPNAME SYSTEM-USERNAME PG-USERNAME*
> > *# ------- --------------- -----------
> > bllewell mary mary
> > *
> >
> >
> >As has been said numerous times, it is utterly pointless to define a mapping like this
> >- you get mary-is-mary for free just by saying peer.
It certainly is but he probably did it just to check whether
anything changes when another code path is run (the mapping)
while the previously-working result (= successful login)
should not change (mary is still mary). despite the
additional code path.
It seems to be a way of bisecting in order to verify/falsify
assumptions in his mental model.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
@ 2022-10-30 16:22 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Karsten Hilbert <Karsten.Hilbert@gmx.net>
0 siblings, 0 replies; 13+ messages in thread
From: Adrian Klaver @ 2022-10-30 16:22 UTC (permalink / raw)
To: Karsten Hilbert <Karsten.Hilbert@gmx.net>; pgsql-general@lists.postgresql.org
On 10/30/22 09:16, Karsten Hilbert wrote:
> Am Sat, Oct 29, 2022 at 09:15:08PM -0700 schrieb Adrian Klaver:
>
>>> *# MAPNAME SYSTEM-USERNAME PG-USERNAME*
>>> *# ------- --------------- -----------
>>> bllewell mary mary
>>> *
>>>
>>>
>>> As has been said numerous times, it is utterly pointless to define a mapping like this
>>> - you get mary-is-mary for free just by saying peer.
>
> It certainly is but he probably did it just to check whether
> anything changes when another code path is run (the mapping)
> while the previously-working result (= successful login)
> should not change (mary is still mary). despite the
> additional code path.
Except the mapping was never in play as the map was not specified in
ph_hba.conf.
>
> It seems to be a way of bisecting in order to verify/falsify
> assumptions in his mental model.
>
> Karsten
> --
> GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 13+ messages in thread
end of thread, other threads:[~2022-10-30 16:22 UTC | newest]
Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-29 00:26 "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should Bryn Llewellyn <bryn@yugabyte.com>
2022-10-29 01:09 ` Jeremy Smith <jeremy@musicsmith.net>
2022-10-29 02:28 ` David G. Johnston <david.g.johnston@gmail.com>
2022-10-29 17:14 Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-30 03:20 ` Bryn Llewellyn <bryn@yugabyte.com>
2022-10-30 03:38 ` David G. Johnston <david.g.johnston@gmail.com>
2022-10-30 04:15 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-30 16:16 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-10-30 16:22 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-30 09:47 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2022-10-30 09:50 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2022-10-30 10:04 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2022-10-30 16:11 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
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