pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Inoue, Hiroshi <inoue@tpf.co.jp>
To: Craig Ringer <craig@2ndquadrant.com>
Cc: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: Impossible to use MSDTC/XA with SSPI
Date: Wed, 09 Jul 2014 13:00:59 +0900
Message-ID: <53BCBE7B.3090002@tpf.co.jp> (raw)
In-Reply-To: <53BCAEB0.8070500@2ndquadrant.com>
References: <53BCAEB0.8070500@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

(2014/07/09 11:53), Craig Ringer wrote:
> (Sent from the wrong account earlier, please disregard if you see
> another copy)
>
> Hi all
>
> It doesn't seem to be possible to use MSDTC XA transactions alongside
> SSPI authentication.
>
> psqlODBC's MSDTC support assumes that the DSN supplied by the user is
> also valid for a connection from MSDTC.exe via pgxalib.dll for XA
> recovery. We've already seen one case where that's not a valid
> assumption - where the 32-bit and 64-bit driver names differ when using
> 32-bit psqlODBC under SysWow64 on 64-bit Windows.
>
> This is another case.
>
> SSPI for TCP is like "peer" for unix socket connections on UNIX, except
> that it uses an in-band handshake protocol rather than out-of-band
> syscalls. It verifies that the connecting user is running as same
> operating system user as the PostgreSQL username they've requested (or
> is allowed to connect as that Pg user by the user mappings).
>
> So what happens is:
>
> - psqlODBC connects as the user
> - User starts distributed tx manager, binds connection(s) to MSDTC
> - User starts distributed tx; psqlODBC starts tx's on each session and
> saves the user's DSN in the DTC transaction context.
> - User does work on each session
> - User asks DTC to commit tx; psqlODBC does a PREPARE TRANSACTION on
> each session
> - DTC tells user tx has committed successfully
> - DTC asks psqlODBC to COMMIT PREPARED on each tx
>
> If the app exits after MSDTC tells it the tx committed (which it might -
> MSDTC doesn't offer synchronous 2-phase commit, it can only wait for the
> first phase to complete) or the server crashes, etc, there are left-over
> prepared transactions.
>
> pgxalib.dll's job is to recover those. To do that it has to connect to
> PostgreSQL. It's loaded within MSDTC.exe, where it establishes a
> psqlODBC connection using the DSN it saved in the distributed
> transaction context earlier.
>
> This works only if the DSN is valid. The 32-bit to 64-bit mismatch was
> one case of this being a problem earlier. SSPI is another - when
> MSDTC.exe tries to connect to PostgreSQL it does so under Windows user
> NETWORKSERVICE, which won't match the username the original user
> connected to PostgreSQL as. So PostgreSQL will reject the connection.

It also occurs with certificate or ident authentication methods.
It also occurs in case of ssl connections with sslmode=verify-[ca|full
.
One way is to reject such connections at enlistment.
One way is to register such DSNs as *users' manual recovery is
required*.
I'd like to test another way to use CreateProcessWithLogonW() with
SSPI authentication method but it's not easy to setup the environmemt.

regards,
Hiroshi Inoue

-- 
I am using the free version of SPAMfighter.
SPAMfighter has removed 11479 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

Do you have a slow PC? Try a Free scan 
http://www.spamfighter.com/SLOW-PCfighter?cid=sigen



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (3+ messages)  latest in thread

Message-ID: <53BCBE7B.3090002@tpf.co.jp>
Permalink:  ../53BCBE7B.3090002@tpf.co.jp/
Also on:    postgresql.org/message-id/53BCBE7B.3090002@tpf.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: inoue@tpf.co.jp, craig@2ndquadrant.com
  Subject: Re: Impossible to use MSDTC/XA with SSPI
  In-Reply-To: <53BCBE7B.3090002@tpf.co.jp>
  References: <53BCAEB0.8070500@2ndquadrant.com> <53BCBE7B.3090002@tpf.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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