Re: libpq-win32 patches

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: libpq-win32 patches
Дата
Msg-id 200309050210.h852Aax16693@candle.pha.pa.us
обсуждение исходный текст
Ответ на libpq-win32 patches  (Andreas Pflug <pgadmin@pse-consulting.de>)
Ответы Re: libpq-win32 patches
Список pgsql-patches
OK, I have applied this patch, except for this part:

> Index: include/pg_config.h.win32
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/include/pg_config.h.win32,v
> retrieving revision 1.11
> diff -u -r1.11 pg_config.h.win32
> --- include/pg_config.h.win32    12 Jun 2003 08:15:29 -0000    1.11
> +++ include/pg_config.h.win32    31 Aug 2003 23:22:31 -0000
> @@ -60,4 +60,9 @@
>  #include <windows.h>
>  #endif
>
> +#include <port/win32.h>
> +
> +/* getpwuid doesn't exist under win32 */
> +#define getpwuid(uid) NULL
> +
>  #endif /* pg_config_h_win32__ */

Why was this needed?  I realize we don't have getpwuid() on Win32, but
we do have GetUserName() for cases where we need the name but not the
directory.

Because all the getpwuid() calls seem ifdef'ed out under Win32 anyway, I
don't understand why you needed it.

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

Andreas Pflug wrote:
> Hm,
>
> I don't see any reaction on my posts from last sunday, neither in this
> list nor in unapplied patches, did they get lost?
> If so, attached is a combined patch for all three problems with libpq
> compiling under win32.
>
> Regards,
> Andreas
>

> cvs diff -u interfaces\libpq\fe-connect.c interfaces\libpq\fe-exec.c interfaces\libpq\fe-secure.c
interfaces\libpq\libpq-int.hinclude\pg_config.h.win32 interfaces\libpq\win32.c interfaces\libpq\win32.mak (in directory
C:\postgresql\src\)
> Index: interfaces/libpq/fe-connect.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
> retrieving revision 1.259
> diff -u -r1.259 fe-connect.c
> --- interfaces/libpq/fe-connect.c    4 Aug 2003 02:40:16 -0000    1.259
> +++ interfaces/libpq/fe-connect.c    31 Aug 2003 23:22:25 -0000
> @@ -48,7 +48,7 @@
>
>  /* For FNCTL_NONBLOCK */
>  #if defined(WIN32) || defined(__BEOS__)
> -long        ioctlsocket_ret;
> +long        ioctlsocket_ret=1;
>  #endif
>
>  #define PGPASSFILE ".pgpass"
>
> Index: interfaces/libpq/fe-exec.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v
> retrieving revision 1.146
> diff -u -r1.146 fe-exec.c
> --- interfaces/libpq/fe-exec.c    27 Aug 2003 00:33:34 -0000    1.146
> +++ interfaces/libpq/fe-exec.c    31 Aug 2003 23:22:28 -0000
> @@ -2304,7 +2304,7 @@
>      if (buffer == NULL)
>          return NULL;
>
> -    for (i = j = buflen = 0; i < strtextlen;)
> +    for (i = j = buflen = 0; i < (int)strtextlen;)
>      {
>          switch (strtext[i])
>          {
> Index: interfaces/libpq/fe-secure.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-secure.c,v
> retrieving revision 1.29
> diff -u -r1.29 fe-secure.c
> --- interfaces/libpq/fe-secure.c    4 Aug 2003 17:25:14 -0000    1.29
> +++ interfaces/libpq/fe-secure.c    31 Aug 2003 23:22:29 -0000
> @@ -312,7 +312,7 @@
>                          printfPQExpBuffer(&conn->errorMessage,
>                                            libpq_gettext("SSL SYSCALL error: EOF detected\n"));
>
> -                        SOCK_ERRNO = ECONNRESET;
> +                        SOCK_ERRNO_SET(ECONNRESET);
>                          n = -1;
>                      }
>                      break;
> @@ -322,7 +322,7 @@
>                        libpq_gettext("SSL error: %s\n"), SSLerrmessage());
>                  /* fall through */
>              case SSL_ERROR_ZERO_RETURN:
> -                SOCK_ERRNO = ECONNRESET;
> +                SOCK_ERRNO_SET(ECONNRESET);
>                  n = -1;
>                  break;
>              default:
> @@ -383,7 +383,7 @@
>                      {
>                          printfPQExpBuffer(&conn->errorMessage,
>                                            libpq_gettext("SSL SYSCALL error: EOF detected\n"));
> -                        SOCK_ERRNO = ECONNRESET;
> +                        SOCK_ERRNO_SET(ECONNRESET);
>                          n = -1;
>                      }
>                      break;
> @@ -393,7 +393,7 @@
>                        libpq_gettext("SSL error: %s\n"), SSLerrmessage());
>                  /* fall through */
>              case SSL_ERROR_ZERO_RETURN:
> -                SOCK_ERRNO = ECONNRESET;
> +                SOCK_ERRNO_SET(ECONNRESET);
>                  n = -1;
>                  break;
>              default:
> @@ -544,6 +544,9 @@
>  static DH  *
>  load_dh_file(int keylength)
>  {
> +#ifdef WIN32
> +    return NULL;
> +#else
>      char        pwdbuf[BUFSIZ];
>      struct passwd pwdstr;
>      struct passwd *pwd = NULL;
> @@ -558,6 +561,7 @@
>      /* attempt to open file.  It's not an error if it doesn't exist. */
>      snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/dh%d.pem",
>               pwd->pw_dir, keylength);
> +
>      if ((fp = fopen(fnbuf, "r")) == NULL)
>          return NULL;
>
> @@ -583,6 +587,7 @@
>      }
>
>      return dh;
> +#endif
>  }
>
>  /*
> @@ -686,6 +691,9 @@
>  static int
>  client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
>  {
> +#ifdef WIN32
> +   return 0;
> +#else
>      char        pwdbuf[BUFSIZ];
>      struct passwd pwdstr;
>      struct passwd *pwd = NULL;
> @@ -785,6 +793,7 @@
>      }
>
>      return 1;
> +#endif
>  }
>
>  /*
> @@ -793,11 +802,13 @@
>  static int
>  initialize_SSL(PGconn *conn)
>  {
> +#ifndef WIN32
>      struct stat buf;
>      char        pwdbuf[BUFSIZ];
>      struct passwd pwdstr;
>      struct passwd *pwd = NULL;
>      char        fnbuf[2048];
> +#endif
>
>      if (!SSL_context)
>      {
> @@ -813,6 +824,7 @@
>          }
>      }
>
> +#ifndef WIN32
>      if (pqGetpwuid(getuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) == 0)
>      {
>          snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/root.crt",
> @@ -849,6 +861,7 @@
>
>      /* set up mechanism to provide client certificate, if available */
>      SSL_CTX_set_client_cert_cb(SSL_context, client_cert_cb);
> +#endif
>
>      return 0;
>  }
> Index: interfaces/libpq/libpq-int.h
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/libpq-int.h,v
> retrieving revision 1.81
> diff -u -r1.81 libpq-int.h
> --- interfaces/libpq/libpq-int.h    13 Aug 2003 18:56:21 -0000    1.81
> +++ interfaces/libpq/libpq-int.h    31 Aug 2003 23:22:30 -0000
> @@ -465,9 +465,11 @@
>  #ifdef WIN32
>  #define SOCK_ERRNO (WSAGetLastError())
>  #define SOCK_STRERROR winsock_strerror
> +#define SOCK_ERRNO_SET(e) WSASetLastError(e)
>  #else
>  #define SOCK_ERRNO errno
>  #define SOCK_STRERROR pqStrerror
> +#define SOCK_ERRNO_SET(e) errno=e
>  #endif
>
>  #endif   /* LIBPQ_INT_H */
> Index: interfaces/libpq/win32.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/win32.c,v
> retrieving revision 1.6
> diff -u -r1.6 win32.c
> --- interfaces/libpq/win32.c    4 Aug 2003 02:40:20 -0000    1.6
> +++ interfaces/libpq/win32.c    31 Aug 2003 23:22:31 -0000
> @@ -312,7 +312,7 @@
>      {
>          strerrbuf[buflen - 1] = '\0';
>          offs = strlen(strerrbuf);
> -        if (offs > buflen - 64)
> +        if (offs > (int)buflen - 64)
>              offs = buflen - 64;
>          sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
>      }
> Index: interfaces/libpq/win32.mak
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/win32.mak,v
> retrieving revision 1.18
> diff -u -r1.18 win32.mak
> --- interfaces/libpq/win32.mak    12 Jun 2003 08:15:29 -0000    1.18
> +++ interfaces/libpq/win32.mak    31 Aug 2003 23:22:31 -0000
> @@ -1,14 +1,16 @@
>  # Makefile for Microsoft Visual C++ 5.0 (or compat)
>
> -# Will build a Win32 static library (non-debug) libpq.lib
> -#        and a Win32 dynamic library (non-debug) libpq.dll with import library libpqdll.lib
> +# Will build a Win32 static library libpq.lib
> +#        and a Win32 dynamic library libpq.dll with import library libpqdll.lib
> +# USE_SSL=1 will compile with OpenSSL
> +# DEBUG=1 compiles with debugging symbols
>
>
>  !MESSAGE Building the Win32 static library...
>  !MESSAGE
>
>  !IFDEF DEBUG
> -OPT=/Od
> +OPT=/Od /Zi
>  LOPT=/debug
>  DEBUGDEF=/D _DEBUG
>  !ELSE
> @@ -26,12 +28,16 @@
>  CPP=cl.exe
>  RSC=rc.exe
>
> +!IFDEF DEBUG
> +OUTDIR=.\Debug
> +INTDIR=.\Debug
> +CPP_OBJS=.\Debug/
> +!ELSE
>  OUTDIR=.\Release
>  INTDIR=.\Release
> +CPP_OBJS=.\Release/
> +!ENDIF
>
> -# Begin Custom Macros
> -OutDir=.\Release
> -# End Custom Macros
>
>  ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll"
>
> @@ -72,16 +78,20 @@
>   "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
>   /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c  /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
>
> -CPP_OBJS=.\Release/
> +!IFDEF USE_SSL
> +CPP_PROJ=$(CPP_PROJ) /D USE_SSL
> +SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
> +!ENDIF
> +
>  CPP_SBRS=.
>
>  LIB32=link.exe -lib
>  LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib"
>  LIB32_OBJS= \
> -    "$(OUTDIR)\win32.obj" \
> +    "$(INTDIR)\win32.obj" \
>      "$(INTDIR)\getaddrinfo.obj" \
>      "$(INTDIR)\inet_aton.obj" \
> -      "$(INTDIR)\crypt.obj" \
> +        "$(INTDIR)\crypt.obj" \
>      "$(INTDIR)\path.obj" \
>      "$(INTDIR)\dllist.obj" \
>      "$(INTDIR)\md5.obj" \
> @@ -94,15 +104,17 @@
>      "$(INTDIR)\fe-lobj.obj" \
>      "$(INTDIR)\fe-misc.obj" \
>      "$(INTDIR)\fe-print.obj" \
> +    "$(INTDIR)\thread.obj" \
>      "$(INTDIR)\fe-secure.obj" \
>      "$(INTDIR)\pqexpbuffer.obj" \
>      "$(INTDIR)\wchar.obj" \
>      "$(INTDIR)\encnames.obj"
>
> +
>  RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
>
>  LINK32=link.exe
> -LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib\
> +LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib $(SSL_LIBS)  \
>   /nologo /subsystem:windows /dll $(LOPT) /incremental:no\
>   /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
>   /implib:"$(OUTDIR)\libpqdll.lib"  /def:libpqdll.def
> @@ -126,38 +138,43 @@
>    $(LINK32_FLAGS) $(LINK32_OBJS)
>  <<
>
> -"$(OUTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
> +"$(INTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\port\getaddrinfo.c
>  <<
>
> -"$(OUTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
> +"$(INTDIR)\thread.obj" : ..\..\port\thread.c
> +    $(CPP) @<<
> +    $(CPP_PROJ) ..\..\port\thread.c
> +<<
> +
> +"$(INTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\port\inet_aton.c
>  <<
>
> -"$(OUTDIR)\crypt.obj" : ..\..\port\crypt.c
> +"$(INTDIR)\crypt.obj" : ..\..\port\crypt.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\port\crypt.c
>  <<
>
> -"$(OUTDIR)\path.obj" : ..\..\port\path.c
> +"$(INTDIR)\path.obj" : ..\..\port\path.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\port\path.c
>  <<
>
> -"$(OUTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
> +"$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\backend\lib\dllist.c
>  <<
>
>
> -"$(OUTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
> +"$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\backend\libpq\md5.c
>  <<
>
> -"$(OUTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
> +"$(INTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
>      $(CPP) @<<
>      $(CPP_PROJ) ..\..\backend\libpq\ip.c
>  <<
> Index: include/pg_config.h.win32
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/include/pg_config.h.win32,v
> retrieving revision 1.11
> diff -u -r1.11 pg_config.h.win32
> --- include/pg_config.h.win32    12 Jun 2003 08:15:29 -0000    1.11
> +++ include/pg_config.h.win32    31 Aug 2003 23:22:31 -0000
> @@ -60,4 +60,9 @@
>  #include <windows.h>
>  #endif
>
> +#include <port/win32.h>
> +
> +/* getpwuid doesn't exist under win32 */
> +#define getpwuid(uid) NULL
> +
>  #endif /* pg_config_h_win32__ */
>
> ***** CVS exited normally with code 1 *****
>
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: libpq with ssl under win32
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: postgresql-7.4b1 Native-Windows patch