Index: configure.in
===================================================================
RCS file: /projects/cvsroot/pgsql/configure.in,v
retrieving revision 1.398.4.1
diff -c -r1.398.4.1 configure.in
*** configure.in	30 Jan 2005 19:17:48 -0000	1.398.4.1
--- configure.in	15 Mar 2005 20:53:30 -0000
***************
*** 673,684 ****
  fi
  
  if test "$with_krb5" = yes ; then
!   AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
!                  [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
!   AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
!                  [AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
!   AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
!                  [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
  fi
  
  if test "$with_openssl" = yes ; then
--- 673,689 ----
  fi
  
  if test "$with_krb5" = yes ; then
!   if test "$PORTNAME" != "win32"; then
!      AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
!                     [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
!      AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
!                     [AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
!      AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
!                     [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
!   else
!      AC_SEARCH_LIBS(com_err, 'comerr32 -lkrb5_32', [],
!                     [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
!   fi
  fi
  
  if test "$with_openssl" = yes ; then
Index: src/include/port.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/port.h,v
retrieving revision 1.69
diff -c -r1.69 port.h
*** src/include/port.h	6 Jan 2005 00:59:25 -0000	1.69
--- src/include/port.h	15 Mar 2005 21:17:47 -0000
***************
*** 21,26 ****
--- 21,27 ----
  
  /* non-blocking */
  extern bool set_noblock(int sock);
+ extern bool set_block(int sock);

  /* Portable path handling for Unix/Win32 */

Index: src/interfaces/libpq/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/Makefile,v
retrieving revision 1.126.4.2
diff -c -r1.126.4.2 Makefile
*** src/interfaces/libpq/Makefile	13 Mar 2005 22:04:45 -0000	1.126.4.2
--- src/interfaces/libpq/Makefile	15 Mar 2005 21:22:13 -0000
***************
*** 55,61 ****
  # matter.)
  SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(PTHREAD_LIBS)
  ifeq ($(PORTNAME), win32)
! SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32, $(LIBS))
  endif


--- 55,61 ----
  # matter.)
  SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(PTHREAD_LIBS)
  ifeq ($(PORTNAME), win32)
! SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
  endif


Index: src/interfaces/libpq/fe-auth.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v
retrieving revision 1.99
diff -c -r1.99 fe-auth.c
*** src/interfaces/libpq/fe-auth.c	12 Jan 2005 21:37:54 -0000	1.99
--- src/interfaces/libpq/fe-auth.c	15 Mar 2005 21:20:05 -0000
***************
*** 367,373 ****
  	krb5_principal server;
  	krb5_auth_context auth_context = NULL;
  	krb5_error *err_ret = NULL;
- 	int			flags;

  	ret = pg_krb5_init(PQerrormsg);
  	if (ret != STATUS_OK)
--- 367,372 ----
***************
*** 388,395 ****
  	 * socket, and we have to block somehow to do mutual authentication
  	 * anyway. So we temporarily make it blocking.
  	 */
! 	flags = fcntl(sock, F_GETFL);
! 	if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK)))
  	{
  		char		sebuf[256];

--- 387,393 ----
  	 * socket, and we have to block somehow to do mutual authentication
  	 * anyway. So we temporarily make it blocking.
  	 */
! 	if (!set_block(sock))
  	{
  		char		sebuf[256];

***************
*** 436,442 ****

  	krb5_free_principal(pg_krb5_context, server);

! 	if (fcntl(sock, F_SETFL, (long) flags))
  	{
  		char		sebuf[256];

--- 434,440 ----

  	krb5_free_principal(pg_krb5_context, server);

! 	if (set_noblock(sock))
  	{
  		char		sebuf[256];

Index: src/port/noblock.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/port/noblock.c,v
retrieving revision 1.5
diff -c -r1.5 noblock.c
*** src/port/noblock.c	31 Dec 2004 22:03:53 -0000	1.5
--- src/port/noblock.c	15 Mar 2005 21:19:19 -0000
***************
*** 34,36 ****
--- 34,59 ----
  #endif
  #endif
  }
+
+
+ bool
+ set_block(int sock)
+ {
+ #if !defined(WIN32) && !defined(__BEOS__)
+ 	int flags;
+ 	flags = fcntl(sock, F_GETFL);
+ 	if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK)))
+ 		return false;
+ 	return true;
+ #else
+ 	long		ioctlsocket_ret = 0;
+
+ 	/* Returns non-0 on failure, while fcntl() returns -1 on failure */
+ #ifdef WIN32
+ 	return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
+ #endif
+ #ifdef __BEOS__
+ 	return (ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0);
+ #endif
+ #endif
+ }

