Explicitly require MIT Kerberos for GSSAPI
authorStephen Frost <[email protected]>
Thu, 13 Apr 2023 12:55:13 +0000 (08:55 -0400)
committerStephen Frost <[email protected]>
Thu, 13 Apr 2023 12:55:13 +0000 (08:55 -0400)
WHen building with GSSAPI support, explicitly require MIT Kerberos and
check for gssapi_ext.h in configure.ac and meson.build.  Also add
documentation explicitly stating that we now require MIT Kerberos when
building with GSSAPI support.

Reveiwed by: Johnathan Katz
Discussion: https://postgr.es/m/abcc73d0-acf7-6896-e0dc-f5bc12a61bb1@postgresql.org

configure
configure.ac
doc/src/sgml/client-auth.sgml
doc/src/sgml/installation.sgml
meson.build
src/backend/libpq/auth.c
src/backend/libpq/be-secure-gssapi.c

index dbea7eaf5f7fbf4fb7a561e4f0806711d4c0ea00..08bcf8f43afa5f1dbe861ae442162f50978e8995 100755 (executable)
--- a/configure
+++ b/configure
@@ -14104,6 +14104,33 @@ done
 
 fi
 
+done
+
+  for ac_header in gssapi/gssapi_ext.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "gssapi/gssapi_ext.h" "ac_cv_header_gssapi_gssapi_ext_h" "$ac_includes_default"
+if test "x$ac_cv_header_gssapi_gssapi_ext_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GSSAPI_GSSAPI_EXT_H 1
+_ACEOF
+
+else
+  for ac_header in gssapi_ext.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "gssapi_ext.h" "ac_cv_header_gssapi_ext_h" "$ac_includes_default"
+if test "x$ac_cv_header_gssapi_ext_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GSSAPI_EXT_H 1
+_ACEOF
+
+else
+  as_fn_error $? "gssapi_ext.h header file is required for GSSAPI" "$LINENO" 5
+fi
+
+done
+
+fi
+
 done
 
 fi
index dda34304db15d866eb87fa3b3a2ae68faae282b2..c53a9c788e8180ce9f4599a55c3ea456938b9ec9 100644 (file)
@@ -1562,6 +1562,8 @@ fi
 if test "$with_gssapi" = yes ; then
   AC_CHECK_HEADERS(gssapi/gssapi.h, [],
    [AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
+  AC_CHECK_HEADERS(gssapi/gssapi_ext.h, [],
+   [AC_CHECK_HEADERS(gssapi_ext.h, [], [AC_MSG_ERROR([gssapi_ext.h header file is required for GSSAPI])])])
 fi
 
 PGAC_PATH_PROGS(OPENSSL, openssl)
index dbba2896004439ab29a5881e623aadab5ec14c52..204d09df67b5002a20fcc7c52c059b0d5be76609 100644 (file)
@@ -1426,7 +1426,7 @@ omicron         bryanh                  guest1
     The keytab file is generated using the Kerberos software; see the
     Kerberos documentation for details. The following example shows
     doing this using the <application>kadmin</application> tool of
-    MIT-compatible Kerberos 5 implementations:
+    MIT Kerberos:
 <screen>
 <prompt>kadmin% </prompt><userinput>addprinc -randkey postgres/server.my.domain.org</userinput>
 <prompt>kadmin% </prompt><userinput>ktadd -k krb5.keytab postgres/server.my.domain.org</userinput>
index f451204854c5f641a6b2361460c7083d6a093db8..3d839d665a7fa2ac0035968684e350e4679f0e73 100644 (file)
@@ -252,9 +252,9 @@ documentation.  See standalone-profile.xsl for details.
 
     <listitem>
      <para>
-      You need <application>Kerberos</application>, <productname>OpenLDAP</productname>,
-      and/or <application>PAM</application>, if you want to support authentication
-      using those services.
+      You need <application>MIT Kerberos</application> (for GSSAPI),
+      <productname>OpenLDAP</productname>, and/or <application>PAM</application>,
+      if you want to support authentication using those services.
      </para>
     </listitem>
 
@@ -1048,9 +1048,9 @@ build-postgresql:
        <term><option>--with-gssapi</option></term>
        <listitem>
         <para>
-         Build with support for GSSAPI authentication. On many systems, the
-         GSSAPI system (usually a part of the Kerberos installation) is not
-         installed in a location
+         Build with support for GSSAPI authentication. MIT Kerberos is required
+         to be installed for GSSAPI.  On many systems, the GSSAPI system (a part
+         of the MIT Kerberos installation) is not installed in a location
          that is searched by default (e.g., <filename>/usr/include</filename>,
          <filename>/usr/lib</filename>), so you must use the options
          <option>--with-includes</option> and <option>--with-libraries</option> in
@@ -2497,10 +2497,11 @@ ninja install
       <term><option>-Dgssapi={ auto | enabled | disabled }</option></term>
       <listitem>
        <para>
-        Build with support for GSSAPI authentication. On many systems, the
-        GSSAPI system (usually a part of the Kerberos installation) is not
-        installed in a location that is searched by default (e.g.,
-        <filename>/usr/include</filename>, <filename>/usr/lib</filename>).  In
+        Build with support for GSSAPI authentication. MIT Kerberos is required
+        to be installed for GSSAPI.  On many systems, the GSSAPI system (a part
+        of the MIT Kerberos installation) is not installed in a location
+        that is searched by default (e.g., <filename>/usr/include</filename>,
+        <filename>/usr/lib</filename>).  In
         those cases, PostgreSQL will query <command>pkg-config</command> to
         detect the required compiler and linker options.  Defaults to auto.
         <filename>meson configure</filename> will check for the required
index b69aaddb1f8cd94c88ef907d51b021490ee48483..3405cc07eed5215e4b28e2d307e84f0b48ee5b2a 100644 (file)
@@ -623,6 +623,16 @@ if not gssapiopt.disabled()
     have_gssapi = false
   endif
 
+  if not have_gssapi
+  elif cc.check_header('gssapi/gssapi_ext.h', dependencies: gssapi, required: false,
+      args: test_c_args, include_directories: postgres_inc)
+    cdata.set('HAVE_GSSAPI_GSSAPI_EXT_H', 1)
+  elif cc.check_header('gssapi_ext.h', args: test_c_args, dependencies: gssapi, required: gssapiopt)
+    cdata.set('HAVE_GSSAPI_EXT_H', 1)
+  else
+    have_gssapi = false
+  endif
+
   if not have_gssapi
   elif cc.has_function('gss_init_sec_context', dependencies: gssapi,
       args: test_c_args, include_directories: postgres_inc)
index 00ec9da284b29d72f0bbeef9a6387c50520281e8..a1a826e37fd2cd20e937027129ae556b4ef74ef5 100644 (file)
@@ -922,8 +922,9 @@ pg_GSS_recvauth(Port *port)
    gss_cred_id_t delegated_creds;
 
    /*
-    * Use the configured keytab, if there is one.  Unfortunately, Heimdal
-    * doesn't support the cred store extensions, so use the env var.
+    * Use the configured keytab, if there is one.  As we now require MIT
+    * Kerberos, we might consider using the credential store extensions in
+    * the future instead of the environment variable.
     */
    if (pg_krb_server_keyfile != NULL && pg_krb_server_keyfile[0] != '\0')
    {
index 73f8ce85549e20bd8ae0dbed8b5cb8213822b2b3..6212f225fda38eae3caeb7d64671976fd4382d5e 100644 (file)
@@ -526,8 +526,9 @@ secure_open_gssapi(Port *port)
    PqGSSRecvLength = PqGSSResultLength = PqGSSResultNext = 0;
 
    /*
-    * Use the configured keytab, if there is one.  Unfortunately, Heimdal
-    * doesn't support the cred store extensions, so use the env var.
+    * Use the configured keytab, if there is one.  As we now require MIT
+    * Kerberos, we might consider using the credential store extensions in the
+    * future instead of the environment variable.
     */
    if (pg_krb_server_keyfile != NULL && pg_krb_server_keyfile[0] != '\0')
    {