88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.177 2009/01/07 13:09:21 mha Exp $
11+ * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.178 2009/01/09 10: 13:18 mha Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -129,8 +129,6 @@ static int CheckCertAuth(Port *port);
129129char * pg_krb_server_keyfile ;
130130char * pg_krb_srvnam ;
131131bool pg_krb_caseins_users ;
132- char * pg_krb_server_hostname = NULL ;
133- char * pg_krb_realm = NULL ;
134132
135133
136134/*----------------------------------------------------------------
@@ -645,10 +643,7 @@ pg_krb5_init(Port *port)
645643 * If no hostname was specified, pg_krb_server_hostname is already NULL.
646644 * If it's set to blank, force it to NULL.
647645 */
648- if (port -> hba -> krb_server_hostname )
649- khostname = port -> hba -> krb_server_hostname ;
650- else
651- khostname = pg_krb_server_hostname ;
646+ khostname = port -> hba -> krb_server_hostname ;
652647 if (khostname && khostname [0 ] == '\0' )
653648 khostname = NULL ;
654649
@@ -694,7 +689,6 @@ pg_krb5_recvauth(Port *port)
694689 krb5_ticket * ticket ;
695690 char * kusername ;
696691 char * cp ;
697- char * realmmatch ;
698692
699693 if (get_role_line (port -> user_name ) == NULL )
700694 return STATUS_ERROR ;
@@ -740,11 +734,6 @@ pg_krb5_recvauth(Port *port)
740734 return STATUS_ERROR ;
741735 }
742736
743- if (port -> hba -> krb_realm )
744- realmmatch = port -> hba -> krb_realm ;
745- else
746- realmmatch = pg_krb_realm ;
747-
748737 cp = strchr (kusername , '@' );
749738 if (cp )
750739 {
@@ -757,27 +746,27 @@ pg_krb5_recvauth(Port *port)
757746 * cp = '\0' ;
758747 cp ++ ;
759748
760- if (realmmatch != NULL && strlen (realmmatch ))
749+ if (port -> hba -> krb_realm != NULL && strlen (port -> hba -> krb_realm ))
761750 {
762751 /* Match realm against configured */
763752 if (pg_krb_caseins_users )
764- ret = pg_strcasecmp (realmmatch , cp );
753+ ret = pg_strcasecmp (port -> hba -> krb_realm , cp );
765754 else
766- ret = strcmp (realmmatch , cp );
755+ ret = strcmp (port -> hba -> krb_realm , cp );
767756
768757 if (ret )
769758 {
770759 elog (DEBUG2 ,
771760 "krb5 realm (%s) and configured realm (%s) don't match" ,
772- cp , realmmatch );
761+ cp , port -> hba -> krb_realm );
773762
774763 krb5_free_ticket (pg_krb5_context , ticket );
775764 krb5_auth_con_free (pg_krb5_context , auth_context );
776765 return STATUS_ERROR ;
777766 }
778767 }
779768 }
780- else if (realmmatch && strlen (realmmatch ))
769+ else if (port -> hba -> krb_realm && strlen (port -> hba -> krb_realm ))
781770 {
782771 elog (DEBUG2 ,
783772 "krb5 did not return realm but realm matching was requested" );
@@ -874,7 +863,6 @@ pg_GSS_recvauth(Port *port)
874863 int ret ;
875864 StringInfoData buf ;
876865 gss_buffer_desc gbuf ;
877- char * realmmatch ;
878866
879867 /*
880868 * GSS auth is not supported for protocol versions before 3, because it
@@ -1034,11 +1022,6 @@ pg_GSS_recvauth(Port *port)
10341022 gettext_noop ("retrieving GSS user name failed" ),
10351023 maj_stat , min_stat );
10361024
1037- if (port -> hba -> krb_realm )
1038- realmmatch = port -> hba -> krb_realm ;
1039- else
1040- realmmatch = pg_krb_realm ;
1041-
10421025 /*
10431026 * Split the username at the realm separator
10441027 */
@@ -1055,28 +1038,28 @@ pg_GSS_recvauth(Port *port)
10551038 * cp = '\0' ;
10561039 cp ++ ;
10571040
1058- if (realmmatch != NULL && strlen (realmmatch ))
1041+ if (port -> hba -> krb_realm != NULL && strlen (port -> hba -> krb_realm ))
10591042 {
10601043 /*
10611044 * Match the realm part of the name first
10621045 */
10631046 if (pg_krb_caseins_users )
1064- ret = pg_strcasecmp (realmmatch , cp );
1047+ ret = pg_strcasecmp (port -> hba -> krb_realm , cp );
10651048 else
1066- ret = strcmp (realmmatch , cp );
1049+ ret = strcmp (port -> hba -> krb_realm , cp );
10671050
10681051 if (ret )
10691052 {
10701053 /* GSS realm does not match */
10711054 elog (DEBUG2 ,
10721055 "GSSAPI realm (%s) and configured realm (%s) don't match" ,
1073- cp , realmmatch );
1056+ cp , port -> hba -> krb_realm );
10741057 gss_release_buffer (& lmin_s , & gbuf );
10751058 return STATUS_ERROR ;
10761059 }
10771060 }
10781061 }
1079- else if (realmmatch && strlen (realmmatch ))
1062+ else if (port -> hba -> krb_realm && strlen (port -> hba -> krb_realm ))
10801063 {
10811064 elog (DEBUG2 ,
10821065 "GSSAPI did not return realm but realm matching was requested" );
@@ -1140,7 +1123,6 @@ pg_SSPI_recvauth(Port *port)
11401123 SID_NAME_USE accountnameuse ;
11411124 HMODULE secur32 ;
11421125 QUERY_SECURITY_CONTEXT_TOKEN_FN _QuerySecurityContextToken ;
1143- char * realmmatch ;
11441126
11451127 /*
11461128 * SSPI auth is not supported for protocol versions before 3, because it
@@ -1353,18 +1335,13 @@ pg_SSPI_recvauth(Port *port)
13531335 * Compare realm/domain if requested. In SSPI, always compare case
13541336 * insensitive.
13551337 */
1356- if (port -> hba -> krb_realm )
1357- realmmatch = port -> hba -> krb_realm ;
1358- else
1359- realmmatch = pg_krb_realm ;
1360-
1361- if (realmmatch && strlen (realmmatch ))
1338+ if (port -> hba -> krb_realm && strlen (port -> hba -> krb_realm ))
13621339 {
1363- if (pg_strcasecmp (realmmatch , domainname ))
1340+ if (pg_strcasecmp (port -> hba -> krb_realm , domainname ))
13641341 {
13651342 elog (DEBUG2 ,
13661343 "SSPI domain (%s) and configured domain (%s) don't match" ,
1367- domainname , realmmatch );
1344+ domainname , port -> hba -> krb_realm );
13681345
13691346 return STATUS_ERROR ;
13701347 }
0 commit comments