📄 leeds_slot.ksh
字号:
# All Recipient's rights under this Agreement shall# terminate if it fails to comply with any of the material# terms or conditions of this Agreement and does not cure# such failure in a reasonable period of time after becoming# aware of such noncompliance. If all Recipient's rights# under this Agreement terminate, Recipient agrees to cease# use and distribution of the Program as soon as reasonably# practicable. However, Recipient's obligations under this# Agreement and any licenses granted by Recipient relating# to the Program shall continue and survive. ## Everyone is permitted to copy and distribute copies of# this Agreement, but in order to avoid inconsistency the# Agreement is copyrighted and may only be modified in the# following manner. The Agreement Steward reserves the right# to publish new versions (including revisions) of this# Agreement from time to time. No one other than the# Agreement Steward has the right to modify this Agreement.## IBM is the initial Agreement Steward. IBM may assign the# responsibility to serve as the Agreement Steward to a# suitable separate entity. Each new version of the# Agreement will be given a distinguishing version number.# The Program (including Contributions) may always be# distributed subject to the version of the Agreement under# which it was received. In addition, after a new version of# the Agreement is published, Contributor may elect to# distribute the Program (including its Contributions) under# the new version. Except as expressly stated in Sections# 2(a) and 2(b) above, Recipient receives no rights or# licenses to the intellectual property of any Contributor# under this Agreement, whether expressly, by implication,# estoppel or otherwise. All rights in the Program not# expressly granted under this Agreement are reserved.### This Agreement is governed by the laws of the State of New# York and the intellectual property laws of the United# States of America. No party to this Agreement will bring a# legal action under this Agreement more than one year after# the cause of action arose. Each party waives its rights to# a jury trial in any resulting litigation. ####*/##/* (C) COPYRIGHT International Business Machines Corp. 2001 */SLOT_DB="ck_slot"DB_PATH="/etc/pkcs11/"DB_LOCATION=`echo $DB_PATH$SLOT_DB`DEEP4758_DLL="/usr/lib/pkcs11/stdll/PKCS11_4758.so"SHALLOW4758_DLL="/usr/lib/pkcs11/stdll/PKCS11_LW.so"SHALLOW_DIR="/etc/pkcs11/4758shallow"DEEP4758_INIT="SC_Initialize"SHALLOW4758_INIT="LW_Initialize"SOFT_DIR="/etc/pkcs11/swtok"SOFT_DLL="/usr/lib/pkcs11/stdll/PKCS11_SW.so"SOFT_INIT="SW_Initialize"SYSTEM=`/usr/bin/uname -s`MANUFACTURER=`/usr/bin/uname -M`# Return CodesOK=0INVALID_PARAMS=1NOT_CRYPT_DEVICE=2NOT_VALID_DEVICE=3NO_DATABASE=4if [ ! $# = 2 ] then echo "Usage: $0 device_name depth" exit $INVALID_PARAMSfiDEVICE=$1DEPTH=$2# If the depth is "soft" then we are configuring the soft token....if [[ $DEPTH = "soft" ]]then test -d $SOFT_DIR if [ $? -ne 0 ] then /usr/bin/mkdir $SOFT_DIR /usr/bin/chgrp pkcs11 $SOFT_DIR /usr/bin/mkdir "$SOFT_DIR"/TOK_OBJ /usr/bin/chgrp pkcs11 "$SOFT_DIR"/TOK_OBJ fi SYS_SLOT="SOFT" SLOT_DESCRIPTION=`echo $MANUFACTURER $SYSTEM "("$SYS_SLOT")"` CONFIG_FILE=`echo "/tmp/leeds_slotcfg"` echo "ck_slot:" > $CONFIG_FILE echo " Present = \"TRUE\"" >> $CONFIG_FILE echo " SlotNumber = "0 >> $CONFIG_FILE echo " SlotDescription = \""$SLOT_DESCRIPTION"\"" >> $CONFIG_FILE echo " ManufacturerID = \""$MANUFACTURER"\"" >> $CONFIG_FILE echo " TokenPresent = \"TRUE\"" >> $CONFIG_FILE echo " RemovableToken = \"FALSE\"" >> $CONFIG_FILE echo " HardwareSlot = \"FALSE\"" >> $CONFIG_FILE echo " HwVersionMajor = 0" >> $CONFIG_FILE echo " HwVersionMinor = 0" >> $CONFIG_FILE echo " FwVersionMajor = 1" >> $CONFIG_FILE echo " FwVersionMinor = 1" >> $CONFIG_FILE echo " Correlator = \" \"" >> $CONFIG_FILE echo " SlotDll = \""$SOFT_DLL"\"" >> $CONFIG_FILE echo " SlotInitFcn = \""$SOFT_INIT"\"" >> $CONFIG_FILE # Set the ODM DIR to be the path to the Slot Manager's Database OLD_ODM=`echo $ODMDIR` export ODMDIR=$DB_PATH /usr/bin/odmadd $CONFIG_FILE > /dev/null 2>&1 #/usr/bin/rm -f $CONFIG_FILE return $OK fi# If the user did not specify a device which starts with "crypt"# it is unsupported so we fail with NOT_CRYPT_DEVICEecho $DEVICE | /usr/bin/grep crypt > /dev/null 2>&1if [ $? -ne 0 ] then exit $NOT_CRYPT_DEVICEfi# Check to see if we can get the attributes for the device.# If we can then it is a valid device# If the device given is not valid, return NOT_VALID_DEVICE`ODMDIR=/etc/objrepos /usr/sbin/lsattr -El $DEVICE > /dev/null 2>&1`if [ $? -ne 0 ] then exit $NOT_VALID_DEVICEfi# If we are using a shallow device, make sure that the directory# to store token objects is available, if not create it and change# the ownership to the pkcs11 group if [[ $DEPTH = "shallow" ]] then test -d $SHALLOW_DIR if [ $? -ne 0 ] then /usr/bin/mkdir $SHALLOW_DIR /usr/bin/chgrp pkcs11 $SHALLOW_DIR /usr/bin/mkdir "$SHALLOW_DIR"/TOK_OBJ /usr/bin/chgrp pkcs11 $SHALLOW_DIR/TOK_OBJ fifi# The device name is now parsed to find the minor number of the# device we are examining. Since the last letter of crypt is "t"# everything after the t is treated as the device numberMINOR=`echo $DEVICE | cut -f 2 -d "t"`if [[ $DEPTH = "deep" ]] then SYS_SLOT="$DEVICE - "`ODMDIR=/etc/objrepos /usr/sbin/lsdev -Cc adapter | /usr/bin/grep $DEVICE | awk '{ print $3 }'` else SYS_SLOT="Shallow"fiSLOT_DESCRIPTION=`echo $MANUFACTURER $SYSTEM "("$SYS_SLOT")"`CONFIG_FILE=`echo "/tmp/leeds_slotcfg"$MINOR`# Set the ODM DIR to be the path to the Slot Manager's DatabaseOLD_ODM=`echo $ODMDIR`export ODMDIR=$DB_PATHtest -r "$DB_LOCATION"if [ $? -ne 0 ] then exit $NO_DATABASEfi# Check to see if the device is already in the slot manager's# Database. This will be done by checking the coorelator of# the device.if [[ $DEPTH = "deep" ]] then IN_DATABASE=`/usr/bin/odmget -q "Correlator = $MINOR" ck_slot | wc -l` if [ $IN_DATABASE -ne 0 ] then exit $OK fi else # adapter is shallow # If the adapter is shallow test to see if there exsist an # exsisting shallow adapter in the database SHALLOW_EXSISTS=`/usr/bin/odmget -q "SlotDll = $SHALLOW4758_DLL" ck_slot | wc -l` if [ $SHALLOW_EXSISTS -ne 0 ] then SHALLOW_COR=`/usr/bin/odmget -q "SlotDll = $SHALLOW4758_DLL" ck_slot | grep Corr | awk '{ print $3 }' | cut -d "\"" -f2` COR_LIST=`echo $SHALLOW_COR | tr "," " "` for k in $COR_LIST do if [ $MINOR = $k ] then exit $OK fi done echo "ck_slot: Correlator = \"$SHALLOW_COR,$MINOR\"" | /usr/bin/odmchange -o ck_slot -q "SlotDll = $SHALLOW4758_DLL" exit $OK fifi# If we have gotten this far then create a stanza for the# database. We have either a deep or new shallow token.echo "ck_slot:" > $CONFIG_FILEecho " Present = \"TRUE\"" >> $CONFIG_FILEecho " SlotNumber = "$MINOR >> $CONFIG_FILEecho " SlotDescription = \""$SLOT_DESCRIPTION"\"" >> $CONFIG_FILEecho " ManufacturerID = \""$MANUFACTURER"\"" >> $CONFIG_FILEecho " TokenPresent = \"TRUE\"" >> $CONFIG_FILEecho " RemovableToken = \"FALSE\"" >> $CONFIG_FILEecho " HardwareSlot = \"FALSE\"" >> $CONFIG_FILEecho " HwVersionMajor = 0" >> $CONFIG_FILEecho " HwVersionMinor = 0" >> $CONFIG_FILEecho " FwVersionMajor = 1" >> $CONFIG_FILEecho " FwVersionMinor = 1" >> $CONFIG_FILEecho " Correlator = \"$MINOR\"" >> $CONFIG_FILEif [[ $DEPTH = "deep" ]] then echo " SlotDll = \""$DEEP4758_DLL"\"" >> $CONFIG_FILE echo " SlotInitFcn = \""$DEEP4758_INIT"\"" >> $CONFIG_FILE else echo " SlotDll = \""$SHALLOW4758_DLL"\"" >> $CONFIG_FILE echo " SlotInitFcn = \""$SHALLOW4758_INIT"\"" >> $CONFIG_FILEfi/usr/bin/odmadd $CONFIG_FILE > /dev/null 2>&1 export ODMDIR=OLD_ODM/usr/bin/rm $CONFIG_FILEreturn $OK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -