system/openct: Added to 12.1 repository

This commit is contained in:
LukenShiro 2010-05-11 22:55:25 +02:00 committed by Robby Workman
parent 16f4ae2412
commit 36cfa2e44b
6 changed files with 339 additions and 0 deletions

34
system/openct/README Normal file
View file

@ -0,0 +1,34 @@
OpenCT implements drivers for several smart card readers. It comes as
driver in ifdhandler format for PC/SC-Lite, as CT-API driver, or as
a small and lean middleware, so applications can use it with minimal
overhead. OpenCT also has a primitive mechanism to export smart card
readers to remote machines via TCP/IP.
This requires pcsc-lite (available on SlackBuilds.org).
For serial and pcmcia readers only, for using it as a PC/SC ifdhandler,
you have to edit file reader-openct.conf in /etc/reader.conf.d/, to
comment lines in other file(s) and run "/usr/sbin/update-reader.conf".
Compiling with "APIDOC=1 ./openct.SlackBuild" produces API .pdf
documentation (mainly intended for developers).
Compiling with "NONPRIV=1 ./openct.SlackBuild" enable non-privileged
mode, but you need to modify /etc/rc.d/rc.openctd to allow 'chown' to
change user/group.
To start OpenCT daemon, run "/etc/rc.d/rc.openctd start". This is
most easily accomplished by adding the following to /etc/rc.d/rc.local:
if [ -x /etc/rc.d/rc.openctd ]; then
/etc/rc.d/rc.openctd start
fi
Beware!
- OpenCT daemon is meant as _alternative_ to pcsc-lite: running rc.openctd
and rc.pcscd at the same time can and will lead to unforseeable problems
(specially with usb devices that can be managed by both of them, one daemon
can claim one device, making it unavailable for other daemon).
- for some unknown reasons, if you start rc.openctd and then stop it,
you may need unplug and plug-in your usb smartcard reader in order
to it to be seen again, so udev rule is re-applied.

23
system/openct/doinst.sh Normal file
View file

@ -0,0 +1,23 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
# Keep same perms on rc.openctd.new:
if [ -e etc/rc.d/rc.openctd ]; then
cp -a etc/rc.d/rc.openctd etc/rc.d/rc.openctd.new.incoming
cat etc/rc.d/rc.openctd.new > etc/rc.d/rc.openctd.new.incoming
mv etc/rc.d/rc.openctd.new.incoming etc/rc.d/rc.openctd.new
fi
config etc/rc.d/rc.openctd.new
config etc/openct.conf.new
config etc/reader.conf.d/reader-openct.conf.new

View file

@ -0,0 +1,191 @@
#!/bin/sh
# Slackware build script for openct
# Copyright 2008 LukenShiro <lukenshiro@ngi.it>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=openct
VERSION=${VERSION:-0.6.15}
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
APIDOC=${APIDOC:-0} # api documentation not built by default
NONPRIV=${NONPRIV:-0} # disable not-privileged mode (it will be used by root)
DOCFILES="NEWS TODO LGPL-2.1"
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
fi
set -e # Exit on most errors
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
# building API doc
case "$APIDOC" in
0) APIDOC_FLAG="dis"
;;
*) APIDOC_FLAG="en"
;;
esac
# daemon user/group seem not to be really used unless for /var/run/openct,
# so set them to a saner 'root:root' or 'root:plugdev' (instead of upstream's
# 'openctd:usb'): for now it's unnecessary to add other user/group.
# If NONPRIV is enabled you'll have to verify /etc/rc.d/rc.openctd accordingly.
case "$NONPRIV" in
0) NONPRIV_FLAGS="--with-daemon-user=root \
--with-daemon-groups=root --disable-non-privileged" # root-only
;;
*) NONPRIV_FLAGS="--with-daemon-user=root \
--with-daemon-groups=plugdev --enable-non-privileged" # non privileged mode
;;
esac
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--docdir=/usr/doc/$PRGNAM-$VERSION \
--datarootdir=/usr/share \
--mandir=/usr/man \
--disable-static \
--enable-usb \
--enable-pcsc \
--enable-doc \
--with-udev=/lib/udev \
--with-bundle=/usr/lib/pcsc/drivers \
--${APIDOC_FLAG}able-api-doc \
--with-ifddir \
--disable-static \
--build=$ARCH-slackware-linux \
$NONPRIV_FLAGS
make
make install DESTDIR=$PKG
# copy Slackware-compliant openct daemon (instead of original 'init-script' file)
mkdir -p $PKG/etc/rc.d
cat $CWD/rc.openctd > $PKG/etc/rc.d/rc.openctd.new
chmod 0755 $PKG/etc/rc.d/rc.openctd.new
case "$NONPRIV" in
0) true # do nothing
;;
*) # enable non-privileged in rc.openctd
sed -i "s|#chown root:plugdev|chown root:plugdev|g" $PKG/etc/rc.d/rc.openctd.new
sed -i "s|#chmod 750|chmod 750|g" $PKG/etc/rc.d/rc.openctd.new
;;
esac
# Don't clobber the config file
mv $PKG/etc/openct.conf $PKG/etc/openct.conf.new
# used for serial devices within pcsc-lite
# entries decommented by default (as they could tamper with pcsc-lite's device detection)
# renamed to avoid pcsc-lite's reader.conf overwriting
mkdir -p $PKG/etc/reader.conf.d
cp -a etc/reader.conf $PKG/etc/reader.conf.d/reader-openct.conf.new
sed -i "s|^FRIENDLYNAME|#FRIENDLYNAME|g" $PKG/etc/reader.conf.d/reader-openct.conf.new
sed -i "s|^DEVICENAME|#DEVICENAME|g" $PKG/etc/reader.conf.d/reader-openct.conf.new
sed -i "s|^LIBPATH|#LIBPATH|g" $PKG/etc/reader.conf.d/reader-openct.conf.new
sed -i "s|^CHANNELID|#CHANNELID|g" $PKG/etc/reader.conf.d/reader-openct.conf.new
# installing udev scripts for openct
mkdir -p $PKG/lib/udev
install -m755 etc/openct_usb $PKG/lib/udev/openct_usb
install -m755 etc/openct_pcmcia $PKG/lib/udev/openct_pcmcia
install -m755 etc/openct_serial $PKG/lib/udev/openct_serial
# to maintain forward compatibility with more recent udev (particularly Slackware post-12.1 current's udev)
sed -i "s|udevinfo|udevadm info|g" $PKG/lib/udev/openct_usb
# installing udev rules for openct
mkdir -p $PKG/etc/udev/rules.d
cp -a etc/openct.udev $PKG/etc/udev/rules.d/95-openct.rules
# update attributes according to recent udev rules' naming convention
sed -i "s|SYSFS{|ATTR{|g" $PKG/etc/udev/rules.d/95-openct.rules
# modification taken to prevent bug (as happened in other distributions:
# i.e. https://bugzilla.redhat.com/287871):
# it seems 'sleep' program would otherwise be applied to every usb add event,
# not only to this one
sed -i "s|^PROGRAM=|#PROGRAM=|g" $PKG/etc/udev/rules.d/95-openct.rules
# REMINDER for slackware-current post-12.1:
# as WAIT_FOR_SYSFS is replaced by WAIT_FOR in udev>=123:
#sed -i "s|WAIT_FOR_SYSFS=|WAIT_FOR=|g" $PKG/etc/udev/rules.d/95-openct.rules
# maybe it will have to be moved to /lib/udev/rules.d/, too
# installing openct rules/script for hal
mkdir -p $PKG/usr/share/hal/fdi/information/10freedesktop/
cp -a etc/openct.fdi $PKG/usr/share/hal/fdi/information/10freedesktop/10-usb-openct.fdi
mkdir -p $PKG/usr/libexec
cp -a etc/openct.hald $PKG/usr/libexec/hald-addon-openct
# directory for status, socket and lock files
mkdir -p $PKG/var/run/openct
case "$NONPRIV" in
0) USR_GRP="root:root" # root-only
;;
*) USR_GRP="root:plugdev" # non privileged mode
;;
esac
chown $USR_GRP $PKG/var/run/openct
( cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
( cd $PKG/usr/man
find . -type f -exec gzip -9 {} \;
for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
)
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/
cp -a $DOCFILES $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README.SBo
[ "$APIDOC" = "0" ] && rm -rf $PKG/usr/doc/$PRGNAM-$VERSION/api
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz

View file

@ -0,0 +1,8 @@
PRGNAM="openct"
VERSION="0.6.15"
HOMEPAGE="http://www.opensc-project.org/openct/"
DOWNLOAD="http://www.opensc-project.org/files/openct/openct-0.6.15.tar.gz"
MD5SUM="70205beac03974e266fc259b6c9feaa8"
MAINTAINER="LukenShiro"
EMAIL="lukenshiro@ngi.it"
APPROVED="rworkman"

64
system/openct/rc.openctd Normal file
View file

@ -0,0 +1,64 @@
#! /bin/sh
#
# rc.openctd
# based on original upstream openct's init-script, modified for
# SlackBuilds.org by LukenShiro <lukenshiro<at>ngi.it>
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/openct-control
NAME="OpenCT smart card terminal framework"
OPENCT_OPTS=""
set -e
openctd_start() {
if [ -x $DAEMON ]; then
echo "Starting $NAME ..."
# create the directory for our status and socket files,
# if it does not exist.
[[ -e "/var/run/openct" ]] || mkdir -p /var/run/openct
# maybe you also want to set ownership and permissions here.
# this example would assign the directory to a group "plugdev"
# and set permissions so only users in that group can access
# smart card readers via openct.
#chown root:plugdev /var/run/openct
#chmod 0750 /var/run/openct
$DAEMON $OPENCT_OPTS init
fi
}
openctd_stop() {
if [ -x $DAEMON ]; then
echo "Starting $NAME ..."
$DAEMON $OPENCT_OPTS shutdown
# remove old status (just in case)
[[ -e "/var/run/openct/status" ]] && rm -f /var/run/openct/status
# remove socket and lock files (they seem not to be deleted by daemon)
rm -f /var/run/openct/0 /var/run/openct/status.lock* 2>&1 >/dev/null
fi
}
openctd_restart() {
openctd_stop
sleep 0.1 # keep original sleep duration
openctd_start
}
case "$1" in
'start')
openctd_start
;;
'stop')
openctd_stop
;;
'restart')
openctd_restart
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac

19
system/openct/slack-desc Normal file
View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler---------------------------------------------------|
openct: openct (Middleware framework for smart card terminals)
openct:
openct: It implements drivers for several smart card readers. It comes as
openct: driver in ifdhandler format for PC/SC-Lite, as CT-API driver, or
openct: as a small and lean middleware, so applications can use it with
openct: minimal overhead. OpenCT also has a primitive mechanism to export
openct: smart card readers to remote machines via TCP/IP.
openct:
openct: Homepage: http://www.opensc-project.org/openct/
openct:
openct: