1*9126SWyllys.Ingersoll@Sun.COM /* 2*9126SWyllys.Ingersoll@Sun.COM * Common Public License Version 0.5 3*9126SWyllys.Ingersoll@Sun.COM * 4*9126SWyllys.Ingersoll@Sun.COM * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF 5*9126SWyllys.Ingersoll@Sun.COM * THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, 6*9126SWyllys.Ingersoll@Sun.COM * REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES 7*9126SWyllys.Ingersoll@Sun.COM * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 8*9126SWyllys.Ingersoll@Sun.COM * 9*9126SWyllys.Ingersoll@Sun.COM * 1. DEFINITIONS 10*9126SWyllys.Ingersoll@Sun.COM * 11*9126SWyllys.Ingersoll@Sun.COM * "Contribution" means: 12*9126SWyllys.Ingersoll@Sun.COM * a) in the case of the initial Contributor, the 13*9126SWyllys.Ingersoll@Sun.COM * initial code and documentation distributed under 14*9126SWyllys.Ingersoll@Sun.COM * this Agreement, and 15*9126SWyllys.Ingersoll@Sun.COM * 16*9126SWyllys.Ingersoll@Sun.COM * b) in the case of each subsequent Contributor: 17*9126SWyllys.Ingersoll@Sun.COM * i) changes to the Program, and 18*9126SWyllys.Ingersoll@Sun.COM * ii) additions to the Program; 19*9126SWyllys.Ingersoll@Sun.COM * 20*9126SWyllys.Ingersoll@Sun.COM * where such changes and/or additions to the Program 21*9126SWyllys.Ingersoll@Sun.COM * originate from and are distributed by that 22*9126SWyllys.Ingersoll@Sun.COM * particular Contributor. A Contribution 'originates' 23*9126SWyllys.Ingersoll@Sun.COM * from a Contributor if it was added to the Program 24*9126SWyllys.Ingersoll@Sun.COM * by such Contributor itself or anyone acting on such 25*9126SWyllys.Ingersoll@Sun.COM * Contributor's behalf. Contributions do not include 26*9126SWyllys.Ingersoll@Sun.COM * additions to the Program which: (i) are separate 27*9126SWyllys.Ingersoll@Sun.COM * modules of software distributed in conjunction with 28*9126SWyllys.Ingersoll@Sun.COM * the Program under their own license agreement, and 29*9126SWyllys.Ingersoll@Sun.COM * (ii) are not derivative works of the Program. 30*9126SWyllys.Ingersoll@Sun.COM * 31*9126SWyllys.Ingersoll@Sun.COM * 32*9126SWyllys.Ingersoll@Sun.COM * "Contributor" means any person or entity that distributes 33*9126SWyllys.Ingersoll@Sun.COM * the Program. 34*9126SWyllys.Ingersoll@Sun.COM * 35*9126SWyllys.Ingersoll@Sun.COM * "Licensed Patents " mean patent claims licensable by a 36*9126SWyllys.Ingersoll@Sun.COM * Contributor which are necessarily infringed by the use or 37*9126SWyllys.Ingersoll@Sun.COM * sale of its Contribution alone or when combined with the 38*9126SWyllys.Ingersoll@Sun.COM * Program. 39*9126SWyllys.Ingersoll@Sun.COM * 40*9126SWyllys.Ingersoll@Sun.COM * "Program" means the Contributions distributed in 41*9126SWyllys.Ingersoll@Sun.COM * accordance with this Agreement. 42*9126SWyllys.Ingersoll@Sun.COM * 43*9126SWyllys.Ingersoll@Sun.COM * "Recipient" means anyone who receives the Program under 44*9126SWyllys.Ingersoll@Sun.COM * this Agreement, including all Contributors. 45*9126SWyllys.Ingersoll@Sun.COM * 46*9126SWyllys.Ingersoll@Sun.COM * 2. GRANT OF RIGHTS 47*9126SWyllys.Ingersoll@Sun.COM * 48*9126SWyllys.Ingersoll@Sun.COM * a) Subject to the terms of this Agreement, each 49*9126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a 50*9126SWyllys.Ingersoll@Sun.COM * no - exclusive, worldwide, royalt - free copyright 51*9126SWyllys.Ingersoll@Sun.COM * license to reproduce, prepare derivative works of, 52*9126SWyllys.Ingersoll@Sun.COM * publicly display, publicly perform, distribute and 53*9126SWyllys.Ingersoll@Sun.COM * sublicense the Contribution of such Contributor, if 54*9126SWyllys.Ingersoll@Sun.COM * any, and such derivative works, in source code and 55*9126SWyllys.Ingersoll@Sun.COM * object code form. 56*9126SWyllys.Ingersoll@Sun.COM * 57*9126SWyllys.Ingersoll@Sun.COM * b) Subject to the terms of this Agreement, each 58*9126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a 59*9126SWyllys.Ingersoll@Sun.COM * no - exclusive, worldwide, royalt - free patent 60*9126SWyllys.Ingersoll@Sun.COM * license under Licensed Patents to make, use, sell, 61*9126SWyllys.Ingersoll@Sun.COM * offer to sell, import and otherwise transfer the 62*9126SWyllys.Ingersoll@Sun.COM * Contribution of such Contributor, if any, in source 63*9126SWyllys.Ingersoll@Sun.COM * code and object code form. This patent license 64*9126SWyllys.Ingersoll@Sun.COM * shall apply to the combination of the Contribution 65*9126SWyllys.Ingersoll@Sun.COM * and the Program if, at the time the Contribution is 66*9126SWyllys.Ingersoll@Sun.COM * added by the Contributor, such addition of the 67*9126SWyllys.Ingersoll@Sun.COM * Contribution causes such combination to be covered 68*9126SWyllys.Ingersoll@Sun.COM * by the Licensed Patents. The patent license shall 69*9126SWyllys.Ingersoll@Sun.COM * not apply to any other combinations which include 70*9126SWyllys.Ingersoll@Sun.COM * the Contribution. No hardware per se is licensed 71*9126SWyllys.Ingersoll@Sun.COM * hereunder. 72*9126SWyllys.Ingersoll@Sun.COM * 73*9126SWyllys.Ingersoll@Sun.COM * c) Recipient understands that although each 74*9126SWyllys.Ingersoll@Sun.COM * Contributor grants the licenses to its 75*9126SWyllys.Ingersoll@Sun.COM * Contributions set forth herein, no assurances are 76*9126SWyllys.Ingersoll@Sun.COM * provided by any Contributor that the Program does 77*9126SWyllys.Ingersoll@Sun.COM * not infringe the patent or other intellectual 78*9126SWyllys.Ingersoll@Sun.COM * property rights of any other entity. Each 79*9126SWyllys.Ingersoll@Sun.COM * Contributor disclaims any liability to Recipient 80*9126SWyllys.Ingersoll@Sun.COM * for claims brought by any other entity based on 81*9126SWyllys.Ingersoll@Sun.COM * infringement of intellectual property rights or 82*9126SWyllys.Ingersoll@Sun.COM * otherwise. As a condition to exercising the rights 83*9126SWyllys.Ingersoll@Sun.COM * and licenses granted hereunder, each Recipient 84*9126SWyllys.Ingersoll@Sun.COM * hereby assumes sole responsibility to secure any 85*9126SWyllys.Ingersoll@Sun.COM * other intellectual property rights needed, if any. 86*9126SWyllys.Ingersoll@Sun.COM * 87*9126SWyllys.Ingersoll@Sun.COM * For example, if a third party patent license is 88*9126SWyllys.Ingersoll@Sun.COM * required to allow Recipient to distribute the 89*9126SWyllys.Ingersoll@Sun.COM * Program, it is Recipient's responsibility to 90*9126SWyllys.Ingersoll@Sun.COM * acquire that license before distributing the 91*9126SWyllys.Ingersoll@Sun.COM * Program. 92*9126SWyllys.Ingersoll@Sun.COM * 93*9126SWyllys.Ingersoll@Sun.COM * d) Each Contributor represents that to its 94*9126SWyllys.Ingersoll@Sun.COM * knowledge it has sufficient copyright rights in its 95*9126SWyllys.Ingersoll@Sun.COM * Contribution, if any, to grant the copyright 96*9126SWyllys.Ingersoll@Sun.COM * license set forth in this Agreement. 97*9126SWyllys.Ingersoll@Sun.COM * 98*9126SWyllys.Ingersoll@Sun.COM * 3. REQUIREMENTS 99*9126SWyllys.Ingersoll@Sun.COM * 100*9126SWyllys.Ingersoll@Sun.COM * A Contributor may choose to distribute the Program in 101*9126SWyllys.Ingersoll@Sun.COM * object code form under its own license agreement, provided 102*9126SWyllys.Ingersoll@Sun.COM * that: 103*9126SWyllys.Ingersoll@Sun.COM * a) it complies with the terms and conditions of 104*9126SWyllys.Ingersoll@Sun.COM * this Agreement; and 105*9126SWyllys.Ingersoll@Sun.COM * 106*9126SWyllys.Ingersoll@Sun.COM * b) its license agreement: 107*9126SWyllys.Ingersoll@Sun.COM * i) effectively disclaims on behalf of all 108*9126SWyllys.Ingersoll@Sun.COM * Contributors all warranties and conditions, express 109*9126SWyllys.Ingersoll@Sun.COM * and implied, including warranties or conditions of 110*9126SWyllys.Ingersoll@Sun.COM * title and no - infringement, and implied warranties 111*9126SWyllys.Ingersoll@Sun.COM * or conditions of merchantability and fitness for a 112*9126SWyllys.Ingersoll@Sun.COM * particular purpose; 113*9126SWyllys.Ingersoll@Sun.COM * 114*9126SWyllys.Ingersoll@Sun.COM * ii) effectively excludes on behalf of all 115*9126SWyllys.Ingersoll@Sun.COM * Contributors all liability for damages, including 116*9126SWyllys.Ingersoll@Sun.COM * direct, indirect, special, incidental and 117*9126SWyllys.Ingersoll@Sun.COM * consequential damages, such as lost profits; 118*9126SWyllys.Ingersoll@Sun.COM * 119*9126SWyllys.Ingersoll@Sun.COM * iii) states that any provisions which differ from 120*9126SWyllys.Ingersoll@Sun.COM * this Agreement are offered by that Contributor 121*9126SWyllys.Ingersoll@Sun.COM * alone and not by any other party; and 122*9126SWyllys.Ingersoll@Sun.COM * 123*9126SWyllys.Ingersoll@Sun.COM * iv) states that source code for the Program is 124*9126SWyllys.Ingersoll@Sun.COM * available from such Contributor, and informs 125*9126SWyllys.Ingersoll@Sun.COM * licensees how to obtain it in a reasonable manner 126*9126SWyllys.Ingersoll@Sun.COM * on or through a medium customarily used for 127*9126SWyllys.Ingersoll@Sun.COM * software exchange. 128*9126SWyllys.Ingersoll@Sun.COM * 129*9126SWyllys.Ingersoll@Sun.COM * When the Program is made available in source code form: 130*9126SWyllys.Ingersoll@Sun.COM * a) it must be made available under this Agreement; 131*9126SWyllys.Ingersoll@Sun.COM * and 132*9126SWyllys.Ingersoll@Sun.COM * b) a copy of this Agreement must be included with 133*9126SWyllys.Ingersoll@Sun.COM * each copy of the Program. 134*9126SWyllys.Ingersoll@Sun.COM * 135*9126SWyllys.Ingersoll@Sun.COM * Contributors may not remove or alter any copyright notices 136*9126SWyllys.Ingersoll@Sun.COM * contained within the Program. 137*9126SWyllys.Ingersoll@Sun.COM * 138*9126SWyllys.Ingersoll@Sun.COM * Each Contributor must identify itself as the originator of 139*9126SWyllys.Ingersoll@Sun.COM * its Contribution, if any, in a manner that reasonably 140*9126SWyllys.Ingersoll@Sun.COM * allows subsequent Recipients to identify the originator of 141*9126SWyllys.Ingersoll@Sun.COM * the Contribution. 142*9126SWyllys.Ingersoll@Sun.COM * 143*9126SWyllys.Ingersoll@Sun.COM * 144*9126SWyllys.Ingersoll@Sun.COM * 4. COMMERCIAL DISTRIBUTION 145*9126SWyllys.Ingersoll@Sun.COM * 146*9126SWyllys.Ingersoll@Sun.COM * Commercial distributors of software may accept certain 147*9126SWyllys.Ingersoll@Sun.COM * responsibilities with respect to end users, business 148*9126SWyllys.Ingersoll@Sun.COM * partners and the like. While this license is intended to 149*9126SWyllys.Ingersoll@Sun.COM * facilitate the commercial use of the Program, the 150*9126SWyllys.Ingersoll@Sun.COM * Contributor who includes the Program in a commercial 151*9126SWyllys.Ingersoll@Sun.COM * product offering should do so in a manner which does not 152*9126SWyllys.Ingersoll@Sun.COM * create potential liability for other Contributors. 153*9126SWyllys.Ingersoll@Sun.COM * Therefore, if a Contributor includes the Program in a 154*9126SWyllys.Ingersoll@Sun.COM * commercial product offering, such Contributor ("Commercial 155*9126SWyllys.Ingersoll@Sun.COM * Contributor") hereby agrees to defend and indemnify every 156*9126SWyllys.Ingersoll@Sun.COM * other Contributor ("Indemnified Contributor") against any 157*9126SWyllys.Ingersoll@Sun.COM * losses, damages and costs (collectively "Losses") arising 158*9126SWyllys.Ingersoll@Sun.COM * from claims, lawsuits and other legal actions brought by a 159*9126SWyllys.Ingersoll@Sun.COM * third party against the Indemnified Contributor to the 160*9126SWyllys.Ingersoll@Sun.COM * extent caused by the acts or omissions of such Commercial 161*9126SWyllys.Ingersoll@Sun.COM * Contributor in connection with its distribution of the 162*9126SWyllys.Ingersoll@Sun.COM * Program in a commercial product offering. The obligations 163*9126SWyllys.Ingersoll@Sun.COM * in this section do not apply to any claims or Losses 164*9126SWyllys.Ingersoll@Sun.COM * relating to any actual or alleged intellectual property 165*9126SWyllys.Ingersoll@Sun.COM * infringement. In order to qualify, an Indemnified 166*9126SWyllys.Ingersoll@Sun.COM * Contributor must: a) promptly notify the Commercial 167*9126SWyllys.Ingersoll@Sun.COM * Contributor in writing of such claim, and b) allow the 168*9126SWyllys.Ingersoll@Sun.COM * Commercial Contributor to control, and cooperate with the 169*9126SWyllys.Ingersoll@Sun.COM * Commercial Contributor in, the defense and any related 170*9126SWyllys.Ingersoll@Sun.COM * settlement negotiations. The Indemnified Contributor may 171*9126SWyllys.Ingersoll@Sun.COM * participate in any such claim at its own expense. 172*9126SWyllys.Ingersoll@Sun.COM * 173*9126SWyllys.Ingersoll@Sun.COM * 174*9126SWyllys.Ingersoll@Sun.COM * For example, a Contributor might include the Program in a 175*9126SWyllys.Ingersoll@Sun.COM * commercial product offering, Product X. That Contributor 176*9126SWyllys.Ingersoll@Sun.COM * is then a Commercial Contributor. If that Commercial 177*9126SWyllys.Ingersoll@Sun.COM * Contributor then makes performance claims, or offers 178*9126SWyllys.Ingersoll@Sun.COM * warranties related to Product X, those performance claims 179*9126SWyllys.Ingersoll@Sun.COM * and warranties are such Commercial Contributor's 180*9126SWyllys.Ingersoll@Sun.COM * responsibility alone. Under this section, the Commercial 181*9126SWyllys.Ingersoll@Sun.COM * Contributor would have to defend claims against the other 182*9126SWyllys.Ingersoll@Sun.COM * Contributors related to those performance claims and 183*9126SWyllys.Ingersoll@Sun.COM * warranties, and if a court requires any other Contributor 184*9126SWyllys.Ingersoll@Sun.COM * to pay any damages as a result, the Commercial Contributor 185*9126SWyllys.Ingersoll@Sun.COM * must pay those damages. 186*9126SWyllys.Ingersoll@Sun.COM * 187*9126SWyllys.Ingersoll@Sun.COM * 188*9126SWyllys.Ingersoll@Sun.COM * 5. NO WARRANTY 189*9126SWyllys.Ingersoll@Sun.COM * 190*9126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE 191*9126SWyllys.Ingersoll@Sun.COM * PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT 192*9126SWyllys.Ingersoll@Sun.COM * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 193*9126SWyllys.Ingersoll@Sun.COM * IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 194*9126SWyllys.Ingersoll@Sun.COM * CONDITIONS OF TITLE, NO - INFRINGEMENT, MERCHANTABILITY OR 195*9126SWyllys.Ingersoll@Sun.COM * FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 196*9126SWyllys.Ingersoll@Sun.COM * responsible for determining the appropriateness of using 197*9126SWyllys.Ingersoll@Sun.COM * and distributing the Program and assumes all risks 198*9126SWyllys.Ingersoll@Sun.COM * associated with its exercise of rights under this 199*9126SWyllys.Ingersoll@Sun.COM * Agreement, including but not limited to the risks and 200*9126SWyllys.Ingersoll@Sun.COM * costs of program errors, compliance with applicable laws, 201*9126SWyllys.Ingersoll@Sun.COM * damage to or loss of data, programs or equipment, and 202*9126SWyllys.Ingersoll@Sun.COM * unavailability or interruption of operations. 203*9126SWyllys.Ingersoll@Sun.COM * 204*9126SWyllys.Ingersoll@Sun.COM * 6. DISCLAIMER OF LIABILITY 205*9126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER 206*9126SWyllys.Ingersoll@Sun.COM * RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY 207*9126SWyllys.Ingersoll@Sun.COM * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 208*9126SWyllys.Ingersoll@Sun.COM * OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 209*9126SWyllys.Ingersoll@Sun.COM * LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF 210*9126SWyllys.Ingersoll@Sun.COM * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 211*9126SWyllys.Ingersoll@Sun.COM * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 212*9126SWyllys.Ingersoll@Sun.COM * OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE 213*9126SWyllys.Ingersoll@Sun.COM * OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE 214*9126SWyllys.Ingersoll@Sun.COM * POSSIBILITY OF SUCH DAMAGES. 215*9126SWyllys.Ingersoll@Sun.COM * 216*9126SWyllys.Ingersoll@Sun.COM * 7. GENERAL 217*9126SWyllys.Ingersoll@Sun.COM * 218*9126SWyllys.Ingersoll@Sun.COM * If any provision of this Agreement is invalid or 219*9126SWyllys.Ingersoll@Sun.COM * unenforceable under applicable law, it shall not affect 220*9126SWyllys.Ingersoll@Sun.COM * the validity or enforceability of the remainder of the 221*9126SWyllys.Ingersoll@Sun.COM * terms of this Agreement, and without further action by the 222*9126SWyllys.Ingersoll@Sun.COM * parties hereto, such provision shall be reformed to the 223*9126SWyllys.Ingersoll@Sun.COM * minimum extent necessary to make such provision valid and 224*9126SWyllys.Ingersoll@Sun.COM * enforceable. 225*9126SWyllys.Ingersoll@Sun.COM * 226*9126SWyllys.Ingersoll@Sun.COM * 227*9126SWyllys.Ingersoll@Sun.COM * If Recipient institutes patent litigation against a 228*9126SWyllys.Ingersoll@Sun.COM * Contributor with respect to a patent applicable to 229*9126SWyllys.Ingersoll@Sun.COM * software (including a cros - claim or counterclaim in a 230*9126SWyllys.Ingersoll@Sun.COM * lawsuit), then any patent licenses granted by that 231*9126SWyllys.Ingersoll@Sun.COM * Contributor to such Recipient under this Agreement shall 232*9126SWyllys.Ingersoll@Sun.COM * terminate as of the date such litigation is filed. In 233*9126SWyllys.Ingersoll@Sun.COM * addition, If Recipient institutes patent litigation 234*9126SWyllys.Ingersoll@Sun.COM * against any entity (including a cros - claim or 235*9126SWyllys.Ingersoll@Sun.COM * counterclaim in a lawsuit) alleging that the Program 236*9126SWyllys.Ingersoll@Sun.COM * itself (excluding combinations of the Program with other 237*9126SWyllys.Ingersoll@Sun.COM * software or hardware) infringes such Recipient's 238*9126SWyllys.Ingersoll@Sun.COM * patent(s), then such Recipient's rights granted under 239*9126SWyllys.Ingersoll@Sun.COM * Section 2(b) shall terminate as of the date such 240*9126SWyllys.Ingersoll@Sun.COM * litigation is filed. 241*9126SWyllys.Ingersoll@Sun.COM * 242*9126SWyllys.Ingersoll@Sun.COM * All Recipient's rights under this Agreement shall 243*9126SWyllys.Ingersoll@Sun.COM * terminate if it fails to comply with any of the material 244*9126SWyllys.Ingersoll@Sun.COM * terms or conditions of this Agreement and does not cure 245*9126SWyllys.Ingersoll@Sun.COM * such failure in a reasonable period of time after becoming 246*9126SWyllys.Ingersoll@Sun.COM * aware of such noncompliance. If all Recipient's rights 247*9126SWyllys.Ingersoll@Sun.COM * under this Agreement terminate, Recipient agrees to cease 248*9126SWyllys.Ingersoll@Sun.COM * use and distribution of the Program as soon as reasonably 249*9126SWyllys.Ingersoll@Sun.COM * practicable. However, Recipient's obligations under this 250*9126SWyllys.Ingersoll@Sun.COM * Agreement and any licenses granted by Recipient relating 251*9126SWyllys.Ingersoll@Sun.COM * to the Program shall continue and survive. 252*9126SWyllys.Ingersoll@Sun.COM * 253*9126SWyllys.Ingersoll@Sun.COM * Everyone is permitted to copy and distribute copies of 254*9126SWyllys.Ingersoll@Sun.COM * this Agreement, but in order to avoid inconsistency the 255*9126SWyllys.Ingersoll@Sun.COM * Agreement is copyrighted and may only be modified in the 256*9126SWyllys.Ingersoll@Sun.COM * following manner. The Agreement Steward reserves the right 257*9126SWyllys.Ingersoll@Sun.COM * to publish new versions (including revisions) of this 258*9126SWyllys.Ingersoll@Sun.COM * Agreement from time to time. No one other than the 259*9126SWyllys.Ingersoll@Sun.COM * Agreement Steward has the right to modify this Agreement. 260*9126SWyllys.Ingersoll@Sun.COM * 261*9126SWyllys.Ingersoll@Sun.COM * IBM is the initial Agreement Steward. IBM may assign the 262*9126SWyllys.Ingersoll@Sun.COM * responsibility to serve as the Agreement Steward to a 263*9126SWyllys.Ingersoll@Sun.COM * suitable separate entity. Each new version of the 264*9126SWyllys.Ingersoll@Sun.COM * Agreement will be given a distinguishing version number. 265*9126SWyllys.Ingersoll@Sun.COM * The Program (including Contributions) may always be 266*9126SWyllys.Ingersoll@Sun.COM * distributed subject to the version of the Agreement under 267*9126SWyllys.Ingersoll@Sun.COM * which it was received. In addition, after a new version of 268*9126SWyllys.Ingersoll@Sun.COM * the Agreement is published, Contributor may elect to 269*9126SWyllys.Ingersoll@Sun.COM * distribute the Program (including its Contributions) under 270*9126SWyllys.Ingersoll@Sun.COM * the new version. Except as expressly stated in Sections 271*9126SWyllys.Ingersoll@Sun.COM * 2(a) and 2(b) above, Recipient receives no rights or 272*9126SWyllys.Ingersoll@Sun.COM * licenses to the intellectual property of any Contributor 273*9126SWyllys.Ingersoll@Sun.COM * under this Agreement, whether expressly, by implication, 274*9126SWyllys.Ingersoll@Sun.COM * estoppel or otherwise. All rights in the Program not 275*9126SWyllys.Ingersoll@Sun.COM * expressly granted under this Agreement are reserved. 276*9126SWyllys.Ingersoll@Sun.COM * 277*9126SWyllys.Ingersoll@Sun.COM * 278*9126SWyllys.Ingersoll@Sun.COM * This Agreement is governed by the laws of the State of New 279*9126SWyllys.Ingersoll@Sun.COM * York and the intellectual property laws of the United 280*9126SWyllys.Ingersoll@Sun.COM * States of America. No party to this Agreement will bring a 281*9126SWyllys.Ingersoll@Sun.COM * legal action under this Agreement more than one year after 282*9126SWyllys.Ingersoll@Sun.COM * the cause of action arose. Each party waives its rights to 283*9126SWyllys.Ingersoll@Sun.COM * a jury trial in any resulting litigation. 284*9126SWyllys.Ingersoll@Sun.COM * 285*9126SWyllys.Ingersoll@Sun.COM * 286*9126SWyllys.Ingersoll@Sun.COM * 287*9126SWyllys.Ingersoll@Sun.COM * (C) COPYRIGHT International Business Machines Corp. 2001, 2002 288*9126SWyllys.Ingersoll@Sun.COM */ 289*9126SWyllys.Ingersoll@Sun.COM /* 290*9126SWyllys.Ingersoll@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 291*9126SWyllys.Ingersoll@Sun.COM * Use is subject to license terms. 292*9126SWyllys.Ingersoll@Sun.COM */ 293*9126SWyllys.Ingersoll@Sun.COM 294*9126SWyllys.Ingersoll@Sun.COM #include <alloca.h> 295*9126SWyllys.Ingersoll@Sun.COM #include <libgen.h> 296*9126SWyllys.Ingersoll@Sun.COM #include <sys/varargs.h> 297*9126SWyllys.Ingersoll@Sun.COM 298*9126SWyllys.Ingersoll@Sun.COM #include "tpmtok_int.h" 299*9126SWyllys.Ingersoll@Sun.COM 300*9126SWyllys.Ingersoll@Sun.COM extern API_Proc_Struct_t *Anchor; 301*9126SWyllys.Ingersoll@Sun.COM extern int logging; 302*9126SWyllys.Ingersoll@Sun.COM 303*9126SWyllys.Ingersoll@Sun.COM void logit(int, char *, ...); 304*9126SWyllys.Ingersoll@Sun.COM static int enabled = 0; 305*9126SWyllys.Ingersoll@Sun.COM 306*9126SWyllys.Ingersoll@Sun.COM void 307*9126SWyllys.Ingersoll@Sun.COM loginit() { 308*9126SWyllys.Ingersoll@Sun.COM if (!enabled) { 309*9126SWyllys.Ingersoll@Sun.COM enabled = 1; 310*9126SWyllys.Ingersoll@Sun.COM openlog("tpmtoken", LOG_PID | LOG_NDELAY, LOG_DAEMON); 311*9126SWyllys.Ingersoll@Sun.COM (void) setlogmask(LOG_UPTO(LOG_DEBUG)); 312*9126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, "Logging enabled %d enabled", enabled); 313*9126SWyllys.Ingersoll@Sun.COM } 314*9126SWyllys.Ingersoll@Sun.COM } 315*9126SWyllys.Ingersoll@Sun.COM 316*9126SWyllys.Ingersoll@Sun.COM void 317*9126SWyllys.Ingersoll@Sun.COM logterm() 318*9126SWyllys.Ingersoll@Sun.COM { 319*9126SWyllys.Ingersoll@Sun.COM enabled = 0; 320*9126SWyllys.Ingersoll@Sun.COM } 321*9126SWyllys.Ingersoll@Sun.COM 322*9126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/ 323*9126SWyllys.Ingersoll@Sun.COM void 324*9126SWyllys.Ingersoll@Sun.COM logit(int type, char *fmt, ...) 325*9126SWyllys.Ingersoll@Sun.COM { 326*9126SWyllys.Ingersoll@Sun.COM #ifdef DEBUG 327*9126SWyllys.Ingersoll@Sun.COM va_list pvar; 328*9126SWyllys.Ingersoll@Sun.COM char buffer[BUFSIZ]; 329*9126SWyllys.Ingersoll@Sun.COM 330*9126SWyllys.Ingersoll@Sun.COM if (enabled) { 331*9126SWyllys.Ingersoll@Sun.COM if (type <= logging) { 332*9126SWyllys.Ingersoll@Sun.COM va_start(pvar, fmt); 333*9126SWyllys.Ingersoll@Sun.COM (void) vsnprintf(buffer, sizeof (buffer), fmt, pvar); 334*9126SWyllys.Ingersoll@Sun.COM va_end(pvar); 335*9126SWyllys.Ingersoll@Sun.COM syslog(type, buffer); 336*9126SWyllys.Ingersoll@Sun.COM } 337*9126SWyllys.Ingersoll@Sun.COM } 338*9126SWyllys.Ingersoll@Sun.COM #else 339*9126SWyllys.Ingersoll@Sun.COM return; 340*9126SWyllys.Ingersoll@Sun.COM #endif /* DEBUG */ 341*9126SWyllys.Ingersoll@Sun.COM 342*9126SWyllys.Ingersoll@Sun.COM } 343*9126SWyllys.Ingersoll@Sun.COM 344*9126SWyllys.Ingersoll@Sun.COM void 345*9126SWyllys.Ingersoll@Sun.COM AddToSessionList(pSess) 346*9126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pSess; 347*9126SWyllys.Ingersoll@Sun.COM { 348*9126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pCur; 349*9126SWyllys.Ingersoll@Sun.COM 350*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->SessListMutex)); 351*9126SWyllys.Ingersoll@Sun.COM 352*9126SWyllys.Ingersoll@Sun.COM pCur = Anchor->SessListBeg; 353*9126SWyllys.Ingersoll@Sun.COM 354*9126SWyllys.Ingersoll@Sun.COM if (! pCur) { 355*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->ProcMutex)); 356*9126SWyllys.Ingersoll@Sun.COM Anchor->SessListBeg = pSess; 357*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->ProcMutex)); 358*9126SWyllys.Ingersoll@Sun.COM pSess->Previous = pSess->Next = NULL; 359*9126SWyllys.Ingersoll@Sun.COM } else { 360*9126SWyllys.Ingersoll@Sun.COM while (pCur->Next != NULL) { 361*9126SWyllys.Ingersoll@Sun.COM pCur = pCur->Next; 362*9126SWyllys.Ingersoll@Sun.COM } 363*9126SWyllys.Ingersoll@Sun.COM pCur->Next = pSess; 364*9126SWyllys.Ingersoll@Sun.COM pSess->Previous = pCur; 365*9126SWyllys.Ingersoll@Sun.COM pSess->Next = NULL; 366*9126SWyllys.Ingersoll@Sun.COM } 367*9126SWyllys.Ingersoll@Sun.COM 368*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->SessListMutex)); 369*9126SWyllys.Ingersoll@Sun.COM } 370*9126SWyllys.Ingersoll@Sun.COM 371*9126SWyllys.Ingersoll@Sun.COM void 372*9126SWyllys.Ingersoll@Sun.COM RemoveFromSessionList(pSess) 373*9126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pSess; 374*9126SWyllys.Ingersoll@Sun.COM { 375*9126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pCur, *pTmp; 376*9126SWyllys.Ingersoll@Sun.COM 377*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->SessListMutex)); 378*9126SWyllys.Ingersoll@Sun.COM 379*9126SWyllys.Ingersoll@Sun.COM pCur = Anchor->SessListBeg; 380*9126SWyllys.Ingersoll@Sun.COM /* 381*9126SWyllys.Ingersoll@Sun.COM * Just in case check that there really is a list although 382*9126SWyllys.Ingersoll@Sun.COM * the call to ValidSession should have caught this already. 383*9126SWyllys.Ingersoll@Sun.COM * But someone may have removed the session already 384*9126SWyllys.Ingersoll@Sun.COM * while we were validating the call. 385*9126SWyllys.Ingersoll@Sun.COM */ 386*9126SWyllys.Ingersoll@Sun.COM if (pCur) { 387*9126SWyllys.Ingersoll@Sun.COM if (pCur == pSess) { 388*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->ProcMutex)); 389*9126SWyllys.Ingersoll@Sun.COM pTmp = pSess->Next; 390*9126SWyllys.Ingersoll@Sun.COM Anchor->SessListBeg = pSess->Next; 391*9126SWyllys.Ingersoll@Sun.COM if (pTmp) { 392*9126SWyllys.Ingersoll@Sun.COM pTmp->Previous = NULL; 393*9126SWyllys.Ingersoll@Sun.COM } 394*9126SWyllys.Ingersoll@Sun.COM free(pSess); 395*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->ProcMutex)); 396*9126SWyllys.Ingersoll@Sun.COM pCur = NULL; 397*9126SWyllys.Ingersoll@Sun.COM } else { 398*9126SWyllys.Ingersoll@Sun.COM /* 399*9126SWyllys.Ingersoll@Sun.COM * First check for a Null element then check 400*9126SWyllys.Ingersoll@Sun.COM * next against the desired element. This will 401*9126SWyllys.Ingersoll@Sun.COM * allow the loop to terminate at the end of 402*9126SWyllys.Ingersoll@Sun.COM * the list even if the desired element is not in 403*9126SWyllys.Ingersoll@Sun.COM * the list (should not happen, but be defensive). 404*9126SWyllys.Ingersoll@Sun.COM */ 405*9126SWyllys.Ingersoll@Sun.COM while (pCur && pCur->Next != pSess) { 406*9126SWyllys.Ingersoll@Sun.COM pCur = pCur->Next; 407*9126SWyllys.Ingersoll@Sun.COM } 408*9126SWyllys.Ingersoll@Sun.COM /* 409*9126SWyllys.Ingersoll@Sun.COM * We did not hit the end of the list without finding 410*9126SWyllys.Ingersoll@Sun.COM * our element so we can continue to remove it 411*9126SWyllys.Ingersoll@Sun.COM */ 412*9126SWyllys.Ingersoll@Sun.COM if (pCur != NULL) { 413*9126SWyllys.Ingersoll@Sun.COM pTmp = pSess->Next; 414*9126SWyllys.Ingersoll@Sun.COM pCur->Next = pTmp; 415*9126SWyllys.Ingersoll@Sun.COM if (pTmp) { 416*9126SWyllys.Ingersoll@Sun.COM pTmp->Previous = pCur; 417*9126SWyllys.Ingersoll@Sun.COM } 418*9126SWyllys.Ingersoll@Sun.COM free(pSess); 419*9126SWyllys.Ingersoll@Sun.COM } 420*9126SWyllys.Ingersoll@Sun.COM } 421*9126SWyllys.Ingersoll@Sun.COM } 422*9126SWyllys.Ingersoll@Sun.COM 423*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->SessListMutex)); 424*9126SWyllys.Ingersoll@Sun.COM } 425*9126SWyllys.Ingersoll@Sun.COM 426*9126SWyllys.Ingersoll@Sun.COM int 427*9126SWyllys.Ingersoll@Sun.COM Valid_Session(Session_Struct_t *pSession, ST_SESSION_T *rSession) 428*9126SWyllys.Ingersoll@Sun.COM { 429*9126SWyllys.Ingersoll@Sun.COM int rv = FALSE; 430*9126SWyllys.Ingersoll@Sun.COM Session_Struct_t *cSessionp; 431*9126SWyllys.Ingersoll@Sun.COM 432*9126SWyllys.Ingersoll@Sun.COM if (! pSession) 433*9126SWyllys.Ingersoll@Sun.COM return (FALSE); 434*9126SWyllys.Ingersoll@Sun.COM 435*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->SessListMutex)); 436*9126SWyllys.Ingersoll@Sun.COM 437*9126SWyllys.Ingersoll@Sun.COM cSessionp = Anchor->SessListBeg; 438*9126SWyllys.Ingersoll@Sun.COM while (cSessionp) { 439*9126SWyllys.Ingersoll@Sun.COM if (cSessionp == pSession) { 440*9126SWyllys.Ingersoll@Sun.COM rv = TRUE; 441*9126SWyllys.Ingersoll@Sun.COM rSession->sessionh = pSession->RealHandle; 442*9126SWyllys.Ingersoll@Sun.COM rSession->slotID = pSession->SltId; 443*9126SWyllys.Ingersoll@Sun.COM break; 444*9126SWyllys.Ingersoll@Sun.COM } 445*9126SWyllys.Ingersoll@Sun.COM cSessionp = (Session_Struct_t *)cSessionp->Next; 446*9126SWyllys.Ingersoll@Sun.COM } 447*9126SWyllys.Ingersoll@Sun.COM 448*9126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->SessListMutex)); 449*9126SWyllys.Ingersoll@Sun.COM return (rv); 450*9126SWyllys.Ingersoll@Sun.COM } 451*9126SWyllys.Ingersoll@Sun.COM 452*9126SWyllys.Ingersoll@Sun.COM int 453*9126SWyllys.Ingersoll@Sun.COM API_Initialized() 454*9126SWyllys.Ingersoll@Sun.COM { 455*9126SWyllys.Ingersoll@Sun.COM return (Anchor != NULL); 456*9126SWyllys.Ingersoll@Sun.COM } 457*9126SWyllys.Ingersoll@Sun.COM 458*9126SWyllys.Ingersoll@Sun.COM void 459*9126SWyllys.Ingersoll@Sun.COM Terminate_All_Process_Sessions() 460*9126SWyllys.Ingersoll@Sun.COM { 461*9126SWyllys.Ingersoll@Sun.COM CK_RV rv; 462*9126SWyllys.Ingersoll@Sun.COM 463*9126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, "Terminate_All_Process_Sessions"); 464*9126SWyllys.Ingersoll@Sun.COM 465*9126SWyllys.Ingersoll@Sun.COM rv = C_CloseAllSessions(TPM_SLOTID); 466*9126SWyllys.Ingersoll@Sun.COM /* 467*9126SWyllys.Ingersoll@Sun.COM * If the return (code is not OK, we are really hosed 468*9126SWyllys.Ingersoll@Sun.COM * since we are terminating the session. 469*9126SWyllys.Ingersoll@Sun.COM * For now we will just log it 470*9126SWyllys.Ingersoll@Sun.COM */ 471*9126SWyllys.Ingersoll@Sun.COM if (rv != CKR_OK) { 472*9126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, 473*9126SWyllys.Ingersoll@Sun.COM "Terminate_All_Process_Sessions RV %x", rv); 474*9126SWyllys.Ingersoll@Sun.COM } 475*9126SWyllys.Ingersoll@Sun.COM } 476