Re: [PATCH] Prompt for password on Windows platforms

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [PATCH] Prompt for password on Windows platforms
Date: 2006-02-28 19:49:02
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCEA0F7FF@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

> > I was very surprised by this issue as well. I am just assuming that
> > not many people have a c:\dev directory on their machines
> where they
> > run postgreSQL from. That is the only way that you would be able to
> > open the file '/dev/tty', if the cwd is c:.
> >
> > If I switch my cwd to a drive that does not have a dev directory at
> > the root, the problem goes away.
>
> This sounds to me like a reasonable explanation to the fact
> that this works in most cases but not all. And that some have
> it working when they're on C: but not on a network drive or
> the other way around.
>
> And I can confirm this problem definitly exists. Haven't had
> time to test the patch, but:

> So yes, it looks like this patch will be needed. A very good
> catch, Robert! This one has been annoying me for a long time!
>
> Tom - if you're unsure the patch fixes the problem, I'll try
> to test it soonest. But the problem definitly exists!

I have now tested the patch, and it does work. Didn't apply cleanly,
most likely because the mailer (either yours or mine) messed up -
probably with the tabs. Attached is a version as an attachment which
should survive this (win32_tty.patch).

This patch fixes a longstanding issue. Anybody who has a \dev directory
on the drive that happens to be current when executing psql will get
broken password authentication without any error msg. I beleive this bug
is responsible for most, if not all, the reports of this kind of issue
we've seen on win32.

The only reason we don't se eit all the time is that c:\dev isn't a very
common directory on win32. But I'm sure several packages doing "I wanna
look like unix" stuff creates one (cygwin, which breaks a lot of other
things, doesn't though - they stick thereis in the cygwin directory. but
there are others)

Now, this bug can in theory affect all platforms not just win32 - any
platform where /dev/tty is not a file, or when it doesn't exist but can
be created (in which case it will be created the first time you run
psql, and then it'll be used later). I've attached a second version of
the patch (alternate_tty.patch) which I think could help in this case.
But I haven't tested it on != win32.
(Specifically, it's bad that we open /dev/tty for writing even if we
failed it for reading (that will create a new file), and that we don't
check if it's a tty at all).

Since this bug is fairly bad for win32, please apply whichever version
of this patch you prefer to HEAD and also to both 8.0 and 8.1 branches.

//Magnus

Attachment Content-Type Size
win32_tty.patch application/octet-stream 1.1 KB
alternate_tty.patch application/octet-stream 1.5 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2006-02-28 20:08:30 Re: 2 line patch to allow plpythonu functions to return
Previous Message Tom Lane 2006-02-28 19:45:05 Re: Zeroing damaged pages