Re: [PATCH] Prompt for password on Windows platforms

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [PATCH] Prompt for password on Windows platforms
Дата
Msg-id 200603032354.k23NsOv08190@candle.pha.pa.us
обсуждение исходный текст
Ответ на [PATCH] Prompt for password on Windows platforms  ("Robert Kinberg" <kinberg@tecore.com>)
Список pgsql-patches
Updated patch applied.  I found a use of /dev/tty in psql for command
history that I changed to stderr for Win32.

Thanks for the legwork in finding the cause of this bug.  Backpatched to
8.1.X and 8.0.X.

---------------------------------------------------------------------------

Robert Kinberg wrote:
> The current version of psql, pg_dump, ... do not properly prompt the
> user for a password, when the backend database is setup for password
> authentication on a Windows platform. In investigating the code, I
> noticed that the file '/dev/tty' is opened to interact with the console.
> It appears as if on a Windows platform, the actual file /dev/tty is
> opened, instead of the console. I am supplying a patch to address this
> issue on the Windows platform.
>
> *** ./src/port/sprompt.c.orig Wed Feb 22 13:07:43 2006
> --- ./src/port/sprompt.c Wed Feb 22 13:08:14 2006
> ***************
> *** 40,47 ****
>   {
>    int   length;
>    char    *destination;
> !  FILE    *termin,
> !       *termout;
>
>   #ifdef HAVE_TERMIOS_H
>    struct termios t_orig,
> --- 40,47 ----
>   {
>    int   length;
>    char    *destination;
> !  FILE    *termin = NULL,
> !       *termout = NULL;
>
>   #ifdef HAVE_TERMIOS_H
>    struct termios t_orig,
> ***************
> *** 63,70 ****
> --- 63,72 ----
>     * Do not try to collapse these into one "w+" mode file. Doesn't work
> on
>     * some platforms (eg, HPUX 10.20).
>     */
> + #ifndef WIN32
>    termin = fopen("/dev/tty", "r");
>    termout = fopen("/dev/tty", "w");
> + #endif
>    if (!termin || !termout)
>    {
>     if (termin)
>
>
> Let me know what you think.
>
> Robert Kinberg
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>

--
  Bruce Momjian   http://candle.pha.pa.us
  SRA OSS, Inc.   http://www.sraoss.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/psql/command.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.161
diff -c -c -r1.161 command.c
*** src/bin/psql/command.c    12 Feb 2006 04:04:32 -0000    1.161
--- src/bin/psql/command.c    3 Mar 2006 23:38:05 -0000
***************
*** 753,760 ****

          expand_tilde(&fname);
          /* This scrolls off the screen when using /dev/tty */
          success = saveHistory(fname ? fname : "/dev/tty");
!
          if (success && !quiet && fname)
              printf(gettext("Wrote history to file \"%s/%s\".\n"),
                     pset.dirname ? pset.dirname : ".", fname);
--- 753,763 ----

          expand_tilde(&fname);
          /* This scrolls off the screen when using /dev/tty */
+ #ifndef WIN32
          success = saveHistory(fname ? fname : "/dev/tty");
! #else
!         success = saveHistory(fname ? fname : stderr);
! #endif
          if (success && !quiet && fname)
              printf(gettext("Wrote history to file \"%s/%s\".\n"),
                     pset.dirname ? pset.dirname : ".", fname);
Index: src/port/sprompt.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/sprompt.c,v
retrieving revision 1.12
diff -c -c -r1.12 sprompt.c
*** src/port/sprompt.c    15 Oct 2005 02:49:51 -0000    1.12
--- src/port/sprompt.c    3 Mar 2006 23:38:06 -0000
***************
*** 40,47 ****
  {
      int            length;
      char       *destination;
!     FILE       *termin,
!                *termout;

  #ifdef HAVE_TERMIOS_H
      struct termios t_orig,
--- 40,47 ----
  {
      int            length;
      char       *destination;
!     FILE       *termin = NULL,
!                *termout = NULL;

  #ifdef HAVE_TERMIOS_H
      struct termios t_orig,
***************
*** 63,70 ****
--- 63,76 ----
       * Do not try to collapse these into one "w+" mode file. Doesn't work on
       * some platforms (eg, HPUX 10.20).
       */
+ #ifndef WIN32
+     /*
+      *    Some win32 platforms actually have a /dev/tty file, but it isn't
+      *    a device file, and it doesn't work as expected, so we avoid trying.
+      */
      termin = fopen("/dev/tty", "r");
      termout = fopen("/dev/tty", "w");
+ #endif
      if (!termin || !termout)
      {
          if (termin)

В списке pgsql-patches по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Native-win32 patch
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: constant too large in port/gettimeofday