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

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