PSARC/2016/217 Smartcard Reintroduction
authorStephen Gaul Jr <steve.gaul@oracle.com>
Fri, 03 Jun 2016 09:30:42 -0700
changeset 6133 73641150a4de
parent 6132 7fb35b7d3c4d
child 6134 e8f61ef0cbe7
PSARC/2016/217 Smartcard Reintroduction PSARC/2016/218 USB CCID PSARC/2016/221 PC/SC Lite smartcard middleware 22017759 Add pcsclite v1.8.14 to Userland consolidation 22017751 Add libccid v1.4.20 to Userland consolidation
components/ccid/Makefile
components/ccid/libccid.license
components/ccid/libccid.p5m
components/ccid/patches/00-ltmain.sh.patch
components/ccid/patches/01-ccid_usb.c.patch
components/ccid/patches/02-commands.c.patch
components/pcsc-lite/Makefile
components/pcsc-lite/Solaris/pcscd.xml
components/pcsc-lite/Solaris/svc-pcscd
components/pcsc-lite/patches/00-configure.ac.patch
components/pcsc-lite/patches/01-ltmain.sh.patch
components/pcsc-lite/patches/02-configfile.c.patch
components/pcsc-lite/patches/03-comp_warning_pcscdaemon.patch
components/pcsc-lite/patches/04-comp_warning_utils.patch
components/pcsc-lite/patches/05-comp_warning_dynfunctions.patch
components/pcsc-lite/patches/06-usb_hotplug.patch
components/pcsc-lite/patches/07-readerfactory.patch
components/pcsc-lite/patches/08-scardconnect_mem.patch
components/pcsc-lite/patches/09-signalhandler.patch
components/pcsc-lite/pcsclite.license
components/pcsc-lite/pcsclite.p5m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ccid/Makefile	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,59 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+BUILD_BITS= 64
+include ../../make-rules/shared-macros.mk
+ 
+COMPONENT_NAME=         ccid
+COMPONENT_VERSION=      1.4.20
+COMPONENT_PROJECT_URL=  https://pcsclite.alioth.debian.org/ccid.html
+COMPONENT_DOWNLOAD_URL= https://alioth.debian.org/frs/download.php/file/4140/
+COMPONENT_ARCHIVE_HASH= sha256:400cb865bb63eed6d7668b2d971cb4644038b9b7a6cda121450d0c6cf6251cbc
+COMPONENT_ARCHIVE=      $(COMPONENT_NAME)-$(COMPONENT_VERSION).tar.bz2
+COMPONENT_ARCHIVE_URL=  $(COMPONENT_DOWNLOAD_URL)/$(COMPONENT_ARCHIVE)
+COMPONENT_BUGDB=        library/smartcard
+ 
+TPNO =                  25483
+
+include $(WS_MAKE_RULES)/common.mk
+
+PERL_VERSION = 5.22
+POD2MAN_PATH = /usr/perl5/$(PERL_VERSION)/bin
+
+COMPONENT_BUILD_ENV +=  PATH="$(PATH):$(POD2MAN_PATH)"
+
+# binary and shared object creation both require the libusb-1.0 library
+CONFIGURE_ENV += LIBUSB_CFLAGS="-I$(USRINCDIR)/libusb-1.0" 
+CONFIGURE_ENV += LIBUSB_LIBS="-L$(USRLIBDIR64) -R$(USRLIBDIR64) -lusb-1.0" 
+
+# compiles as a 64-bit binary and 64-bit library, requires it's own headers for shared objects
+CONFIGURE_ENV += CFLAGS="$(CFLAGS) -m64 -I$(USRINCDIR)/PCSC" 
+CONFIGURE_ENV += LDFLAGS="-L$(USRLIBDIR64) -R$(USRLIBDIR64) -lpcsclite"
+
+# options needed for configure, otherwise default will install into /usr/local   
+CONFIGURE_OPTIONS +=    --exec-prefix=$(USRLIBDIR64)
+CONFIGURE_OPTIONS +=    --enable-libusb
+CONFIGURE_OPTIONS +=    --enable-usbdropdir=$(USRLIBDIR64)/pcsc/drivers
+   
+REQUIRED_PACKAGES += library/libusb-1
+REQUIRED_PACKAGES += library/security/pcsc/pcsclite
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ccid/libccid.license	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,502 @@
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ccid/libccid.p5m	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+
+set name=pkg.fmri \
+    value=pkg:/library/security/pcsc-lite/[email protected]$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary \
+    value="Provides smart card reader drivers for pcsclite (PC/SC)"
+set name=pkg.description \
+    value="Provides the driver functionality and library necessary to interact with smart card readers compliant with the PC/SC specification."
+set name=com.oracle.info.description value="the CCID driver library"
+set name=com.oracle.info.tpno value=$(TPNO)
+set name=info.classification \
+    value=org.opensolaris.category.2008:System/Libraries \
+    value=org.opensolaris.category.2008:System/Security
+set name=info.source-url value=$(COMPONENT_ARCHIVE_URL)
+set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
+set name=org.opensolaris.arc-caseid value=PSARC/2016/218 value=PSARC/2016/217
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+dir  path=usr/lib/$(MACH64)/pcsc/drivers/ifd-ccid.bundle/Contents
+file path=usr/lib/$(MACH64)/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist
+dir  path=usr/lib/$(MACH64)/pcsc/drivers/ifd-ccid.bundle/Contents/Solaris
+file path=usr/lib/$(MACH64)/pcsc/drivers/ifd-ccid.bundle/Contents/Solaris/libccid.so
+license libccid.license license="LGPL v.2.1"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ccid/patches/00-ltmain.sh.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,60 @@
+In-house patch created as a workaround until BugID: 22985199 is completed.
+
+This patch is Solaris buildenv specific and may not be suitable for upstream.
+
+--- ccid-1.4.20/ltmain.sh	2015-08-05 05:37:57.000000000 -0400
++++ ccid-1.4.20/ltmain.sh	2016-05-09 11:29:47.649103701 -0400
[email protected]@ -6146,7 +6146,7 @@
+ 	    func_basename "$deplib"
+             deplib_base=$func_basename_result
+ 	    case " $weak_libs " in
+-	    *" $deplib_base "*) ;;
++	    *" $deplib_base "*) ;;	    
+ 	    *) func_append deplibs " $deplib" ;;
+ 	    esac
+ 	  done
[email protected]@ -6235,7 +6235,7 @@
+ 		    lib=$ladir/$old_library
+ 		    if test "$linkmode,$pass" = "prog,link"; then
+ 		      compile_deplibs="$deplib $compile_deplibs"
+-		      finalize_deplibs="$deplib $finalize_deplibs"
++		      finalize_deplibs="$deplib $finalize_deplibs"                   
+ 		    else
+ 		      deplibs="$deplib $deplibs"
+ 		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
[email protected]@ -6425,7 +6425,15 @@
+ 	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+ 	    case " $new_inherited_linker_flags " in
+ 	      *" $tmp_inherited_linker_flag "*) ;;
+-	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
++	      #
++    	      # XXX: Special case handling for sunstudio and sunlinker on 
++             #      Solaris 11 and 12 as -pthread is no longer needed and 
++	      #      if passed as an arguement/option to ld, it will error 
++             #      when parsed by ld
++             #
++              -pthread) func_append new_inherited_linker_flags "";;
++	      *) func_append new_inherited_linker_flags " $new_inherited_linker_flag";;
++
+ 	    esac
+ 	  done
+ 	fi
[email protected]@ -7145,9 +7153,17 @@
+ 	    case $deplib in
+ 	    -L*) new_libs="$deplib $new_libs" ;;
+ 	    -R*) ;;
++            #
++            # XXX: Special case handling for sunstudio and sunlinker on 
++            #      Solaris 11 and 12 as -pthread is no longer needed and 
++	     #      if passed as an arguement/option to ld, it will error 
++            #      when parsed by ld
++            #
++	    -mt) ;;
++            -pthread) ;;
+ 	    *)
+ 	      # And here is the reason: when a library appears more
+-	      # than once as an explicit dependence of a library, or
++	      # than once as an explicit dependence of a library, or    
+ 	      # is implicitly linked in more than once by the
+ 	      # compiler, it is considered special, and multiple
+ 	      # occurrences thereof are not removed.  Compare this
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ccid/patches/01-ccid_usb.c.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,303 @@
+In-house patch created for multiple CCID usb issues seen on Solaris:
+busy loop, race condition and the closing of libusb. 
+
+This is similar to several different upstream patches for the same ccid_usb.c 
+issues to that will be fixed in a future release of ccid.
+
+--- ccid-1.4.20/src/ccid_usb.c	2016-05-17 10:28:40.585070162 -0400
++++ ccid-1.4.20/src/ccid_usb.c	2016-05-10 22:55:51.214474582 -0400
[email protected]@ -17,10 +17,6 @@
+ 	Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+ 
+-/*
+- * $Id$
+- */
+-
+ #define __CCID_USB__
+ 
+ #include <stdio.h>
[email protected]@ -178,6 +174,9 @@
+ {
+ 	int i, to_exit = TRUE;
+ 
++	if (NULL == ctx)
++		return;
++
+ 	/* if at least 1 reader is still in use we do not exit libusb */
+ 	for (i=0; i<CCID_DRIVER_MAX_READERS; i++)
+ 	{
[email protected]@ -218,9 +217,12 @@
+ 	char infofile[FILENAME_MAX];
+ #ifndef __APPLE__
+ 	unsigned int device_vendor, device_product;
++	unsigned int device_bus = 0;
++	unsigned int device_addr = 0;
+ #else
+ 	/* 100 ms delay */
+ 	struct timespec sleep_time = { 0, 100 * 1000 * 1000 };
++	int count_libusb = 10;
+ #endif
+ 	int interface_number = -1;
+ 	int i;
[email protected]@ -262,9 +264,11 @@
+ 		 */
+ 		if ((dirname = strstr(device, "libudev:")) != NULL)
+ 		{
+-			/* convert the interface number */
+-			interface_number = atoi(dirname + 8 /* "libudev:" */);
+-			DEBUG_COMM2("interface_number: %d", interface_number);
++			/* convert the interface number, bus and device ids */
++			if (sscanf(dirname + 8, "%d:/dev/bus/usb/%d/%d", &interface_number, &device_bus, &device_addr) == 3) {
++				DEBUG_COMM2("interface_number: %d", interface_number);
++				DEBUG_COMM3("usb bus/device: %d/%d", device_bus, device_addr);
++			}
+ 		}
+ 	}
+ #endif
[email protected]@ -307,31 +311,19 @@
+ 		rv = libusb_init(&ctx);
+ 		if (rv != 0)
+ 		{
+-			DEBUG_CRITICAL2("libusb_init failed: %d", rv);
++			DEBUG_CRITICAL2("libusb_init failed: %s", libusb_error_name(rv));
+ 			return_value = STATUS_UNSUCCESSFUL;
+ 			goto end1;
+ 		}
+ 	}
+ 
+-#ifdef __APPLE__
+-	/* give some time to libusb to detect the new USB devices on Mac OS X */
+-	nanosleep(&sleep_time, NULL);
+-#endif
+-	cnt = libusb_get_device_list(ctx, &devs);
+-	if (cnt < 0)
+-	{
+-		DEBUG_CRITICAL("libusb_get_device_list() failed\n");
+-		return_value = STATUS_UNSUCCESSFUL;
+-		goto end1;
+-	}
+-
+ #define GET_KEYS(key, values) \
+ 	rv = LTPBundleFindValueWithKey(&plist, key, values); \
+ 	if (rv) \
+ 	{ \
+ 		DEBUG_CRITICAL2("Value/Key not defined for " key " in %s", infofile); \
+ 		return_value = STATUS_UNSUCCESSFUL; \
+-		goto end2; \
++		goto end1; \
+ 	}
+ 
+ 	GET_KEYS("ifdVendorID", &ifdVendorID)
[email protected]@ -347,6 +339,17 @@
+ 		goto end1;
+ 	}
+ 
++#ifdef __APPLE__
++again_libusb:
++#endif
++	cnt = libusb_get_device_list(ctx, &devs);
++	if (cnt < 0)
++	{
++		DEBUG_CRITICAL("libusb_get_device_list() failed\n");
++		return_value = STATUS_UNSUCCESSFUL;
++		goto end1;
++	}
++
+ 	/* for any supported reader */
+ 	for (alias=0; alias<list_size(ifdVendorID); alias++)
+ 	{
[email protected]@ -377,6 +380,16 @@
+ 			uint8_t bus_number = libusb_get_bus_number(dev);
+ 			uint8_t device_address = libusb_get_device_address(dev);
+ 
++#ifndef __APPLE__
++			if ((device_bus || device_addr)
++				&& ((bus_number != device_bus)
++				|| (device_address != device_addr))) {
++				/* not USB the device we are looking for */
++				continue;
++			}
++#endif
++			DEBUG_COMM3("Try device: %d/%d", bus_number, device_address);
++
+ 			int r = libusb_get_device_descriptor(dev, &desc);
+ 			if (r < 0)
+ 			{
[email protected]@ -385,6 +398,8 @@
+ 				continue;
+ 			}
+ 
++			DEBUG_COMM3("vid/pid : %04X/%04X", desc.idVendor, desc.idProduct);
++
+ 			if (desc.idVendor == vendorID && desc.idProduct == productID)
+ 			{
+ 				int already_used;
[email protected]@ -399,7 +414,8 @@
+ 
+ 				/* simulate a composite device as when libudev is used */
+ 				if ((GEMALTOPROXDU == readerID)
+-					|| (GEMALTOPROXSU == readerID))
++					|| (GEMALTOPROXSU == readerID)
++					|| (FEITIANR502DUAL == readerID))
+ 				{
+ 						/*
+ 						 * We can't talk to the two CCID interfaces
[email protected]@ -496,8 +512,8 @@
+ 				r = libusb_open(dev, &dev_handle);
+ 				if (r < 0)
+ 				{
+-					DEBUG_CRITICAL4("Can't libusb_open(%d/%d): %d",
+-						bus_number, device_address, r);
++					DEBUG_CRITICAL4("Can't libusb_open(%d/%d): %s",
++						bus_number, device_address, libusb_error_name(r));
+ 
+ 					continue;
+ 				}
[email protected]@ -522,8 +538,9 @@
+ 						if (r < 0)
+ 						{
+ 							(void)libusb_close(dev_handle);
+-							DEBUG_CRITICAL4("Can't set configuration on %d/%d: %d",
+-									bus_number, device_address, r);
++							DEBUG_CRITICAL4("Can't set configuration on %d/%d: %s",
++									bus_number, device_address,
++									libusb_error_name(r));
+ 							continue;
+ 						}
+ 					}
[email protected]@ -534,8 +551,8 @@
+ 					{
+ #endif
+ 						(void)libusb_close(dev_handle);
+-						DEBUG_CRITICAL4("Can't get config descriptor on %d/%d: %d",
+-							bus_number, device_address, r);
++						DEBUG_CRITICAL4("Can't get config descriptor on %d/%d: %s",
++							bus_number, device_address, libusb_error_name(r));
+ 						continue;
+ 					}
+ #ifdef __APPLE__
[email protected]@ -570,7 +587,7 @@
+ 					/* an interface was specified and it is not the
+ 					 * current one */
+ 					DEBUG_INFO3("Found interface %d but expecting %d",
+-						interface_number, interface);
++						interface, interface_number);
+ 					DEBUG_INFO3("Wrong interface for USB device %d/%d."
+ 						" Checking next one.", bus_number, device_address);
+ 
[email protected]@ -584,8 +601,8 @@
+ 				if (r < 0)
+ 				{
+ 					(void)libusb_close(dev_handle);
+-					DEBUG_CRITICAL4("Can't claim interface %d/%d: %d",
+-						bus_number, device_address, r);
++					DEBUG_CRITICAL4("Can't claim interface %d/%d: %s",
++						bus_number, device_address, libusb_error_name(r));
+ 					claim_failed = TRUE;
+ 					interface_number = -1;
+ 					continue;
[email protected]@ -610,7 +627,7 @@
+ 
+ 				/* reset for a next reader */
+ 				if (static_interface > 2)
+-					static_interface = 1;
++					static_interface = (FEITIANR502DUAL == readerID) ? 0: 1;
+ #endif
+ 
+ 				/* Get Endpoints values*/
[email protected]@ -696,7 +713,23 @@
+ end:
+ 	if (usbDevice[reader_index].dev_handle == NULL)
+ 	{
++		/* free the libusb allocated list & devices */
++		libusb_free_device_list(devs, 1);
++
++#ifdef __APPLE__
++		/* give some time to libusb to detect the new USB devices on Mac OS X */
++		if (count_libusb > 0)
++		{
++			count_libusb--;
++			DEBUG_INFO2("Wait after libusb: %d", count_libusb);
++			nanosleep(&sleep_time, NULL);
++
++			goto again_libusb;
++		}
++#endif
++		/* failed */
+ 		close_libusb_if_needed();
++
+ 		if (claim_failed)
+ 			return STATUS_COMM_ERROR;
+ 		DEBUG_INFO1("Device not found?");
[email protected]@ -715,6 +748,9 @@
+ 	/* free bundle list */
+ 	bundleRelease(&plist);
+ 
++	if (return_value != STATUS_SUCCESS)
++		close_libusb_if_needed();
++
+ 	return return_value;
+ } /* OpenUSBByName */
+ 
[email protected]@ -868,10 +904,6 @@
+ 		if (usbDevice[reader_index].ccid.sIFD_iManufacturer)
+ 			free(usbDevice[reader_index].ccid.sIFD_iManufacturer);
+ 
+-		/* reset so that bSeq starts at 0 again */
+-		if (DriverOptions & DRIVER_OPTION_RESET_ON_CLOSE)
+-			(void)libusb_reset_device(usbDevice[reader_index].dev_handle);
+-
+ 		if (usbDevice[reader_index].ccid.arrayOfSupportedDataRates)
+ 			free(usbDevice[reader_index].ccid.arrayOfSupportedDataRates);
+ 
[email protected]@ -1210,7 +1242,8 @@
+ 	ret = libusb_submit_transfer(transfer);
+ 	if (ret < 0) {
+ 		libusb_free_transfer(transfer);
+-		DEBUG_CRITICAL2("libusb_submit_transfer failed: %d", ret);
++		DEBUG_CRITICAL2("libusb_submit_transfer failed: %s",
++			libusb_error_name(ret));
+ 		return ret;
+ 	}
+ 
[email protected]@ -1218,17 +1251,18 @@
+ 
+ 	while (!completed)
+ 	{
+-		ret = libusb_handle_events(ctx);
++		ret = libusb_handle_events_completed(ctx, &completed);
+ 		if (ret < 0)
+ 		{
+ 			if (ret == LIBUSB_ERROR_INTERRUPTED)
+ 				continue;
+ 			libusb_cancel_transfer(transfer);
+ 			while (!completed)
+-				if (libusb_handle_events(ctx) < 0)
++				if (libusb_handle_events_completed(ctx, &completed) < 0)
+ 					break;
+ 			libusb_free_transfer(transfer);
+-			DEBUG_CRITICAL2("libusb_handle_events failed: %d", ret);
++			DEBUG_CRITICAL2("libusb_handle_events failed: %s",
++				libusb_error_name(ret));
+ 			return ret;
+ 		}
+ 	}
[email protected]@ -1344,7 +1378,7 @@
+ 		completed = 0;
+ 		while (!completed && !msExt->terminated)
+ 		{
+-			rv = libusb_handle_events(ctx);
++			rv = libusb_handle_events_completed(ctx, &completed);
+ 			if (rv < 0)
+ 			{
+ 				DEBUG_COMM2("libusb_handle_events err %d", rv);
[email protected]@ -1356,7 +1390,7 @@
+ 
+ 				while (!completed && !msExt->terminated)
+ 				{
+-					if (libusb_handle_events(ctx) < 0)
++					if (libusb_handle_events_completed(ctx, &completed) < 0)
+ 						break;
+ 				}
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ccid/patches/02-commands.c.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,41 @@
+In-house patch created for CCID data frame error handling issue seen on Solaris.
+
+The data the CCID frame says to contain will only be evaluated to see if we 
+have less data, if so then report it as an error condition. 
+
+--- ccid-1.4.20/src/commands.c	2016-05-17 10:28:40.587856908 -0400
++++ ccid-1.4.20/src/commands.c	2016-05-17 10:04:27.530080977 -0400
[email protected]@ -1493,6 +1493,8 @@
+ 	length = sizeof(cmd);
+ 	ret = ReadPort(reader_index, &length, cmd);
+ 
++        DEBUG_CRITICAL2("LENGTH 1 is: %d ", length);
++
+ 	/* restore the original value of read timeout */
+ 	ccid_descriptor -> readTimeout = old_timeout;
+ 	CHECK_STATUS(ret)
[email protected]@ -1543,12 +1545,21 @@
+ 		DEBUG_COMM2("New timeout: %d ms", ccid_descriptor -> readTimeout);
+ 		goto time_request;
+ 	}
+-
+-	/* we have read less (or more) data than the CCID frame says to contain */
+-	if (length-10 != dw2i(cmd, 1))
++        /****************************************************************************
++	  * we have read less (or more) data than the CCID frame says to contain       
++         * XXX - Change from original FOSS if test logic of "!=" due to line 1493     
++         *       'length' getting assigned a value of 65636 and 'cmd' appears to be     
++         *       evaluated and returned from 'sizeof' as an unsigned int, therefore         
++         *       (65536 -10) will never equal the data the CCID frame says to contain 
++         *       so, only evaluate to see if we have less data as an error condition. 
++         ****************************************************************************/
++       if (length-10 < dw2i(cmd, 1))
+ 	{
+ 		DEBUG_CRITICAL3("Can't read all data (%d out of %d expected)",
+ 			length-10, dw2i(cmd, 1));
++
++                DEBUG_CRITICAL2("LENGTH 2 is: %d ", length);
++
+ 		return_value = IFD_COMMUNICATION_ERROR;
+ 	}
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/Makefile	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,69 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+BUILD_BITS= 64
+include ../../make-rules/shared-macros.mk
+
+COMPONENT_NAME=         pcsc-lite
+COMPONENT_VERSION=      1.8.14
+COMPONENT_PROJECT_URL=  http://pcsclite.alioth.debian.org/pcsclite.html
+COMPONENT_DOWNLOAD_URL= https://alioth.debian.org/frs/download.php/file/4138
+COMPONENT_ARCHIVE_HASH= sha256:b91f97806042315a41f005e69529cb968621f73f2ddfbd1380111a175b02334e
+COMPONENT_ARCHIVE=      $(COMPONENT_NAME)-$(COMPONENT_VERSION).tar.bz2
+COMPONENT_ARCHIVE_URL=  https://alioth.debian.org/frs/download.php/file/4138/$(COMPONENT_ARCHIVE)
+COMPONENT_BUGDB=        library/smartcard
+ 
+TPNO =                  25484
+
+include $(WS_MAKE_RULES)/common.mk
+
+PERL_VERSION = 5.22
+POD2MAN_PATH = /usr/perl5/$(PERL_VERSION)/bin
+
+COMPONENT_BUILD_ENV +=  PATH="$(PATH):$(POD2MAN_PATH)"
+
+# binary and shared object creation both require the libusb-1.0 library
+CONFIGURE_ENV += LIBUSB_CFLAGS="-I$(USRINCDIR)/libusb-1.0" 
+CONFIGURE_ENV += LIBUSB_LIBS="-L$(USRLIBDIR64) -R$(USRLIBDIR64) -lusb-1.0" 
+
+# compiles as a 64-bit binary and 64-bit library, requires it's own headers for shared objects
+CONFIGURE_ENV += CFLAGS="$(CFLAGS) -m64 -I$(USRINCDIR)/PCSC" 
+CONFIGURE_ENV += LDFLAGS="-L$(USRLIBDIR64) -R$(USRLIBDIR64)"
+
+# configure.ac related patch needs configure script re-creation
+COMPONENT_PREP_ACTION +=(cd $(@D); autoreconf);
+
+# enable ASLR for this component, lint warning against pcscd will occur if this is not set
+ASLR_MODE=$(ASLR_ENABLE)
+
+# options needed for configure, otherwise default will install into /usr/local   
+CONFIGURE_OPTIONS +=    --exec-prefix=$(USRLIBDIR64)
+CONFIGURE_OPTIONS +=    --enable-libusb
+CONFIGURE_OPTIONS +=    --enable-confdir=$(ETCDIR)/pcsc 
+CONFIGURE_OPTIONS +=    --enable-usbdropdir=$(USRLIBDIR64)/pcsc/drivers
+
+# required packages   
+REQUIRED_PACKAGES += library/libusb-1
+REQUIRED_PACKAGES += shell/ksh93
+REQUIRED_PACKAGES += system/core-os
+REQUIRED_PACKAGES += system/network
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/Solaris/pcscd.xml	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+ Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+
+ CDDL HEADER START
+
+ The contents of this file are subject to the terms of the
+ Common Development and Distribution License (the "License").
+ You may not use this file except in compliance with the License.
+
+ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ or http://www.opensolaris.org/os/licensing.
+ See the License for the specific language governing permissions
+ and limitations under the License.
+
+ When distributing Covered Code, include this CDDL HEADER in each
+ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ If applicable, add the following below this CDDL HEADER, with the
+ fields enclosed by brackets "[]" replaced with your own identifying
+ information: Portions Copyright [yyyy] [name of copyright owner]
+
+ CDDL HEADER END
+
+ NOTE:  This service manifest is not editable; its contents will
+ be overwritten by package or patch operations, including
+ operating system upgrade.  Make customizations in a different
+ file.
+--> 
+
+<service_bundle type='manifest' name='pcsc'>
+
+<service
+        name='application/security/pcsc'
+        type='service'
+        version='1'>
+
+	<create_default_instance enabled='false' />
+	<single_instance/>
+
+	<!-- wait for network interfaces to be initialized -->
+	<dependency
+		name='network'
+		grouping='require_all'
+		restart_on='none'
+		type='service'>
+		<service_fmri value='svc:/milestone/network:default' />
+	</dependency>
+
+	<!-- need / and /usr filesystems mounted, /var mounted read/write -->
+	<dependency
+		name='filesystem'
+		grouping='require_all'
+		restart_on='none'
+		type='service'>
+		<service_fmri value='svc:/system/filesystem/minimal' />
+	</dependency>
+
+    <exec_method
+                type='method'
+                name='start'
+                exec='/lib/svc/method/svc-pcscd start'
+                timeout_seconds='60'>
+		<method_context>
+			<method_credential user='root' group='root' />
+		</method_context>
+	</exec_method>
+
+    <exec_method
+                type='method'
+                name='stop'
+                exec=':kill'
+                timeout_seconds='60'>
+		<method_context>
+			<method_credential user='root' group='root' />
+		</method_context>
+	</exec_method>
+
+    <exec_method
+                type='method'
+                name='restart'
+                exec='/lib/svc/method/svc-pcscd restart'
+                timeout_seconds='60'>
+        <method_context>
+            <method_credential user='root' group='root' />
+        </method_context>
+    </exec_method>
+
+	<stability value='Unstable' />
+
+	<template>
+		<common_name>
+			<loctext xml:lang='C'>
+				PCSC Lite Resource Manager
+			</loctext>
+		</common_name>
+	</template>
+</service>
+
+</service_bundle>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/Solaris/svc-pcscd	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,53 @@
+#!/sbin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+
+. /lib/svc/share/smf_include.sh
+
+NAME=pcscd
+DAEMON=/usr/sbin/$NAME
+PIDFILE=$SMF_SYSVOL_FS/$NAME.pid
+
+# exit if the server daemon is not installed
+[ -x "$DAEMON" ] || exit 0
+
+case "$1" in
+'start')
+	$DAEMON >/dev/null 2>&1 &
+	;;
+
+# attribute exec=':kill' in manifest pcscd.xml stops the pcscd daemon.
+
+'restart')
+	if [ -f "$PIDFILE" ]; then
+		/usr/bin/kill -HUP `/usr/bin/cat $PIDFILE`
+	fi
+	;;
+*)
+	echo "Usage: $0 {start|restart}" 
+	exit 1
+	;;
+esac
+exit $?
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/00-configure.ac.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,19 @@
+In-house patch created as a workaround for the hard coded /usr/local/lib
+pre-processor and linker flags in the configure file creation for Solaris.
+
+This patch is Solaris buildenv specific and may not be suitable for upstream.
+
+--- pcsc-lite-1.8.14/configure.ac	2016-05-06 22:11:53.687836295 -0400
++++ pcsc-lite-1.8.14/configure.ac	2016-05-06 22:11:00.834314248 -0400
[email protected]@ -22,8 +22,8 @@
+ 	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED"
+ 	;;
+ *-*-solaris*)
+-	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+-	LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
++	CPPFLAGS="$CPPFLAGS"
++	LDFLAGS="$LDFLAGS"
+ 	need_dash_r=1
+ 	;;
+ *-*-sunos4*)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/01-ltmain.sh.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,39 @@
+In-house patch created as a workaround until BugID: 22985199 is completed.
+
+This patch is Solaris buildenv specific and may not be suitable for upstream.
+
+--- pcsc-lite-1.8.14/ltmain.sh	2016-05-05 13:01:01.885421474 -0400
++++ pcsc-lite-1.8.14/ltmain.sh	2016-03-10 19:52:10.679807000 -0500
[email protected]@ -5662,7 +5662,8 @@
+ 	func_append finalize_command " $arg"
+ 	case "$new_inherited_linker_flags " in
+ 	    *" $arg "*) ;;
+-	    * ) func_append new_inherited_linker_flags " $arg" ;;
++	    * ) func_append new_inherited_linker_flags " $arg" 
++		;;
+ 	esac
+ 	continue
+ 	;;
[email protected]@ -6173,7 +6174,7 @@
+ 	    if test "$linkmode" = lib ; then
+ 		case "$new_inherited_linker_flags " in
+ 		    *" $deplib "*) ;;
+-		    * ) func_append new_inherited_linker_flags " $deplib" ;;
++		    * ) func_append new_inherited_linker_flags "" ;;
+ 		esac
+ 	    fi
+ 	  fi
[email protected]@ -7145,6 +7146,13 @@
+ 	    case $deplib in
+ 	    -L*) new_libs="$deplib $new_libs" ;;
+ 	    -R*) ;;
++	     #
++            # XXX: Special case handling for sunstudio and sunlinker on 
++            #      Solaris 11 and 12 as -pthread is no longer needed and 
++	     #      if passed as an arguement/option to ld, it will error 
++            #      when parsed by ld
++            #
++            -pthread) $new_libs = "$new_libs" ;;
+ 	    *)
+ 	      # And here is the reason: when a library appears more
+ 	      # than once as an explicit dependence of a library, or
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/02-configfile.c.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,57 @@
+In-house patch created for studio compiler and userland build environment.
+This is similar to upstream patch for missing d_type field on SunOS.
+
+This patch is Solaris buildenv specific and may not be suitable for upstream.
+
+--- pcsc-lite-1.8.14/src/configfile.c	2015-04-29 15:23:11.000000000 -0400
++++ pcsc-lite-1.8.14/src/configfile.c	2016-05-05 16:41:12.704546283 -0400
[email protected]@ -2012,37 +2012,28 @@
+ 		while ((direntry = readdir(dir)) != NULL)
+ 		{
+ 			char filename[FILENAME_MAX];
++			struct stat st;		
+ 			int r;
+ 
+ 			snprintf(filename, sizeof(filename), "%s/%s",
+ 				readerconf_dir, direntry->d_name);
+ 
+ 			/* skip non regular files */
+-			if (direntry->d_type == DT_UNKNOWN)
+-			{
+-				struct stat st;
+ 
+-				if (lstat(filename, &st) != 0)
+-				{
+-					Log2(PCSC_LOG_DEBUG, "Skipping non statable file: %s",
+-						direntry->d_name);
+-					continue;
+-				}
+ 
+-				if (!S_ISREG(st.st_mode))
+-				{
+-					Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
++			if (lstat(direntry->d_name, &st) != 0)
++			{
++
++				Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
+ 						direntry->d_name);
+-					continue;
+-				}
++				continue;
+ 			}
+-			else
+-				if (direntry->d_type != DT_REG)
+-				{
+-					Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
+-						direntry->d_name);
+-					continue;
+-				}
++			if (!S_ISREG(st.st_mode))
++                        {
++                                Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
++                                       direntry->d_name);
++                                continue;
++                        }
+ 
+ 			/* skip files starting with . like ., .., .svn, etc */
+ 			if ('.' == direntry->d_name[0])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/03-comp_warning_pcscdaemon.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,31 @@
+Upstream fix that will be included in another release of pcsclite.
+
+From 2360debebf1c35c8599cd2e0fc484e5f5029ab87 Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Sun, 24 Apr 2016 18:52:45 +0200
+Subject: [PATCH] Fix compiler warning on SunOS
+
+pcscdaemon.c: In function 'main':
+pcscdaemon.c:402:5: warning: format '%d' expects argument of type 'int', but argument 6 has type 'pid_t' [-Wformat=]
+     Log2(PCSC_LOG_CRITICAL,
+     ^
+---
+ src/pcscdaemon.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/pcscdaemon.c b/src/pcscdaemon.c
+index 624e759..099b18c 100644
+--- a/src/pcscdaemon.c
++++ b/src/pcscdaemon.c
[email protected]@ -491,7 +491,7 @@ int main(int argc, char **argv)
+ 				Log1(PCSC_LOG_CRITICAL,
+ 					"file " PCSCLITE_CSOCK_NAME " already exists.");
+ 				Log2(PCSC_LOG_CRITICAL,
+-					"Another pcscd (pid: %d) seems to be running.", pid);
++					"Another pcscd (pid: %ld) seems to be running.", (long)pid);
+ 				return EXIT_FAILURE;
+ 			}
+ 			else
+-- 
+1.9.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/04-comp_warning_utils.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,41 @@
+Upstream fix that will be included in another release of pcsclite.
+
+From 88acbfa03b98f28567c2438ea7aca6447488c0af Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Sun, 24 Apr 2016 18:55:45 +0200
+Subject: [PATCH] Fix compiler warnings on SunOS
+
+utils.c: In function 'SendHotplugSignal':
+utils.c:97:3: warning: format '%d' expects argument of type 'int', but argument 6 has type 'pid_t' [-Wformat=]
+   Log2(PCSC_LOG_INFO, "Send hotplug signal to pcscd (pid=%d)", pid);
+   ^
+utils.c:100:4: warning: format '%d' expects argument of type 'int', but argument 6 has type 'pid_t' [-Wformat=]
+    Log3(PCSC_LOG_CRITICAL, "Can't signal pcscd (pid=%d): %s",
+    ^
+---
+ src/utils.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/utils.c b/src/utils.c
+index 7efc9b6..2619a48 100644
+--- a/src/utils.c
++++ b/src/utils.c
[email protected]@ -94,11 +94,12 @@ int SendHotplugSignal(void)
+ 
+ 	if (pid != -1)
+ 	{
+-		Log2(PCSC_LOG_INFO, "Send hotplug signal to pcscd (pid=%d)", pid);
++		Log2(PCSC_LOG_INFO, "Send hotplug signal to pcscd (pid=%ld)",
++			(long)pid);
+ 		if (kill(pid, SIGUSR1) < 0)
+ 		{
+-			Log3(PCSC_LOG_CRITICAL, "Can't signal pcscd (pid=%d): %s",
+-				pid, strerror(errno));
++			Log3(PCSC_LOG_CRITICAL, "Can't signal pcscd (pid=%ld): %s",
++				(long)pid, strerror(errno));
+ 			return EXIT_FAILURE ;
+ 		}
+ 		(void)SYS_Sleep(1);
+-- 
+1.9.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/05-comp_warning_dynfunctions.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,119 @@
+Upstream fix that will be included in another release of pcsclite.
+
+From 4d7abdeff7808b1ab545a98733282d421e751a0e Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Sun, 20 Mar 2016 16:47:05 +0100
+Subject: [PATCH] dyn_*: Fix compiler warnings
+
+DYN_* functions now return a LONG instead of an int
+
+dyn_unix.c:59:10: warning: implicit conversion from 'LONG' (aka 'long') to 'int'
+      changes value from 2148532244 to -2146435052 [-Wconstant-conversion]
+                return SCARD_F_UNKNOWN_ERROR;
+                ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~
+../src/PCSC/pcsclite.h:147:33: note: expanded from macro 'SCARD_F_UNKNOWN_ERROR'
+                                         ^~~~~~~~~~~~~~~~
+dyn_unix.c:77:10: warning: implicit conversion from 'LONG' (aka 'long') to 'int'
+      changes value from 2148532244 to -2146435052 [-Wconstant-conversion]
+                return SCARD_F_UNKNOWN_ERROR;
+                ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~
+../src/PCSC/pcsclite.h:147:33: note: expanded from macro 'SCARD_F_UNKNOWN_ERROR'
+                                         ^~~~~~~~~~~~~~~~
+dyn_unix.c:105:8: warning: implicit conversion from 'LONG' (aka 'long') to 'int'
+      changes value from 2148532244 to -2146435052 [-Wconstant-conversion]
+                rv = SCARD_F_UNKNOWN_ERROR;
+                   ~ ^~~~~~~~~~~~~~~~~~~~~
+../src/PCSC/pcsclite.h:147:33: note: expanded from macro 'SCARD_F_UNKNOWN_ERROR'
+                                         ^~~~~~~~~~~~~~~~
+---
+ src/dyn_generic.h | 6 +++---
+ src/dyn_hpux.c    | 6 +++---
+ src/dyn_unix.c    | 8 ++++----
+ 3 files changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/src/dyn_generic.h b/src/dyn_generic.h
+index 30d8225..8989908 100644
+--- a/src/dyn_generic.h
++++ b/src/dyn_generic.h
[email protected]@ -38,8 +38,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #ifndef __dyn_generic_h__
+ #define __dyn_generic_h__
+ 
+-	int DYN_LoadLibrary(void **, char *);
+-	int DYN_CloseLibrary(void **);
+-	int DYN_GetAddress(void *, /*@[email protected]*/ void **, const char *, int);
++	LONG DYN_LoadLibrary(void **, char *);
++	LONG DYN_CloseLibrary(void **);
++	LONG DYN_GetAddress(void *, /*@[email protected]*/ void **, const char *, int);
+ 
+ #endif
+diff --git a/src/dyn_hpux.c b/src/dyn_hpux.c
+index 03c0392..151ce2a 100644
+--- a/src/dyn_hpux.c
++++ b/src/dyn_hpux.c
[email protected]@ -45,7 +45,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #include "debuglog.h"
+ #include "dyn_generic.h"
+ 
+-int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
++LONG DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
+ {
+ 
+ 	shl_t myHandle;
[email protected]@ -65,7 +65,7 @@ int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
+ 	return SCARD_S_SUCCESS;
+ }
+ 
+-int DYN_CloseLibrary(void **pvLHandle)
++LONG DYN_CloseLibrary(void **pvLHandle)
+ {
+ 
+ 	int rv;
[email protected]@ -82,7 +82,7 @@ int DYN_CloseLibrary(void **pvLHandle)
+ 	return SCARD_S_SUCCESS;
+ }
+ 
+-int DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFunction,
++LONG DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFunction,
+ 	int mayfail)
+ {
+ 
+diff --git a/src/dyn_unix.c b/src/dyn_unix.c
+index 52353dd..edf8397 100644
+--- a/src/dyn_unix.c
++++ b/src/dyn_unix.c
[email protected]@ -47,7 +47,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #include "debuglog.h"
+ #include "dyn_generic.h"
+ 
+-INTERNAL int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
++INTERNAL LONG DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
+ {
+ 	*pvLHandle = NULL;
+ #ifndef PCSCLITE_STATIC_DRIVER
[email protected]@ -63,7 +63,7 @@ INTERNAL int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
+ 	return SCARD_S_SUCCESS;
+ }
+ 
+-INTERNAL int DYN_CloseLibrary(void **pvLHandle)
++INTERNAL LONG DYN_CloseLibrary(void **pvLHandle)
+ {
+ #ifndef PCSCLITE_STATIC_DRIVER
+ 	int ret;
[email protected]@ -81,11 +81,11 @@ INTERNAL int DYN_CloseLibrary(void **pvLHandle)
+ 	return SCARD_S_SUCCESS;
+ }
+ 
+-INTERNAL int DYN_GetAddress(void *pvLHandle, void **pvFHandle,
++INTERNAL LONG DYN_GetAddress(void *pvLHandle, void **pvFHandle,
+ 	const char *pcFunction, int mayfail)
+ {
+ 	char pcFunctionName[256];
+-	int rv = SCARD_S_SUCCESS;
++	LONG rv = SCARD_S_SUCCESS;
+ 
+ 	/* Some platforms might need a leading underscore for the symbol */
+ 	(void)snprintf(pcFunctionName, sizeof(pcFunctionName), "_%s", pcFunction);
+-- 
+1.9.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/06-usb_hotplug.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,55 @@
+Upstream fix that will be included in another release of pcsclite.
+
+From 9d0438ae384c33276d671cdf0830fe5d51901192 Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Fri, 18 Mar 2016 13:29:35 +0100
+Subject: [PATCH] libusb hotplug: handle error in parsing drivers
+
+If HPReadBundleValues() returned an error (-1) it was considered as a
+correct value in HPSearchHotPluggables()
+
+We now check that at least 1 driver has been found.
+
+Thanks to Maksim Ivanov for the bug report
+https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20160314/000550.html
+---
+ src/hotplug_libusb.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/src/hotplug_libusb.c b/src/hotplug_libusb.c
+index 71d5192..eff8519 100644
+--- a/src/hotplug_libusb.c
++++ b/src/hotplug_libusb.c
[email protected]@ -263,19 +263,17 @@ static LONG HPReadBundleValues(void)
+ 	driverSize = listCount;
+ 	closedir(hpDir);
+ 
+-	rv = TRUE;
+ 	if (driverSize == 0)
+ 	{
+ 		Log1(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
+-		rv = FALSE;
+ 	}
+ #ifdef DEBUG_HOTPLUG
+ 	else
+ 		Log2(PCSC_LOG_INFO, "Found drivers for %d readers", listCount);
+ #endif
+ 
+-	return rv;
++	return driverSize;
+ }
+ 
+ static void HPRescanUsbBus(void)
[email protected]@ -490,7 +488,7 @@ LONG HPSearchHotPluggables(void)
+ 		readerTracker[i].fullName = NULL;
+ 	}
+ 
+-	if (HPReadBundleValues())
++	if (HPReadBundleValues() > 0)
+ 	{
+ 		int pipefd[2];
+ 		char c;
+-- 
+1.9.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/07-readerfactory.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,35 @@
+Upstream fix that will be included in another release of pcsclite.
+
+From 890f7edbd931467fd381739257ac1e1f335eb64a Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Sat, 23 Apr 2016 15:57:46 +0200
+Subject: [PATCH] readerfactory: fix compilation warning on SunOS
+
+The code uses alloca() so we #include "alloca.h"
+
+readerfactory.c: In function 'RFAddReader':
+readerfactory.c:211:2: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
+  readerName = alloca(strlen(readerNameLong)+1);
+  ^
+readerfactory.c:211:15: warning: incompatible implicit declaration of built-in function 'alloca'
+  readerName = alloca(strlen(readerNameLong)+1);
+               ^
+---
+ src/readerfactory.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/readerfactory.c b/src/readerfactory.c
+index 14cd42f..df855ea 100644
+--- a/src/readerfactory.c
++++ b/src/readerfactory.c
[email protected]@ -49,6 +49,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <pthread.h>
++#include "alloca.h"
+ 
+ #include "misc.h"
+ #include "pcscd.h"
+-- 
+1.9.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/08-scardconnect_mem.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,45 @@
+Upstream fix that will be included in the another release of pcsclite.
+
+From 2269f10c2d2c5be1308d59469722024650a19b6d Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Wed, 13 Apr 2016 18:29:53 +0200
+Subject: [PATCH] SCardConnect(): fix a Valgrind warning
+
+==19635== Memcheck, a memory error detector
+==19635== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
+==19635== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
+==19635== Command: /usr/rtests/bin/Pkcs11UnitTest.X64 pkcs11_common
+==19635==
+Running pkcs11_common
+pkcs11_common::testGetInfo==19635== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
+==19635== at 0x605A1F7: send (send.c:32)
+==19635== by 0xBC47CE6: ??? (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
+==19635== by 0xBC47E22: ??? (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
+==19635== by 0xBC43BBE: SCardConnect (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
+...
+
+The field scConnectStruct.szReader (containing the reader name) was not
+completely initialized.
+
+Thanks to Andrey Roussev for the patch
+https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20160404/000560.html
+---
+ src/winscard_clnt.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/winscard_clnt.c b/src/winscard_clnt.c
+index e36cab7..ea480de 100644
+--- a/src/winscard_clnt.c
++++ b/src/winscard_clnt.c
[email protected]@ -794,6 +794,7 @@ LONG SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader,
+ 	if (NULL == currentContextMap)
+ 		return SCARD_E_INVALID_HANDLE;
+ 
++	memset(scConnectStruct.szReader, 0, sizeof scConnectStruct.szReader);
+ 	strncpy(scConnectStruct.szReader, szReader, sizeof scConnectStruct.szReader);
+ 	scConnectStruct.szReader[sizeof scConnectStruct.szReader -1] = '\0';
+ 
+-- 
+1.9.1
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/patches/09-signalhandler.patch	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,302 @@
+Upstream fix that will be included in the another release of pcsclite.
+
+From abe436e38aa58cb1140eff0d497ba721474c7703 Mon Sep 17 00:00:00 2001
+From: Ludovic Rousseau <[email protected]>
+Date: Sun, 24 Apr 2016 18:46:53 +0200
+Subject: [PATCH] Fix signal handler by using only allowed functions
+
+The signals are now treated in a special thread created just for that purpose.
+
+Thanks to Andre Florath for the bug report
+https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20160404/000561.html
+
+[Pcsclite-muscle] pcscd jams when using '--auto-exit'
+
+Andre Florath andre at florath.net
+Sat Apr 9 06:06:44 UTC 2016
+
+Hello!
+
+Since some time I have problems with pcscd. I'm using pcscd in
+conjunction with online banking and after a short period of working it
+stops and jams the banking application.
+
+A 'strace' to the pcscd showed that it is still running somewhere
+deep in the USB stack.
+
+The problem is, when manually running the the pcscd, there is no
+problem at all - only when running from systemd.
+Therefore I searched for the differences and found one: the
+'--auto-exit'. Downloaded the source and had a closer look.
+
+What I understand from the source code is, that when '--auto-exit' is
+given, a SIGALRM is generated which (should) terminate the process.
+
+I have noticed that the signal handler 'signal_trap()' uses some
+function calls that are not allowed in signal handlers; like:
+* syslog()
+* gettimeofday()
+* remove()
+
+Using this creates undefined behavior.
+(Please see 'man 7 signal' for a complete list of system calls that
+are not allowed in signal handlers.)
+
+I found a workaround for the issue.
+Changed the service file to:
+
+===
+[Unit]
+Description=PC/SC Smart Card Daemon
+
+[Service]
+ExecStart=/usr/sbin/pcscd --foreground --debug -a
+ExecReload=/usr/sbin/pcscd --hotplug
+
+[Install]
+Also=pcscd.socket
+===
+
+and disabling the pcscd.socket gives me a stable system.
+(Yes - pcscd is now started at boot time and runs the whole time
+ - which is fine for me.)
+
+If you need more information, please drop me a note.
+
+Kind regards
+
+Andre
+---
+ src/pcscdaemon.c | 170 ++++++++++++++++++++++++++++++++++++-------------------
+ 1 file changed, 111 insertions(+), 59 deletions(-)
+
+diff --git a/src/pcscdaemon.c b/src/pcscdaemon.c
+index 791f7f6..624e759 100644
+--- a/src/pcscdaemon.c
++++ b/src/pcscdaemon.c
[email protected]@ -81,6 +81,7 @@ char SocketActivated = FALSE;
+ static int ExitValue = EXIT_FAILURE;
+ int HPForceReaderPolling = 0;
+ static int pipefd[] = {-1, -1};
++static int signal_handler_fd[] = {-1, -1};
+ char Add_Serial_In_Name = TRUE;
+ char Add_Interface_In_Name = TRUE;
+ 
[email protected]@ -89,7 +90,6 @@ char Add_Interface_In_Name = TRUE;
+  */
+ static void at_exit(void);
+ static void clean_temp_files(void);
+-static void signal_reload(int sig);
+ static void signal_trap(int);
+ static void print_version (void);
+ static void print_usage (char const * const);
[email protected]@ -152,6 +152,10 @@ static void SVCServiceRunLoop(void)
+ 			/* Nothing to do in case of a syscall interrupted
+ 			 * It happens when SIGUSR1 (reload) or SIGINT (Ctrl-C) is received
+ 			 * We just try again */
++
++			/* we wait a bit so that the signal handler thread can do
++			 * its job and set AraKiri if needed */
++			SYS_USleep(1000);
+ 			break;
+ 
+ 		default:
[email protected]@ -162,6 +166,93 @@ static void SVCServiceRunLoop(void)
+ 	}
+ }
+ 
++/**
++ * thread dedicated to handle signals
++ *
++ * a signal handler can not call any function. See signal(7) for a list
++ * of function that are safe to call from a signal handler.
++ * The functions syslog(), gettimeofday() and remove() are NOT safe.
++ */
++static void *signal_thread(void *arg)
++{
++	(void)arg;
++
++	while (TRUE)
++	{
++		int r;
++		int sig;
++
++		r = read(signal_handler_fd[0], &sig, sizeof sig);
++		if (r < 0)
++		{
++			Log2(PCSC_LOG_ERROR, "read failed: %s", strerror(errno));
++			return NULL;
++		}
++
++		Log2(PCSC_LOG_INFO, "Received signal: %d", sig);
++
++		/* signal for hotplug */
++		if (SIGUSR1 == sig)
++		{
++#ifdef USE_USB
++			if (! AraKiri)
++				HPReCheckSerialReaders();
++#endif
++			/* Reenable the signal handler.
++			 * This is needed on Solaris and HPUX. */
++			(void)signal(SIGUSR1, signal_trap);
++
++			continue;
++		}
++
++		/* do not wait if asked to terminate
++		 * avoids waiting after the reader(s) in shutdown for example */
++		if (SIGTERM == sig)
++		{
++			Log1(PCSC_LOG_INFO, "Direct suicide");
++			at_exit();
++		}
++
++		if (SIGALRM == sig)
++		{
++			/* normal exit without error */
++			ExitValue = EXIT_SUCCESS;
++		}
++
++		/* the signal handler is called several times for the same Ctrl-C */
++		if (AraKiri == FALSE)
++		{
++			Log1(PCSC_LOG_INFO, "Preparing for suicide");
++			AraKiri = TRUE;
++
++			/* if still in the init/loading phase the AraKiri will not be
++			 * seen by the main event loop
++			 */
++			if (Init)
++			{
++				Log1(PCSC_LOG_INFO, "Suicide during init");
++				at_exit();
++			}
++		}
++		else
++		{
++			/* if pcscd do not want to die */
++			static int lives = 2;
++
++			lives--;
++			/* no live left. Something is blocking the normal death. */
++			if (0 == lives)
++			{
++				Log1(PCSC_LOG_INFO, "Forced suicide");
++				at_exit();
++			}
++		}
++	}
++
++	return NULL;
++}
++
++
+ int main(int argc, char **argv)
+ {
+ 	int rv;
[email protected]@ -515,6 +606,20 @@ int main(int argc, char **argv)
+ 	/* exits on SIGALARM to allow pcscd to suicide if not used */
+ 	(void)signal(SIGALRM, signal_trap);
+ 
++	if (pipe(signal_handler_fd) == -1)
++	{
++		Log2(PCSC_LOG_CRITICAL, "pipe() failed: %s", strerror(errno));
++		return EXIT_FAILURE;
++	}
++
++	pthread_t signal_handler_thread;
++	rv = pthread_create(&signal_handler_thread, NULL, signal_thread, NULL);
++	if (rv)
++	{
++		Log2(PCSC_LOG_CRITICAL, "pthread_create failed: %s", strerror(rv));
++		return EXIT_FAILURE;
++	}
++
+ 	/*
+ 	 * If PCSCLITE_IPC_DIR does not exist then create it
+ 	 */
[email protected]@ -610,7 +715,7 @@ int main(int argc, char **argv)
+ 	/*
+ 	 * Hotplug rescan
+ 	 */
+-	(void)signal(SIGUSR1, signal_reload);
++	(void)signal(SIGUSR1, signal_trap);
+ 
+ 	/*
+ 	 * Initialize the comm structure
[email protected]@ -730,66 +835,13 @@ static void clean_temp_files(void)
+ 			strerror(errno));
+ }
+ 
+-static void signal_reload(/*@[email protected]*/ int sig)
+-{
+-	(void)signal(SIGUSR1, signal_reload);
+-
+-	(void)sig;
+-
+-	if (AraKiri)
+-		return;
+-
+-#ifdef USE_USB
+-	HPReCheckSerialReaders();
+-#endif
+-} /* signal_reload */
+-
+ static void signal_trap(int sig)
+ {
+-	Log2(PCSC_LOG_INFO, "Received signal: %d", sig);
+-
+-	/* do not wait if asked to terminate
+-	 * avoids waiting after the reader(s) in shutdown for example */
+-	if (SIGTERM == sig)
+-	{
+-		Log1(PCSC_LOG_INFO, "Direct suicide");
+-		at_exit();
+-	}
+-
+-	if (SIGALRM == sig)
+-	{
+-		/* normal exit without error */
+-		ExitValue = EXIT_SUCCESS;
+-	}
+-
+-	/* the signal handler is called several times for the same Ctrl-C */
+-	if (AraKiri == FALSE)
+-	{
+-		Log1(PCSC_LOG_INFO, "Preparing for suicide");
+-		AraKiri = TRUE;
+-
+-		/* if still in the init/loading phase the AraKiri will not be
+-		 * seen by the main event loop
+-		 */
+-		if (Init)
+-		{
+-			Log1(PCSC_LOG_INFO, "Suicide during init");
+-			at_exit();
+-		}
+-	}
+-	else
+-	{
+-		/* if pcscd do not want to die */
+-		static int lives = 2;
++	int r;
+ 
+-		lives--;
+-		/* no live left. Something is blocking the normal death. */
+-		if (0 == lives)
+-		{
+-			Log1(PCSC_LOG_INFO, "Forced suicide");
+-			at_exit();
+-		}
+-	}
++	r = write(signal_handler_fd[1], &sig, sizeof sig);
++	if (r < 0)
++		Log2(PCSC_LOG_ERROR, "write failed: %s", strerror(errno));
+ }
+ 
+ static void print_version (void)
+-- 
+1.9.1
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/pcsclite.license	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,119 @@
+Copyright (c) 1999-2003 David Corcoran <[email protected]>
+Copyright (c) 2001-2011 Ludovic Rousseau <[email protected]>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+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.
+
+
+Some files are under GNU GPL v3 or any later version
+- doc/example/pcsc_demo.c
+- the files in src/spy/
+- the files in UnitaryTests/
+
+    Copyright (C) 2003-2014  Ludovic Rousseau
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+Files src/auth.c and src/auth.h are:
+ * Copyright (C) 2013 Red Hat
+ *
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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
+ * COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+ *
+ * Author: Nikos Mavrogiannopoulos <[email protected]>
+
+
+Files src/sd-daemon.c and src/sd-daemon.h are:
+  Copyright 2010 Lennart Poettering
+
+  Permission is hereby granted, free of charge, to any person
+  obtaining a copy of this software and associated documentation files
+  (the "Software"), to deal in the Software without restriction,
+  including without limitation the rights to use, copy, modify, merge,
+  publish, distribute, sublicense, and/or sell copies of the Software,
+  and to permit persons to whom the Software is furnished to do so,
+  subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+
+
+Files src/simclist.c and src/simclist.h are:
+ * Copyright (c) 2007,2008,2009,2010,2011 Mij <[email protected]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/pcsc-lite/pcsclite.p5m	Fri Jun 03 09:30:42 2016 -0700
@@ -0,0 +1,55 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+
+set name=pkg.fmri \
+    value=pkg:/library/security/pcsc/[email protected]$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary \
+    value="Provides smart card services using the SCard API (PC/SC)"
+set name=pkg.description \
+    value="Provides the server functionality and middleware necessary to interact with smart cards compliant with the PC/SC specification."
+set name=com.oracle.info.description value="the PC/SC project"
+set name=com.oracle.info.tpno value=$(TPNO)
+set name=info.classification value=org.opensolaris.category.2008:System/Security
+set name=info.source-url value=$(COMPONENT_ARCHIVE_URL)
+set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
+set name=org.opensolaris.arc-caseid value=PSARC/2016/217 value=PSARC/2016/221
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+dir  path=etc/pcsc
+file Solaris/pcscd.xml path=lib/svc/manifest/application/security/pcscd.xml
+file Solaris/svc-pcscd path=lib/svc/method/svc-pcscd
+file path=usr/include/PCSC/debuglog.h
+file path=usr/include/PCSC/ifdhandler.h
+file path=usr/include/PCSC/pcsclite.h
+file path=usr/include/PCSC/reader.h
+file path=usr/include/PCSC/winscard.h
+file path=usr/include/PCSC/wintypes.h
+link path=usr/lib/$(MACH64)/libpcsclite.so target=libpcsclite.so.1.0.0
+link path=usr/lib/$(MACH64)/libpcsclite.so.1 target=libpcsclite.so.1.0.0
+file path=usr/lib/$(MACH64)/libpcsclite.so.1.0.0
+dir  path=usr/lib/$(MACH64)/pcsc/drivers
+file path=usr/lib/$(MACH64)/pkgconfig/libpcsclite.pc
+file path=usr/sbin/pcscd
+file path=usr/share/doc/pcsc-lite/README.DAEMON
+license pcsclite.license license="GPL v.3"