Main changes are: - Don't create state dirs (usually /var/lib/opencryptoki/..) with make install as these are already created by pkss11_startup - Only build pkcscca_migrate if flag is set - In every script, use standardized paths, avoid processing them at configure time (use sed to process them at build time) - "Try" fixing pkcs11_startup to use the ./configure'ed directories instead of a hardcoded one. If bi-arch builds are required this will probably need some intervention from the packagers.
Signed-off-by: Klaus Heinrich Kiwi <[email protected]> --- usr/lib/pkcs11/api/Makefile.am | 83 ++++++++++++++--------------- usr/sbin/Makefile.am | 6 +- usr/sbin/pkcs11_startup/Makefile.am | 17 ++++++ usr/sbin/pkcs11_startup/pkcs11_startup.in | 46 ++++++++-------- usr/sbin/pkcs_slot/Makefile.am | 13 +++++ usr/sbin/pkcs_slot/pkcs_slot.in | 70 ++++++++++++------------ 6 files changed, 132 insertions(+), 103 deletions(-) diff --git a/usr/lib/pkcs11/api/Makefile.am b/usr/lib/pkcs11/api/Makefile.am index d4636de..e3349b0 100644 --- a/usr/lib/pkcs11/api/Makefile.am +++ b/usr/lib/pkcs11/api/Makefile.am @@ -18,46 +18,45 @@ AM_CFLAGS = -DSPINXPL -DAPI -DDEV -D_THREAD_SAFE \ opencryptoki_libopencryptoki_la_SOURCES = api_interface.c shrd_mem.c apiutil.c -install-data-local: - mkdir -p $(DESTDIR)/$(libdir)/opencryptoki - cd $(DESTDIR)/$(libdir)/opencryptoki && rm -f PKCS11_API.so && \ +install-data-hook: + cd $(DESTDIR)$(libdir)/opencryptoki && \ ln -sf libopencryptoki.so PKCS11_API.so - cd $(DESTDIR)/$(libdir)/opencryptoki && rm -f methods && \ - ln -sf ../../sbin/ methods - mkdir -p $(DESTDIR)/$(libdir)/pkcs11 - cd $(DESTDIR)/$(libdir)/pkcs11 && rm -f methods && \ - ln -sf ../../sbin/ methods - cd $(DESTDIR)/$(libdir)/pkcs11 && rm -f PKCS11_API.so && \ - ln -sf ../opencryptoki/libopencryptoki.so PKCS11_API.so - cd $(DESTDIR)/$(libdir)/pkcs11 && rm -f libopencryptoki.so && \ - ln -sf ../opencryptoki/libopencryptoki.so libopencryptoki.so - mkdir -p $(DESTDIR)/$(libdir)/opencryptoki/stdll - cd $(DESTDIR)/$(libdir)/pkcs11 && rm -f stdll && \ - ln -sf ../opencryptoki/stdll/ stdll - -groupadd pkcs11 - if test "x$(prefix)" = "x/usr"; then \ - mkdir -p $(DESTDIR)/var/lib/opencryptoki ; \ - chown root:pkcs11 $(DESTDIR)/var/lib/opencryptoki ; \ - chmod 775 $(DESTDIR)/var/lib/opencryptoki ; \ - if [ ! -L $(DESTDIR)/etc/pkcs11 ] ; then \ - if [ -e $(DESTDIR)/etc/pkcs11/* ] ; then \ - mv $(DESTDIR)/etc/pkcs11/* $(DESTDIR)/var/lib/opencryptoki ; \ - fi ; \ - fi ;\ - mkdir -p $(DESTDIR)/etc \ - cd $(DESTDIR)/etc && rm -rf pkcs11 && \ - ln -sf $(DESTDIR)/var/lib/opencryptoki pkcs11 ; \ - else \ - mkdir -p $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ - chown root:pkcs11 $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ - chmod 775 $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ - if [ ! -L $(DESTDIR)/$(sysconfdir)/pkcs11 ] ; then \ - if [ -e $(DESTDIR)/$(sysconfdir)/pkcs11/* ] ; then \ - mv $(DESTDIR)/$(sysconfdir)/pkcs11/* \ - $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ - fi ; \ - fi ; \ - mkdir -p $(DESTDIR)/$(sysconfdir) ; \ - cd $(DESTDIR)/$(sysconfdir) && rm -rf pkcs11 && \ - ln -sf $(DESTDIR)/$(localstatedir)/lib/opencryptoki pkcs11 ; \ - fi + cd $(DESTDIR)$(libdir)/opencryptoki && \ + ln -sf $(DESTDIR)$(sbindir) methods + $(MKDIR_P) $(DESTDIR)$(libdir)/pkcs11 + cd $(DESTDIR)$(libdir)/pkcs11 && \ + ln -sf $(DESTDIR)$(sbindir) methods + cd $(DESTDIR)$(libdir)/pkcs11 && \ + ln -sf $(DESTDIR)$(libdir)/opencryptoki/libopencryptoki.so PKCS11_API.so + cd $(DESTDIR)/$(libdir)/pkcs11 && \ + ln -sf $(DESTDIR)$(libdir)/opencryptoki/libopencryptoki.so libopencryptoki.so + $(MKDIR_P) $(DESTDIR)/$(libdir)/opencryptoki/stdll + cd $(DESTDIR)/$(libdir)/pkcs11 && \ + ln -sf $(DESTDIR)$(libdir)/opencryptoki/stdll/ stdll +# -groupadd pkcs11 +# if test "x$(prefix)" = "x/usr"; then \ +# mkdir -p $(DESTDIR)/var/lib/opencryptoki ; \ +# chown root:pkcs11 $(DESTDIR)/var/lib/opencryptoki ; \ +# chmod 775 $(DESTDIR)/var/lib/opencryptoki ; \ +# if [ ! -L $(DESTDIR)/etc/pkcs11 ] ; then \ +# if [ -e $(DESTDIR)/etc/pkcs11/* ] ; then \ +# mv $(DESTDIR)/etc/pkcs11/* $(DESTDIR)/var/lib/opencryptoki ; \ +# fi ; \ +# fi ;\ +# # mkdir -p $(DESTDIR)/etc \ +# cd $(DESTDIR)/etc && rm -rf pkcs11 && \ +# ln -sf $(DESTDIR)/var/lib/opencryptoki pkcs11 ; \ +# else \ +# mkdir -p $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ +# chown root:pkcs11 $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ +# chmod 775 $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ +# if [ ! -L $(DESTDIR)/$(sysconfdir)/pkcs11 ] ; then \ +# if [ -e $(DESTDIR)/$(sysconfdir)/pkcs11/* ] ; then \ +# mv $(DESTDIR)/$(sysconfdir)/pkcs11/* \ +# $(DESTDIR)/$(localstatedir)/lib/opencryptoki ; \ +# fi ; \ +# fi ; \ +# mkdir -p $(DESTDIR)/$(sysconfdir) ; \ +# cd $(DESTDIR)/$(sysconfdir) && rm -rf pkcs11 && \ +# ln -sf $(DESTDIR)/$(localstatedir)/lib/opencryptoki pkcs11 ; \ +# fi diff --git a/usr/sbin/Makefile.am b/usr/sbin/Makefile.am index 538ae09..708c973 100644 --- a/usr/sbin/Makefile.am +++ b/usr/sbin/Makefile.am @@ -1,6 +1,6 @@ -if CCA -CCA_APP = pkcscca_migrate +if ENABLE_PKCSCCA_MIGRATE +PKCSCCA_MIGRATE_DIR = pkcscca_migrate endif -SUBDIRS = pkcsslotd pkcs11_startup pkcs_slot pkcsconf $(CCA_APP) +SUBDIRS = pkcsslotd pkcs11_startup pkcs_slot pkcsconf $(PKCSCCA_MIGRATE_DIR) diff --git a/usr/sbin/pkcs11_startup/Makefile.am b/usr/sbin/pkcs11_startup/Makefile.am index 6788ad5..cbc8358 100644 --- a/usr/sbin/pkcs11_startup/Makefile.am +++ b/usr/sbin/pkcs11_startup/Makefile.am @@ -1 +1,18 @@ sbin_SCRIPTS = pkcs11_startup + +EXTRA_DIST = pkcs11_startup.in + +CLEANFILES = pkcs11_startup + +pkcs11_startup: pkcs11_startup.in + @SED@ -e s...@sbindir\@!"@sbindir@"!g \ + -e s...@libdir\@!"@libdir@"!g \ + -e s...@libexecdir\@!"@libexecdir@"!g \ + -e s...@localstatedir\@!"@localstatedir@"!g \ + -e s...@id\@!"@ID@"!g \ + -e s...@cat\@!"@CAT@"!g \ + -e s...@sed\@!"@SED@"!g \ + -e s...@groupadd\@!"@GROUPADD@"!g \ + -e s...@usermod\@!"@USERMOD@"!g < $< > $...@-t + @CHMOD@ +x $...@-t + mv $...@-t $@ diff --git a/usr/sbin/pkcs11_startup/pkcs11_startup.in b/usr/sbin/pkcs11_startup/pkcs11_startup.in index bcfd956..bd432ff 100644 --- a/usr/sbin/pkcs11_startup/pkcs11_startup.in +++ b/usr/sbin/pkcs11_startup/pkcs11_startup.in @@ -302,10 +302,10 @@ # Get the operating System.... Everything else falls into that # Get a list of crypto adapters and set error code to 0 -CARDS=`ls /dev/crypt* 2>/dev/null | sed s?\/dev\/??g 2>/dev/null` +CARDS=`ls /dev/crypt* 2>/dev/null | @SED@ s?\/dev\/??g 2>/dev/null` ERRORS=0 -STATCOMMAND=/usr/lib/pkcs11/methods/4758_status -rm -f @CONFIG_PATH@/@CONFIG_FILE@ >/dev/null 2>&1 # always whack the entire config file and build +STATCOMMAND=/@libexecdir@/4758_status +rm -f @localstatedir@/lib/opencryptoki/pk_config_data >/dev/null 2>&1 # always whack the entire config file and build # it from scratch @@ -328,7 +328,7 @@ if [ -x @USERMOD@ -a -x @ID@ ] then # add the pkcs group # replace spaces by commas - @USERMOD@ -G $( @ID@ --groups --name root | /bin/sed -e 'y/ /,/'),pkcs11 root + @USERMOD@ -G $( @ID@ --groups --name root | @SED@ -e 'y/ /,/'),pkcs11 root else echo "Couldn't execute @user...@. Please add root to the group 'pkcs11' manually." fi @@ -347,7 +347,7 @@ do then # need to make this the minor number of the device only x=`ls -l /dev/$i | awk '{ print $6 }'` - @METHOD_PATH@/pkcs_slot $x deep + @sbindir@/pkcs_slot $x deep elif [ $RC = 102 ] then # SAB XXX Need to get the groups created elsewhere @@ -366,21 +366,21 @@ fi # Add the TPM device automatically if it exists -if [ -f @STDLL_PATH@/libpkcs11_tpm.so ] +if [ -f @libdir@/opencryptoki/stdll/libpkcs11_tpm.so ] then - @METHOD_PATH@/pkcs_slot 0 tpm + @sbindir@/pkcs_slot 0 tpm fi # Addition for AEP Devices -if [ -f @STDLL_PATH@/PKCS11_AEP.so ] +if [ -f @libdir@/opencryptoki/stdll/PKCS11_AEP.so ] then - /bin/cat /proc/devices | grep paep >/dev/null 2>&1 + @CAT@ /proc/devices | grep paep >/dev/null 2>&1 rc=$? if [ $rc = 0 ] then - @METHOD_PATH@/pkcs_slot 0 aep + @sbindir@/pkcs_slot 0 aep fi fi @@ -390,35 +390,35 @@ fi # Starting from version 1.3, libica supports software # fallback when no specialized hardware is found, so # we default for including the ica token when it's -# stdll is present (s390x by default) - KlausK Jul'09 -if [ -f @STDLL_PATH@/libpkcs11_ica.so ] +# stdll is present - KlausK Jul'09 +if [ -f @libdir@/opencryptoki/stdll/libpkcs11_ica.so ] then - @METHOD_PATH@/pkcs_slot 0 ica + @sbindir@/pkcs_slot 0 ica fi #add the broadcom device -if [ -f @STDLL_PATH@/PKCS11_BC.so ] +if [ -f @libdir@/opencryptoki/stdll/PKCS11_BC.so ] then - /bin/cat /proc/devices | grep cryptonet >/dev/null 2>&1 + @CAT@ /proc/devices | grep cryptonet >/dev/null 2>&1 rc=$? if [ $rc = 0 ] then - @METHOD_PATH@/pkcs_slot 0 bcom + @sbindir@/pkcs_slot 0 bcom fi fi #add the Corrent device -if [ -f @STDLL_PATH@/PKCS11_CR.so ] +if [ -f @libdir@/opencryptoki/stdll/PKCS11_CR.so ] then - /bin/cat /proc/misc | grep cr702x >/dev/null 2>&1 + @CAT@ /proc/misc | grep cr702x >/dev/null 2>&1 rc=$? if [ $rc = 0 ] then - @METHOD_PATH@/pkcs_slot 0 cr + @sbindir@/pkcs_slot 0 cr fi fi @@ -427,16 +427,16 @@ fi # the CCA stdll *and* for a library needed by the CCA token - KlausK Jul'09 # The libraries required by CCA token are provided by the 'xcryptolinzGA' # RPM package, available from the IBM web site. -if [ -f @STDLL_PATH@/libpkcs11_cca.so ] && [ -f /usr/lib64/libcsulmkapi.so.1 ] +if [ -f @libdir@/opencryptoki/stdll/libpkcs11_cca.so ] && [ -f /usr/lib64/libcsulmkapi.so.1 ] then - @METHOD_PATH@/pkcs_slot 0 cca + @sbindir@/pkcs_slot 0 cca fi # Add the SW token last, so that "dumb" apps that always open # slot 0 will get a HW token if one exists -if [ -f @STDLL_PATH@/libpkcs11_sw.so ] +if [ -f @libdir@/opencryptoki/stdll/libpkcs11_sw.so ] then - @METHOD_PATH@/pkcs_slot 0 soft + @sbindir@/pkcs_slot 0 soft fi if [ $ERRORS -ne 0 ] diff --git a/usr/sbin/pkcs_slot/Makefile.am b/usr/sbin/pkcs_slot/Makefile.am index 1bc259b..3ac2b4d 100644 --- a/usr/sbin/pkcs_slot/Makefile.am +++ b/usr/sbin/pkcs_slot/Makefile.am @@ -1 +1,14 @@ sbin_SCRIPTS = pkcs_slot + +EXTRA_DIST = pkcs_slot.in + +CLEANFILES = pkcs_slot + +pkcs_slot: pkcs_slot.in + @SED@ -e s...@libdir\@!"@libdir@"!g \ + -e s...@localstatedir\@!"@localstatedir@"!g \ + -e s...@mkdir_p\@!"@MKDIR_P@"!g \ + -e s...@chgrp\@!"@CHGRP@"!g \ + -e s...@chmod\@!"@CHMOD@"!g < $< > $...@-t + @CHMOD@ +x $...@-t + mv $...@-t $@ diff --git a/usr/sbin/pkcs_slot/pkcs_slot.in b/usr/sbin/pkcs_slot/pkcs_slot.in index c4845b5..8f06372 100644 --- a/usr/sbin/pkcs_slot/pkcs_slot.in +++ b/usr/sbin/pkcs_slot/pkcs_slot.in @@ -298,42 +298,42 @@ -DEEP4758_DLL="@STDLL_PATH@/PKCS11_4758.so" +DEEP4758_DLL="@libdir@/opencryptoki/stdll/PKCS11_4758.so" DEEP4758_DLL_FN="PKCS11_4758.so" DEEP4758_INIT="SC_Initialize" -SOFT_DIR="@DB_PATH@/swtok" -SOFT_DLL="@STDLL_PATH@/libpkcs11_sw.so" +SOFT_DIR="@localstatedir@/lib/opencryptoki/swtok" +SOFT_DLL="@libdir@/opencryptoki/stdll/libpkcs11_sw.so" SOFT_DLL_FN="libpkcs11_sw.so" SOFT_INIT="ST_Initialize" -ICA_DIR="@DB_PATH@/lite" -ICA_DLL="@STDLL_PATH@/libpkcs11_ica.so" +ICA_DIR="@localstatedir@/lib/opencryptoki/lite" +ICA_DLL="@libdir@/opencryptoki/stdll/libpkcs11_ica.so" ICA_DLL_FN="libpkcs11_ica.so" ICA_INIT="ST_Initialize" -BCOM_DIR="@DB_PATH@/bcom" -BCOM_DLL="@STDLL_PATH@/PKCS11_BC.so" +BCOM_DIR="@localstatedir@/lib/opencryptoki/bcom" +BCOM_DLL="@libdir@/opencryptoki/stdll/PKCS11_BC.so" BCOM_DLL_FN="PKCS11_BC.so" BCOM_INIT="ST_Initialize" -AEP_DIR="@DB_PATH@/aep" -AEP_DLL="@STDLL_PATH@/PKCS11_AEP.so" +AEP_DIR="@localstatedir@/lib/opencryptoki/aep" +AEP_DLL="@libdir@/opencryptoki/stdll/PKCS11_AEP.so" AEP_DLL_FN="PKCS11_AEP.so" AEP_INIT="ST_Initialize" -CR_DIR="@DB_PATH@/cr" -CR_DLL="@STDLL_PATH@/PKCS11_CR.so" +CR_DIR="@localstatedir@/lib/opencryptoki/cr" +CR_DLL="@libdir@/opencryptoki/stdll/PKCS11_CR.so" CR_DLL_FN="PKCS11_CR.so" CR_INIT="ST_Initialize" -TPM_DIR="@DB_PATH@/tpm" -TPM_DLL="@STDLL_PATH@/libpkcs11_tpm.so" +TPM_DIR="@localstatedir@/lib/opencryptoki/tpm" +TPM_DLL="@libdir@/opencryptoki/stdll/libpkcs11_tpm.so" TPM_DLL_FN="libpkcs11_tpm.so" TPM_INIT="ST_Initialize" -CCA_DIR="@DB_PATH@/ccatok" -CCA_DLL="@STDLL_PATH@/libpkcs11_cca.so" +CCA_DIR="@localstatedir@/lib/opencryptoki/ccatok" +CCA_DLL="@libdir@/opencryptoki/stdll/libpkcs11_cca.so" CCA_DLL_FN="libpkcs11_cca.so" CCA_INIT="ST_Initialize" @@ -357,11 +357,11 @@ DEVICE=$1 DEPTH=$2 # Check for the existance of the directories -if [ ! -d @DB_PATH@ ] +if [ ! -d @localstatedir@/lib/opencryptoki ] then - mkdir -p @DB_PATH@ - chgrp pkcs11 @DB_PATH@ - chmod -R g+rwx @DB_PATH@ + @MKDIR_P@ @localstatedir@/lib/opencryptoki + @CHGRP@ pkcs11 @localstatedir@/lib/opencryptoki + @CHMOD@ -R g+rwX @localstatedir@/lib/opencryptoki fi @@ -372,9 +372,9 @@ then if [ $? -ne 0 ] then mkdir $SOFT_DIR - chgrp pkcs11 $SOFT_DIR + @CHGRP@ pkcs11 $SOFT_DIR mkdir "$SOFT_DIR"/TOK_OBJ - chgrp pkcs11 "$SOFT_DIR"/TOK_OBJ + @CHGRP@ pkcs11 "$SOFT_DIR"/TOK_OBJ fi SYS_SLOT="Soft" fi @@ -386,7 +386,7 @@ then if [ $? -ne 0 ] then mkdir $TPM_DIR - chgrp pkcs11 $TPM_DIR + @CHGRP@ pkcs11 $TPM_DIR fi SYS_SLOT="TPM" fi @@ -397,9 +397,9 @@ then if [ $? -ne 0 ] then mkdir $CCA_DIR - chgrp pkcs11 $CCA_DIR + @CHGRP@ pkcs11 $CCA_DIR mkdir "$CCA_DIR"/TOK_OBJ - chgrp pkcs11 "$CCA_DIR"/TOK_OBJ + @CHGRP@ pkcs11 "$CCA_DIR"/TOK_OBJ fi SYS_SLOT="CCA" fi @@ -415,9 +415,9 @@ then if [ $? -ne 0 ] then mkdir $ICA_DIR - chgrp pkcs11 $ICA_DIR + @CHGRP@ pkcs11 $ICA_DIR mkdir "$ICA_DIR"/TOK_OBJ - chgrp pkcs11 "$ICA_DIR"/TOK_OBJ + @CHGRP@ pkcs11 "$ICA_DIR"/TOK_OBJ fi SYS_SLOT="ICA" fi @@ -428,9 +428,9 @@ then if [ $? -ne 0 ] then mkdir $BCOM_DIR - chgrp pkcs11 $BCOM_DIR + @CHGRP@ pkcs11 $BCOM_DIR mkdir "$BCOM_DIR"/TOK_OBJ - chgrp pkcs11 "$BCOM_DIR"/TOK_OBJ + @CHGRP@ pkcs11 "$BCOM_DIR"/TOK_OBJ fi SYS_SLOT="BCOM" fi @@ -441,9 +441,9 @@ then if [ $? -ne 0 ] then mkdir $AEP_DIR - chgrp pkcs11 $AEP_DIR + @CHGRP@ pkcs11 $AEP_DIR mkdir "$AEP_DIR"/TOK_OBJ - chgrp pkcs11 "$AEP_DIR"/TOK_OBJ + @CHGRP@ pkcs11 "$AEP_DIR"/TOK_OBJ fi SYS_SLOT="AEP" fi @@ -454,9 +454,9 @@ then if [ $? -ne 0 ] then mkdir $CR_DIR - chgrp pkcs11 $CR_DIR + @CHGRP@ pkcs11 $CR_DIR mkdir "$CR_DIR"/TOK_OBJ - chgrp pkcs11 "$CR_DIR"/TOK_OBJ + @CHGRP@ pkcs11 "$CR_DIR"/TOK_OBJ fi SYS_SLOT="CRNT" fi @@ -473,7 +473,7 @@ fi SLOT_DESCRIPTION=`echo $MANUFACTURER $SYSTEM "("$SYS_SLOT")"` -cfgfi...@config_path@/@CONFIG_FILE@ +cfgfi...@localstatedir@/lib/opencryptoki/pk_config_data if [ $DEPTH = "deep" ] then @@ -502,8 +502,8 @@ then echo "TRUE|0|$SLOT_DESCRIPTION|$MANUFACTURER|TRUE|FALSE|TRUE|0|0|1|1|NONE|$CCA_DLL_FN|$CCA_INIT" >>$CFGFILE fi -cd @DB_PATH@ -chmod -R g+wrx . +...@chmod@ -R g+wrX @localstatedir@/lib/opencryptoki + exit $OK -- 1.6.2.5 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Opencryptoki-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech
