Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6befdc

Browse files
committed
Kerberos fixes from Magnus Hagander --- in theory Kerberos 5 auth
should work on Windows now. Also, rename set_noblock to pg_set_noblock;since it is included in libpq, the former name polluted applicationnamespace.
1 parent46be09e commite6befdc

File tree

9 files changed

+182
-35
lines changed

9 files changed

+182
-35
lines changed

‎configure

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6358,7 +6358,8 @@ done
63586358
fi
63596359

63606360
if test "$with_krb5" = yes ; then
6361-
echo "$as_me:$LINENO: checking for library containing com_err" >&5
6361+
if test "$PORTNAME" != "win32"; then
6362+
echo "$as_me:$LINENO: checking for library containing com_err" >&5
63626363
echo $ECHO_N "checking for library containing com_err... $ECHO_C" >&6
63636364
if test "${ac_cv_search_com_err+set}" = set; then
63646365
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6470,7 +6471,7 @@ echo "$as_me: error: could not find function 'com_err' required for Kerberos 5"
64706471
{ (exit 1); exit 1; }; }
64716472
fi
64726473

6473-
echo "$as_me:$LINENO: checking for library containing krb5_encrypt" >&5
6474+
echo "$as_me:$LINENO: checking for library containing krb5_encrypt" >&5
64746475
echo $ECHO_N "checking for library containing krb5_encrypt... $ECHO_C" >&6
64756476
if test "${ac_cv_search_krb5_encrypt+set}" = set; then
64766477
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6582,7 +6583,7 @@ echo "$as_me: error: could not find function 'krb5_encrypt' required for Kerbero
65826583
{ (exit 1); exit 1; }; }
65836584
fi
65846585

6585-
echo "$as_me:$LINENO: checking for library containing krb5_sendauth" >&5
6586+
echo "$as_me:$LINENO: checking for library containing krb5_sendauth" >&5
65866587
echo $ECHO_N "checking for library containing krb5_sendauth... $ECHO_C" >&6
65876588
if test "${ac_cv_search_krb5_sendauth+set}" = set; then
65886589
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6694,6 +6695,120 @@ echo "$as_me: error: could not find function 'krb5_sendauth' required for Kerber
66946695
{ (exit 1); exit 1; }; }
66956696
fi
66966697

6698+
else
6699+
echo "$as_me:$LINENO: checking for library containing com_err" >&5
6700+
echo $ECHO_N "checking for library containing com_err... $ECHO_C" >&6
6701+
if test "${ac_cv_search_com_err+set}" = set; then
6702+
echo $ECHO_N "(cached) $ECHO_C" >&6
6703+
else
6704+
ac_func_search_save_LIBS=$LIBS
6705+
ac_cv_search_com_err=no
6706+
cat >conftest.$ac_ext <<_ACEOF
6707+
#line $LINENO "configure"
6708+
#include "confdefs.h"
6709+
6710+
/* Override any gcc2 internal prototype to avoid an error. */
6711+
#ifdef __cplusplus
6712+
extern "C"
6713+
#endif
6714+
/* We use char because int might match the return type of a gcc2
6715+
builtin and then its argument prototype would still apply. */
6716+
char com_err ();
6717+
#ifdef F77_DUMMY_MAIN
6718+
# ifdef __cplusplus
6719+
extern "C"
6720+
# endif
6721+
int F77_DUMMY_MAIN() { return 1; }
6722+
#endif
6723+
int
6724+
main ()
6725+
{
6726+
com_err ();
6727+
;
6728+
return 0;
6729+
}
6730+
_ACEOF
6731+
rm -f conftest.$ac_objext conftest$ac_exeext
6732+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6733+
(eval $ac_link) 2>&5
6734+
ac_status=$?
6735+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
6736+
(exit $ac_status); } &&
6737+
{ ac_try='test -s conftest$ac_exeext'
6738+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6739+
(eval $ac_try) 2>&5
6740+
ac_status=$?
6741+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
6742+
(exit $ac_status); }; }; then
6743+
ac_cv_search_com_err="none required"
6744+
else
6745+
echo "$as_me: failed program was:" >&5
6746+
cat conftest.$ac_ext >&5
6747+
fi
6748+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
6749+
if test "$ac_cv_search_com_err" = no; then
6750+
for ac_lib in 'comerr32 -lkrb5_32'; do
6751+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
6752+
cat >conftest.$ac_ext <<_ACEOF
6753+
#line $LINENO "configure"
6754+
#include "confdefs.h"
6755+
6756+
/* Override any gcc2 internal prototype to avoid an error. */
6757+
#ifdef __cplusplus
6758+
extern "C"
6759+
#endif
6760+
/* We use char because int might match the return type of a gcc2
6761+
builtin and then its argument prototype would still apply. */
6762+
char com_err ();
6763+
#ifdef F77_DUMMY_MAIN
6764+
# ifdef __cplusplus
6765+
extern "C"
6766+
# endif
6767+
int F77_DUMMY_MAIN() { return 1; }
6768+
#endif
6769+
int
6770+
main ()
6771+
{
6772+
com_err ();
6773+
;
6774+
return 0;
6775+
}
6776+
_ACEOF
6777+
rm -f conftest.$ac_objext conftest$ac_exeext
6778+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6779+
(eval $ac_link) 2>&5
6780+
ac_status=$?
6781+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
6782+
(exit $ac_status); } &&
6783+
{ ac_try='test -s conftest$ac_exeext'
6784+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6785+
(eval $ac_try) 2>&5
6786+
ac_status=$?
6787+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
6788+
(exit $ac_status); }; }; then
6789+
ac_cv_search_com_err="-l$ac_lib"
6790+
break
6791+
else
6792+
echo "$as_me: failed program was:" >&5
6793+
cat conftest.$ac_ext >&5
6794+
fi
6795+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
6796+
done
6797+
fi
6798+
LIBS=$ac_func_search_save_LIBS
6799+
fi
6800+
echo "$as_me:$LINENO: result: $ac_cv_search_com_err" >&5
6801+
echo "${ECHO_T}$ac_cv_search_com_err" >&6
6802+
if test "$ac_cv_search_com_err" != no; then
6803+
test "$ac_cv_search_com_err" = "none required" || LIBS="$ac_cv_search_com_err $LIBS"
6804+
6805+
else
6806+
{ { echo "$as_me:$LINENO: error: could not find function 'com_err' required for Kerberos 5" >&5
6807+
echo "$as_me: error: could not find function 'com_err' required for Kerberos 5" >&2;}
6808+
{ (exit 1); exit 1; }; }
6809+
fi
6810+
6811+
fi
66976812
fi
66986813

66996814
if test "$with_openssl" = yes ; then

‎configure.in

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.406 2005/03/11 17:20:33 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.407 2005/03/25 00:34:19 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -673,12 +673,17 @@ if test "$with_krb4" = yes ; then
673673
fi
674674

675675
if test "$with_krb5" = yes ; then
676-
AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
677-
[AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
678-
AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
679-
[AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
680-
AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
681-
[AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
676+
if test "$PORTNAME" != "win32"; then
677+
AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
678+
[AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
679+
AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
680+
[AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
681+
AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
682+
[AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
683+
else
684+
AC_SEARCH_LIBS(com_err, 'comerr32 -lkrb5_32', [],
685+
[AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
686+
fi
682687
fi
683688

684689
if test "$with_openssl" = yes ; then

‎src/backend/postmaster/pgstat.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2005, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.87 2005/01/01 05:43:07 momjian Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.88 2005/03/25 00:34:21 tgl Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -422,7 +422,7 @@ pgstat_init(void)
422422
* messages will be discarded; backends won't block waiting to send
423423
* messages to the collector.
424424
*/
425-
if (!set_noblock(pgStatSock))
425+
if (!pg_set_noblock(pgStatSock))
426426
{
427427
ereport(LOG,
428428
(errcode_for_socket_access(),
@@ -1766,7 +1766,7 @@ pgstat_recvbuffer(void)
17661766
* Set the write pipe to nonblock mode, so that we cannot block when
17671767
* the collector falls behind.
17681768
*/
1769-
if (!set_noblock(writePipe))
1769+
if (!pg_set_noblock(writePipe))
17701770
ereport(ERROR,
17711771
(errcode_for_socket_access(),
17721772
errmsg("could not set statistics collector pipe to nonblocking mode: %m")));

‎src/backend/postmaster/postmaster.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.449 2005/03/24 18:16:17 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.450 2005/03/25 00:34:21 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -1246,10 +1246,10 @@ ServerLoop(void)
12461246
PgStatPID=pgstat_start();
12471247

12481248
/*
1249-
* Touch the socket and lock fileat leasteveryhour, to
1249+
* Touch the socket and lock file every58 minutes, to
12501250
* ensure that they are not removed by overzealous /tmp-cleaning
1251-
* tasks.Set to 58 minutes so a cleaner never sees the
1252-
*file as an hourold.
1251+
* tasks.We assume no one runs cleaners with cutoff times of
1252+
*less than an hour...
12531253
*/
12541254
now=time(NULL);
12551255
if (now-last_touch_time >=58*60)
@@ -2479,7 +2479,7 @@ report_fork_failure_to_client(Port *port, int errnum)
24792479
strerror(errnum));
24802480

24812481
/* Set port to non-blocking. Don't do send() if this fails */
2482-
if (!set_noblock(port->sock))
2482+
if (!pg_set_noblock(port->sock))
24832483
return;
24842484

24852485
send(port->sock,buffer,strlen(buffer)+1,0);

‎src/include/port.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.73 2005/03/16 21:27:23 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.74 2005/03/25 00:34:24 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -20,7 +20,8 @@
2020
#include<ctype.h>
2121

2222
/* non-blocking */
23-
externboolset_noblock(intsock);
23+
externboolpg_set_noblock(intsock);
24+
externboolpg_set_block(intsock);
2425

2526
/* Portable path handling for Unix/Win32 */
2627

‎src/interfaces/libpq/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.130 2005/03/14 17:27:50 momjian Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.131 2005/03/25 00:34:28 tgl Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -55,7 +55,7 @@ endif
5555
# matter.)
5656
SHLIB_LINK +=$(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl,$(LIBS))$(PTHREAD_LIBS)
5757
ifeq ($(PORTNAME), win32)
58-
SHLIB_LINK += -lshfolder -lwsock32 -lws2_32$(filter -leay32 -lssleay32,$(LIBS))
58+
SHLIB_LINK += -lshfolder -lwsock32 -lws2_32$(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32,$(LIBS))
5959
endif
6060

6161

‎src/interfaces/libpq/fe-auth.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.99 2005/01/12 21:37:54 tgl Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.100 2005/03/25 00:34:28 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -367,7 +367,13 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname)
367367
krb5_principalserver;
368368
krb5_auth_contextauth_context=NULL;
369369
krb5_error*err_ret=NULL;
370-
intflags;
370+
371+
if (!hostname)
372+
{
373+
snprintf(PQerrormsg,PQERRORMSG_LENGTH,
374+
"pg_krb5_sendauth: hostname must be specified for Kerberos authentication\n");
375+
returnSTATUS_ERROR;
376+
}
371377

372378
ret=pg_krb5_init(PQerrormsg);
373379
if (ret!=STATUS_OK)
@@ -388,8 +394,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname)
388394
* socket, and we have to block somehow to do mutual authentication
389395
* anyway. So we temporarily make it blocking.
390396
*/
391-
flags=fcntl(sock,F_GETFL);
392-
if (flags<0||fcntl(sock,F_SETFL, (long) (flags& ~O_NONBLOCK)))
397+
if (!pg_set_block(sock))
393398
{
394399
charsebuf[256];
395400

@@ -436,7 +441,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname)
436441

437442
krb5_free_principal(pg_krb5_context,server);
438443

439-
if (fcntl(sock,F_SETFL, (long)flags))
444+
if (!pg_set_noblock(sock))
440445
{
441446
charsebuf[256];
442447

@@ -599,8 +604,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
599604
(structsockaddr_in*)&conn->raddr.addr,
600605
hostname)!=STATUS_OK)
601606
{
602-
snprintf(PQerrormsg,PQERRORMSG_LENGTH,
603-
libpq_gettext("Kerberos 4 authentication failed\n"));
607+
/* PQerrormsg already filled in */
604608
pgunlock_thread();
605609
returnSTATUS_ERROR;
606610
}
@@ -618,8 +622,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
618622
if (pg_krb5_sendauth(PQerrormsg,conn->sock,
619623
hostname)!=STATUS_OK)
620624
{
621-
snprintf(PQerrormsg,PQERRORMSG_LENGTH,
622-
libpq_gettext("Kerberos 5 authentication failed\n"));
625+
/* PQerrormsg already filled in */
623626
pgunlock_thread();
624627
returnSTATUS_ERROR;
625628
}

‎src/interfaces/libpq/fe-connect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.303 2005/02/22 04:42:20 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.304 2005/03/25 00:34:29 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1211,7 +1211,7 @@ PQconnectPoll(PGconn *conn)
12111211
continue;
12121212
}
12131213
}
1214-
if (!set_noblock(conn->sock))
1214+
if (!pg_set_noblock(conn->sock))
12151215
{
12161216
printfPQExpBuffer(&conn->errorMessage,
12171217
libpq_gettext("could not set socket to non-blocking mode: %s\n"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp