Blame SOURCES/0007-Add-configure-variable-for-default-PKCS-11-module.patch

905476
From c0a6d66e98e62b94d72bb51b8d6c00130a951215 Mon Sep 17 00:00:00 2001
8874ae
From: Julien Rische <jrische@redhat.com>
8874ae
Date: Fri, 22 Apr 2022 14:12:37 +0200
8874ae
Subject: [PATCH] Add configure variable for default PKCS#11 module
8874ae
8874ae
[ghudson@mit.edu: added documentation of configure variable and doc
8874ae
substitution; shortened commit message]
8874ae
8874ae
ticket: 9058 (new)
8874ae
---
8874ae
 doc/admin/conf_files/krb5_conf.rst  |  2 +-
8874ae
 doc/build/options2configure.rst     |  3 +++
8874ae
 doc/conf.py                         |  3 +++
8874ae
 doc/mitK5defaults.rst               | 25 +++++++++++++------------
8874ae
 src/configure.ac                    |  8 ++++++++
8874ae
 src/doc/Makefile.in                 |  2 ++
8874ae
 src/man/Makefile.in                 |  4 +++-
8874ae
 src/man/krb5.conf.man               |  2 +-
8874ae
 src/plugins/preauth/pkinit/pkinit.h |  1 -
8874ae
 9 files changed, 34 insertions(+), 16 deletions(-)
8874ae
8874ae
diff --git a/doc/admin/conf_files/krb5_conf.rst b/doc/admin/conf_files/krb5_conf.rst
905476
index 2a4962069f..a33711d918 100644
8874ae
--- a/doc/admin/conf_files/krb5_conf.rst
8874ae
+++ b/doc/admin/conf_files/krb5_conf.rst
905476
@@ -1017,7 +1017,7 @@ information for PKINIT is as follows:
8874ae
     All keyword/values are optional.  *modname* specifies the location
8874ae
     of a library implementing PKCS #11.  If a value is encountered
8874ae
     with no keyword, it is assumed to be the *modname*.  If no
8874ae
-    module-name is specified, the default is ``opensc-pkcs11.so``.
8874ae
+    module-name is specified, the default is |pkcs11_modname|.
8874ae
     ``slotid=`` and/or ``token=`` may be specified to force the use of
8874ae
     a particular smard card reader or token if there is more than one
8874ae
     available.  ``certid=`` and/or ``certlabel=`` may be specified to
8874ae
diff --git a/doc/build/options2configure.rst b/doc/build/options2configure.rst
905476
index 9e355dc2c5..e879b18bd2 100644
8874ae
--- a/doc/build/options2configure.rst
8874ae
+++ b/doc/build/options2configure.rst
905476
@@ -137,6 +137,9 @@ Environment variables
8874ae
     This option allows one to specify libraries to be passed to the
8874ae
     linker (e.g., ``-l<library>``)
8874ae
 
8874ae
+**PKCS11_MODNAME=**\ *library*
8874ae
+    Override the built-in default PKCS11 library name.
8874ae
+
8874ae
 **SS_LIB=**\ *libs*...
8874ae
     If ``-lss`` is not the correct way to link in your installed ss
8874ae
     library, for example if additional support libraries are needed,
8874ae
diff --git a/doc/conf.py b/doc/conf.py
905476
index 12168fa695..0ab5ff9606 100644
8874ae
--- a/doc/conf.py
8874ae
+++ b/doc/conf.py
905476
@@ -242,6 +242,7 @@ if 'mansubs' in tags:
8874ae
     ccache = '``@CCNAME@``'
8874ae
     keytab = '``@KTNAME@``'
8874ae
     ckeytab = '``@CKTNAME@``'
8874ae
+    pkcs11_modname = '``@PKCS11MOD@``'
8874ae
 elif 'pathsubs' in tags:
8874ae
     # Read configured paths from a file produced by the build system.
8874ae
     exec(open("paths.py").read())
905476
@@ -255,6 +256,7 @@ else:
8874ae
     ccache = ':ref:`DEFCCNAME <paths>`'
8874ae
     keytab = ':ref:`DEFKTNAME <paths>`'
8874ae
     ckeytab = ':ref:`DEFCKTNAME <paths>`'
8874ae
+    pkcs11_modname = ':ref:`PKCS11_MODNAME <paths>`'
8874ae
 
8874ae
 rst_epilog = '\n'
8874ae
 
905476
@@ -275,6 +277,7 @@ else:
8874ae
     rst_epilog += '.. |ccache| replace:: %s\n' % ccache
8874ae
     rst_epilog += '.. |keytab| replace:: %s\n' % keytab
8874ae
     rst_epilog += '.. |ckeytab| replace:: %s\n' % ckeytab
8874ae
+    rst_epilog += '.. |pkcs11_modname| replace:: %s\n' % pkcs11_modname
8874ae
     rst_epilog += '''
8874ae
 .. |krb5conf| replace:: ``/etc/krb5.conf``
8874ae
 .. |defkeysalts| replace:: ``aes256-cts-hmac-sha1-96:normal aes128-cts-hmac-sha1-96:normal``
8874ae
diff --git a/doc/mitK5defaults.rst b/doc/mitK5defaults.rst
905476
index 74e69f4ad0..aea7af3dbb 100644
8874ae
--- a/doc/mitK5defaults.rst
8874ae
+++ b/doc/mitK5defaults.rst
8874ae
@@ -59,18 +59,19 @@ subdirectories of ``/usr/local``.  When MIT krb5 is integrated into an
8874ae
 operating system, the paths are generally chosen to match the
8874ae
 operating system's filesystem layout.
8874ae
 
8874ae
-==========================  =============  ===========================  ===========================
8874ae
-Description                 Symbolic name  Custom build path            Typical OS path
8874ae
-==========================  =============  ===========================  ===========================
8874ae
-User programs               BINDIR         ``/usr/local/bin``           ``/usr/bin``
8874ae
-Libraries and plugins       LIBDIR         ``/usr/local/lib``           ``/usr/lib``
8874ae
-Parent of KDC state dir     LOCALSTATEDIR  ``/usr/local/var``           ``/var``
8874ae
-Parent of KDC runtime dir   RUNSTATEDIR    ``/usr/local/var/run``       ``/run``
8874ae
-Administrative programs     SBINDIR        ``/usr/local/sbin``          ``/usr/sbin``
8874ae
-Alternate krb5.conf dir     SYSCONFDIR     ``/usr/local/etc``           ``/etc``
8874ae
-Default ccache name         DEFCCNAME      ``FILE:/tmp/krb5cc_%{uid}``  ``FILE:/tmp/krb5cc_%{uid}``
8874ae
-Default keytab name         DEFKTNAME      ``FILE:/etc/krb5.keytab``    ``FILE:/etc/krb5.keytab``
8874ae
-==========================  =============  ===========================  ===========================
8874ae
+==========================  ==============  ===========================  ===========================
8874ae
+Description                 Symbolic name   Custom build path            Typical OS path
8874ae
+==========================  ==============  ===========================  ===========================
8874ae
+User programs               BINDIR          ``/usr/local/bin``           ``/usr/bin``
8874ae
+Libraries and plugins       LIBDIR          ``/usr/local/lib``           ``/usr/lib``
8874ae
+Parent of KDC state dir     LOCALSTATEDIR   ``/usr/local/var``           ``/var``
8874ae
+Parent of KDC runtime dir   RUNSTATEDIR     ``/usr/local/var/run``       ``/run``
8874ae
+Administrative programs     SBINDIR         ``/usr/local/sbin``          ``/usr/sbin``
8874ae
+Alternate krb5.conf dir     SYSCONFDIR      ``/usr/local/etc``           ``/etc``
8874ae
+Default ccache name         DEFCCNAME       ``FILE:/tmp/krb5cc_%{uid}``  ``FILE:/tmp/krb5cc_%{uid}``
8874ae
+Default keytab name         DEFKTNAME       ``FILE:/etc/krb5.keytab``    ``FILE:/etc/krb5.keytab``
8874ae
+Default PKCS11 module       PKCS11_MODNAME  ``opensc-pkcs11.so``         ``opensc-pkcs11.so``
8874ae
+==========================  ==============  ===========================  ===========================
8874ae
 
8874ae
 The default client keytab name (DEFCKTNAME) typically defaults to
8874ae
 ``FILE:/usr/local/var/krb5/user/%{euid}/client.keytab`` for a custom
8874ae
diff --git a/src/configure.ac b/src/configure.ac
905476
index 8dc864718d..9774cb71ae 100644
8874ae
--- a/src/configure.ac
8874ae
+++ b/src/configure.ac
905476
@@ -1471,6 +1471,14 @@ AC_DEFINE_UNQUOTED(DEFKTNAME, ["$DEFKTNAME"], [Define to default keytab name])
8874ae
 AC_DEFINE_UNQUOTED(DEFCKTNAME, ["$DEFCKTNAME"],
8874ae
                    [Define to default client keytab name])
8874ae
 
8874ae
+AC_ARG_VAR(PKCS11_MODNAME, [Default PKCS11 module name])
8874ae
+if test "${PKCS11_MODNAME+set}" != set; then
8874ae
+	PKCS11_MODNAME=opensc-pkcs11.so
8874ae
+fi
8874ae
+AC_MSG_NOTICE([Default PKCS11 module name: $PKCS11_MODNAME])
8874ae
+AC_DEFINE_UNQUOTED(PKCS11_MODNAME, ["$PKCS11_MODNAME"],
8874ae
+                   [Default PKCS11 module name])
8874ae
+
8874ae
 AC_CONFIG_FILES([build-tools/krb5-config], [chmod +x build-tools/krb5-config])
8874ae
 AC_CONFIG_FILES([build-tools/kadm-server.pc
8874ae
 	build-tools/kadm-client.pc
8874ae
diff --git a/src/doc/Makefile.in b/src/doc/Makefile.in
905476
index 379bc36511..a1b0cff0a4 100644
8874ae
--- a/src/doc/Makefile.in
8874ae
+++ b/src/doc/Makefile.in
8874ae
@@ -10,6 +10,7 @@ sysconfdir=@sysconfdir@
8874ae
 DEFCCNAME=@DEFCCNAME@
8874ae
 DEFKTNAME=@DEFKTNAME@
8874ae
 DEFCKTNAME=@DEFCKTNAME@
8874ae
+PKCS11_MODNAME=@PKCS11_MODNAME@
8874ae
 
8874ae
 RST_SOURCES= _static \
8874ae
 	_templates \
8874ae
@@ -118,6 +119,7 @@ paths.py:
8874ae
 	echo 'ccache = "``$(DEFCCNAME)``"' >> $@
8874ae
 	echo 'keytab = "``$(DEFKTNAME)``"' >> $@
8874ae
 	echo 'ckeytab = "``$(DEFCKTNAME)``"' >> $@
8874ae
+	echo 'pkcs11_modname = "``$(PKCS11_MODNAME)``"' >> $@
8874ae
 
8874ae
 # Dummy rule that man/Makefile can invoke
8874ae
 version.py: $(docsrc)/version.py
8874ae
diff --git a/src/man/Makefile.in b/src/man/Makefile.in
905476
index 00b1b2de06..85cae0914e 100644
8874ae
--- a/src/man/Makefile.in
8874ae
+++ b/src/man/Makefile.in
8874ae
@@ -8,6 +8,7 @@ sysconfdir=@sysconfdir@
8874ae
 DEFCCNAME=@DEFCCNAME@
8874ae
 DEFKTNAME=@DEFKTNAME@
8874ae
 DEFCKTNAME=@DEFCKTNAME@
8874ae
+PKCS11_MODNAME=@PKCS11_MODNAME@
8874ae
 
8874ae
 MANSUBS=k5identity.sub k5login.sub k5srvutil.sub kadm5.acl.sub kadmin.sub \
8874ae
 	kadmind.sub kdb5_ldap_util.sub kdb5_util.sub kdc.conf.sub \
8874ae
@@ -47,7 +48,8 @@ $(docsrc)/version.py: $(top_srcdir)/patchlevel.h
8874ae
 	    -e 's|@SYSCONFDIR@|$(sysconfdir)|g' \
8874ae
 	    -e 's|@CCNAME@|$(DEFCCNAME)|g' \
8874ae
 	    -e 's|@KTNAME@|$(DEFKTNAME)|g' \
8874ae
-	    -e 's|@CKTNAME@|$(DEFCKTNAME)|g' $? > $@
8874ae
+	    -e 's|@CKTNAME@|$(DEFCKTNAME)|g' \
8874ae
+	    -e 's|@PKCS11MOD@|$(PKCS11_MODNAME)|g' $? > $@
8874ae
 
8874ae
 all: $(MANSUBS)
8874ae
 
8874ae
diff --git a/src/man/krb5.conf.man b/src/man/krb5.conf.man
905476
index 51acb38815..fd2c6f2bc4 100644
8874ae
--- a/src/man/krb5.conf.man
8874ae
+++ b/src/man/krb5.conf.man
905476
@@ -1148,7 +1148,7 @@ user\(aqs certificate and private key.
8874ae
 All keyword/values are optional.  \fImodname\fP specifies the location
8874ae
 of a library implementing PKCS #11.  If a value is encountered
8874ae
 with no keyword, it is assumed to be the \fImodname\fP\&.  If no
8874ae
-module\-name is specified, the default is \fBopensc\-pkcs11.so\fP\&.
8874ae
+module\-name is specified, the default is \fB@PKCS11MOD@\fP\&.
8874ae
 \fBslotid=\fP and/or \fBtoken=\fP may be specified to force the use of
8874ae
 a particular smard card reader or token if there is more than one
8874ae
 available.  \fBcertid=\fP and/or \fBcertlabel=\fP may be specified to
8874ae
diff --git a/src/plugins/preauth/pkinit/pkinit.h b/src/plugins/preauth/pkinit/pkinit.h
905476
index 8135535e2c..66f92d8f03 100644
8874ae
--- a/src/plugins/preauth/pkinit/pkinit.h
8874ae
+++ b/src/plugins/preauth/pkinit/pkinit.h
8874ae
@@ -42,7 +42,6 @@
8874ae
 #ifndef WITHOUT_PKCS11
8874ae
 #include "pkcs11.h"
8874ae
 
8874ae
-#define PKCS11_MODNAME "opensc-pkcs11.so"
8874ae
 #define PK_SIGLEN_GUESS 1000
8874ae
 #define PK_NOSLOT 999999
8874ae
 #endif
8874ae
-- 
905476
2.38.1
8874ae