--- /dev/null
+# Disable pcscd on-demand startup (#653903)
+https://bugzilla.redhat.com/show_bug.cgi?id=653903
+
+--- pcsc-lite-1.7.0/src/winscard_clnt.c.orig 2011-02-22 23:20:25.000000000 +0100
++++ pcsc-lite-1.7.0/src/winscard_clnt.c 2011-03-18 16:44:57.275416294 +0100
+@@ -444,80 +444,16 @@
+ LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
+ {
+ LONG rv;
+- int daemon_launched = FALSE;
+- int retries = 0;
+
+ API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
+ PROFILE_START
+
+-again:
+ /* Check if the server is running */
+ rv = SCardCheckDaemonAvailability();
+ if (SCARD_E_INVALID_HANDLE == rv)
+ /* we reconnected to a daemon or we got called from a forked child */
+ rv = SCardCheckDaemonAvailability();
+
+- if (SCARD_E_NO_SERVICE == rv)
+- {
+-launch:
+- if (daemon_launched)
+- {
+- retries++;
+- if (retries < 50) /* 50 x 100ms = 5 seconds */
+- {
+- /* give some more time to the server to start */
+- SYS_USleep(100*1000); /* 100 ms */
+- goto again;
+- }
+-
+- /* the server failed to start (in time) */
+- goto end;
+- }
+- else
+- {
+- int pid;
+-
+- pid = fork();
+-
+- if (pid < 0)
+- {
+- Log2(PCSC_LOG_CRITICAL, "fork failed: %s", strerror(errno));
+- rv = SCARD_F_INTERNAL_ERROR;
+- goto end;
+- }
+-
+- if (0 == pid)
+- {
+- int i, max;
+- char *param = getenv("PCSCLITE_PCSCD_ARGS");
+-
+- /* close all file handles except stdin, stdout and
+- * stderr so that pcscd does not confiscate ressources
+- * allocated by the application */
+- max = sysconf(_SC_OPEN_MAX);
+- if (-1 == max)
+- max = 1024;
+- for (i=3; i<max; i++)
+- (void)close(i);
+-
+- /* son process */
+- execl(PCSCD_BINARY, "pcscd", "--auto-exit", param,
+- (char *)NULL);
+- Log2(PCSC_LOG_CRITICAL, "exec " PCSCD_BINARY " failed: %s",
+- strerror(errno));
+- exit(1);
+- }
+-
+- /* father process */
+- daemon_launched = TRUE;
+-
+- if (waitpid(pid, NULL, 0) < 0)
+- Log2(PCSC_LOG_CRITICAL, "waitpid failed: %s", strerror(errno));
+-
+- goto again;
+- }
+- }
+-
+ if (rv != SCARD_S_SUCCESS)
+ goto end;
+
+@@ -526,15 +462,6 @@
+ pvReserved2, phContext);
+ (void)SCardUnlockThread();
+
+- /* SCardEstablishContextTH may fail if the previous pcscd crashed
+- * without cleaning /var/run/pcscd/pcscd.comm */
+- if (SCARD_E_NO_SERVICE == rv)
+- {
+- retries++;
+- if (retries <= 1)
+- goto launch;
+- }
+-
+ end:
+ PROFILE_END(rv)
+ API_TRACE_OUT("%ld", *phContext)
--- /dev/null
+#!/bin/sh
+#
+# pcscd PC/SC Smartcard daemon
+#
+# chkconfig: 2345 12 88
+#
+# description: The PC/SC smart card daemon is a resource manager for the \
+# PC/SC lite and Musclecard frameworks. It coordinates \
+# communications with smart card readers, smart cards, and \
+# cryptographic tokens that are connected to the system.
+#
+# processname: pcscd
+# config: /etc/reader.conf.d
+#
+# Note! pcscd should be started after pcmcia, and shut down before it
+# for smooth experience with PCMCIA readers.
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+upstart_controlled
+
+umask 077
+
+# Set defaults
+LOGLEVEL=""
+PCSCD_OPTIONS=""
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/pcscd ] && . /etc/sysconfig/pcscd
+
+pidfile=/var/run/pcscd/pcscd.pid
+
+start() {
+ if [ -f /var/lock/subsys/pcscd ]; then
+ msg_already_running "PC/SC smart card daemon"
+ return
+ fi
+
+ local logopt
+ case "$LOGLEVEL" in
+ debug|info|error|critical)
+ logopt=--$LOGLEVEL
+ ;;
+ esac
+
+ msg_starting "PC/SC smart card daemon"
+ daemon /usr/sbin/pcscd $logopt $PCSCD_OPTIONS
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pcscd
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/pcscd ]; then
+ msg_not_running "PC/SC smart card daemon"
+ return
+ fi
+
+ msg_stopping "PC/SC smart card daemon"
+ killproc --pidfile $pidfile pcscd
+ rm -f /var/lock/subsys/pcscd
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/pcscd ]; then
+ msg_not_running "PC/SC smart card daemon"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ # pcscd doesn't support reloading on HUP
+ condrestart 7
+ ;;
+ status)
+ status --pidfile $pidfile pcscd
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
--- /dev/null
+# TODO
+# - pcscd & pcscd-lite-libs need to be exactly same version installed otherwise
+# client will flood daemon so much that daemon is not usable (max 200
+# connections reached, etc)
+#
+# Conditional build:
+%bcond_without polkit # polkit support
+%bcond_without udev # udev support (plain libusb if disabled)
+
+Summary: PCSC Framework for Linux
+Summary(pl.UTF-8): Środowisko PCSC dla Linuksa
+Name: pcsc-lite
+Version: 1.8.11
+Release: 2
+License: BSD
+Group: Daemons
+# Source0Download: https://alioth.debian.org/frs/?group_id=30105
+Source0: https://alioth.debian.org/frs/download.php/file/3991/%{name}-%{version}.tar.bz2
+# Source0-md5: 73502ca4ba6526727f9f49c63d805408
+Source1: %{name}-pcscd.init
+Source2: %{name}-pcscd.sysconfig
+Source3: pcscd.upstart
+Source4: %{name}.tmpfiles
+Patch0: %{name}-fhs.patch
+Patch1: %{name}-any.patch
+Patch2: debuglog-pid.patch
+Patch3: configure-expand.patch
+URL: https://alioth.debian.org/projects/pcsclite/
+BuildRequires: autoconf >= 2.69
+BuildRequires: automake >= 1:1.8
+BuildRequires: flex
+%{?with_apidocs:BuildRequires: graphviz}
+BuildRequires: libtool >= 2:2.0
+%{!?with_udev:BuildRequires: libusb-devel >= 1.0}
+BuildRequires: pkgconfig
+%{?with_polkit:BuildRequires: polkit-devel >= 0.111}
+BuildRequires: rpmbuild(macros) >= 1.647
+%{?with_udev:BuildRequires: udev-devel}
+Requires(post,preun): /sbin/chkconfig
+Requires(pretrans): fileutils
+%{?with_polkit:Requires: polkit >= 0.111}
+Requires: rc-scripts >= 0.4.3.0
+Requires: systemd-units >= 38
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define usbdropdir /usr/%{_lib}/pcsc/drivers
+
+%description
+pcscd is the daemon program for PC/SC Lite. It is a resource manager
+that coorinates communications with Smart Card readers and Smart Cards
+that are connected to the system. The purpose of PCSC Lite is to
+provide a Windows(R) SCard interface in a very small form factor for
+communicating to smartcards and readers. PCSC Lite uses the same
+winscard api as used under Windows(R).
+
+%description -l pl.UTF-8
+pcscd jest demonem dla PC/SC Lite. Jest to zarządca zasobów,
+koordynujący komunikację z czytnikami kart procesorowych podłączonymi
+do systemu. Celem PCSC Lite jest udostępnienie interfejsu zgodnego z
+Windows(R) SCard służącego do komunikacji z czytnikami kart chipowych.
+Używa tego samego API winscard, które jest używane pod Microsoft(TM)
+Windows(R).
+
+%package libs
+Summary: PC/SC Lite libraries
+Summary(pl.UTF-8): Biblioteki PC/SC Lite
+Group: Libraries
+
+%description libs
+PC/SC Lite libraries.
+
+%description libs -l pl.UTF-8
+Biblioteki PC/SC Lite.
+
+%package devel
+Summary: PC/SC Lite development files
+Summary(pl.UTF-8): Pliki dla programistów używających PC/SC Lite
+Group: Development/Libraries
+Requires: %{name}-libs = %{version}-%{release}
+
+%description devel
+PC/SC Lite development files.
+
+%description devel -l pl.UTF-8
+Pliki dla programistów używających PC/SC Lite.
+
+%package static
+Summary: Static PC/SC Lite libraries
+Summary(pl.UTF-8): Biblioteki statyczne PC/SC Lite
+Group: Development/Libraries
+Requires: %{name}-devel = %{version}-%{release}
+
+%description static
+Static PC/SC Lite libraries.
+
+%description static -l pl.UTF-8
+Statyczne biblioteki PC/SC Lite.
+
+%package apidocs
+Summary: PC/SC Lite API documentation
+Summary(pl.UTF-8): Dokumentacja API biblioteki PC/SC Lite
+Group: Documentation
+
+%description apidocs
+API and internal documentation for PC/SC Lite library.
+
+%description apidocs -l pl.UTF-8
+Dokumentacja API biblioteki PC/SC Lite.
+
+%prep
+%setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+
+%build
+%{__libtoolize}
+%{__aclocal} -I m4
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+# auto power down unreliable yet
+CPPFLAGS="%{rpmcppflags} -DDISABLE_ON_DEMAND_POWER_ON"
+%configure \
+ %{!?with_udev:--disable-libudev} \
+ --disable-silent-rules \
+ --enable-ipcdir=/var/run/pcscd \
+ %{?with_polkit:--enable-polkit} \
+ --enable-static \
+ --enable-usbdropdir=%{usbdropdir}
+
+%{__make}
+
+%if %{with apidocs}
+doxygen doc/doxygen.conf
+rm -f doc/api/*.{map,md5}
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT%{usbdropdir} \
+ $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig,init} \
+ $RPM_BUILD_ROOT%{_sysconfdir}/reader.conf.d \
+ $RPM_BUILD_ROOT/var/run/pcscd \
+ $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} \
+ $RPM_BUILD_ROOT/usr/lib/tmpfiles.d
+
+%{__make} install \
+ DESTDIR=$RPM_BUILD_ROOT
+
+%{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name}
+
+install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/pcscd
+cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/pcscd
+cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/init/pcscd.conf
+install %{SOURCE4} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/%{name}.conf
+
+cp -p doc/example/*.c $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pretrans
+# upgrade from pcsc-lite < 1.2.9-0.beta7
+if [ -f /etc/reader.conf -a ! -f %{_sysconfdir}/reader.conf.d/reader.conf ]; then
+ install -d -m755 %{_sysconfdir}/reader.conf.d
+ cp -af /etc/reader.conf %{_sysconfdir}/reader.conf.d/reader.conf
+fi
+
+%post
+/sbin/chkconfig --add pcscd
+%service pcscd restart "PC/SC smart card daemon"
+%systemd_post pcscd.service pcscd.socket
+
+%preun
+if [ "$1" = "0" ]; then
+ %service pcscd stop
+ /sbin/chkconfig --del pcscd
+fi
+%systemd_preun pcscd.service pcscd.socket
+
+%postun
+%systemd_reload
+
+%triggerpostun -- pcsc-lite < 1.8.3-1
+%systemd_trigger pcscd.service pcscd.socket
+
+%post libs -p /sbin/ldconfig
+%postun libs -p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS COPYING ChangeLog* DRIVERS HELP NEWS README SECURITY TODO doc/README.{DAEMON,polkit}
+%attr(755,root,root) %{_bindir}/pcsc-spy
+%attr(755,root,root) %{_sbindir}/pcscd
+%dir %{_libdir}/pcsc
+%dir %{_libdir}/pcsc/drivers
+%dir %{_sysconfdir}/reader.conf.d
+%attr(754,root,root) /etc/rc.d/init.d/pcscd
+%config(noreplace) %verify(not md5 mtime size) /etc/init/pcscd.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/pcscd
+%{_mandir}/man1/pcsc-spy.1*
+%{_mandir}/man5/reader.conf.5*
+%{_mandir}/man8/pcscd.8*
+%dir /var/run/pcscd
+%{systemdunitdir}/pcscd.service
+%{systemdunitdir}/pcscd.socket
+/usr/lib/tmpfiles.d/%{name}.conf
+%if %{with polkit}
+%{_datadir}/polkit-1/actions/org.debian.pcsc-lite.policy
+%endif
+
+%files libs
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libpcsclite.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libpcsclite.so.1
+%attr(755,root,root) %{_libdir}/libpcscspy.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libpcscspy.so.0
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libpcsclite.so
+%attr(755,root,root) %{_libdir}/libpcscspy.so
+%{_libdir}/libpcsclite.la
+%{_libdir}/libpcscspy.la
+%{_includedir}/PCSC
+%{_pkgconfigdir}/libpcsclite.pc
+%{_examplesdir}/%{name}-%{version}
+
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libpcsclite.a
+%{_libdir}/libpcscspy.a
+
+%if %{with apidocs}
+%files apidocs
+%defattr(644,root,root,755)
+%doc doc/api/*
+%endif