19126SWyllys.Ingersoll@Sun.COM /* 29126SWyllys.Ingersoll@Sun.COM * Common Public License Version 0.5 39126SWyllys.Ingersoll@Sun.COM * 49126SWyllys.Ingersoll@Sun.COM * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF 59126SWyllys.Ingersoll@Sun.COM * THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, 69126SWyllys.Ingersoll@Sun.COM * REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES 79126SWyllys.Ingersoll@Sun.COM * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 89126SWyllys.Ingersoll@Sun.COM * 99126SWyllys.Ingersoll@Sun.COM * 1. DEFINITIONS 109126SWyllys.Ingersoll@Sun.COM * 119126SWyllys.Ingersoll@Sun.COM * "Contribution" means: 129126SWyllys.Ingersoll@Sun.COM * a) in the case of the initial Contributor, the 139126SWyllys.Ingersoll@Sun.COM * initial code and documentation distributed under 149126SWyllys.Ingersoll@Sun.COM * this Agreement, and 159126SWyllys.Ingersoll@Sun.COM * 169126SWyllys.Ingersoll@Sun.COM * b) in the case of each subsequent Contributor: 179126SWyllys.Ingersoll@Sun.COM * i) changes to the Program, and 189126SWyllys.Ingersoll@Sun.COM * ii) additions to the Program; 199126SWyllys.Ingersoll@Sun.COM * 209126SWyllys.Ingersoll@Sun.COM * where such changes and/or additions to the Program 219126SWyllys.Ingersoll@Sun.COM * originate from and are distributed by that 229126SWyllys.Ingersoll@Sun.COM * particular Contributor. A Contribution 'originates' 239126SWyllys.Ingersoll@Sun.COM * from a Contributor if it was added to the Program 249126SWyllys.Ingersoll@Sun.COM * by such Contributor itself or anyone acting on such 259126SWyllys.Ingersoll@Sun.COM * Contributor's behalf. Contributions do not include 269126SWyllys.Ingersoll@Sun.COM * additions to the Program which: (i) are separate 279126SWyllys.Ingersoll@Sun.COM * modules of software distributed in conjunction with 289126SWyllys.Ingersoll@Sun.COM * the Program under their own license agreement, and 299126SWyllys.Ingersoll@Sun.COM * (ii) are not derivative works of the Program. 309126SWyllys.Ingersoll@Sun.COM * 319126SWyllys.Ingersoll@Sun.COM * 329126SWyllys.Ingersoll@Sun.COM * "Contributor" means any person or entity that distributes 339126SWyllys.Ingersoll@Sun.COM * the Program. 349126SWyllys.Ingersoll@Sun.COM * 359126SWyllys.Ingersoll@Sun.COM * "Licensed Patents " mean patent claims licensable by a 369126SWyllys.Ingersoll@Sun.COM * Contributor which are necessarily infringed by the use or 379126SWyllys.Ingersoll@Sun.COM * sale of its Contribution alone or when combined with the 389126SWyllys.Ingersoll@Sun.COM * Program. 399126SWyllys.Ingersoll@Sun.COM * 409126SWyllys.Ingersoll@Sun.COM * "Program" means the Contributions distributed in 419126SWyllys.Ingersoll@Sun.COM * accordance with this Agreement. 429126SWyllys.Ingersoll@Sun.COM * 439126SWyllys.Ingersoll@Sun.COM * "Recipient" means anyone who receives the Program under 449126SWyllys.Ingersoll@Sun.COM * this Agreement, including all Contributors. 459126SWyllys.Ingersoll@Sun.COM * 469126SWyllys.Ingersoll@Sun.COM * 2. GRANT OF RIGHTS 479126SWyllys.Ingersoll@Sun.COM * 489126SWyllys.Ingersoll@Sun.COM * a) Subject to the terms of this Agreement, each 499126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a 509126SWyllys.Ingersoll@Sun.COM * no - exclusive, worldwide, royalt - free copyright 519126SWyllys.Ingersoll@Sun.COM * license to reproduce, prepare derivative works of, 529126SWyllys.Ingersoll@Sun.COM * publicly display, publicly perform, distribute and 539126SWyllys.Ingersoll@Sun.COM * sublicense the Contribution of such Contributor, if 549126SWyllys.Ingersoll@Sun.COM * any, and such derivative works, in source code and 559126SWyllys.Ingersoll@Sun.COM * object code form. 569126SWyllys.Ingersoll@Sun.COM * 579126SWyllys.Ingersoll@Sun.COM * b) Subject to the terms of this Agreement, each 589126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a 599126SWyllys.Ingersoll@Sun.COM * no - exclusive, worldwide, royalt - free patent 609126SWyllys.Ingersoll@Sun.COM * license under Licensed Patents to make, use, sell, 619126SWyllys.Ingersoll@Sun.COM * offer to sell, import and otherwise transfer the 629126SWyllys.Ingersoll@Sun.COM * Contribution of such Contributor, if any, in source 639126SWyllys.Ingersoll@Sun.COM * code and object code form. This patent license 649126SWyllys.Ingersoll@Sun.COM * shall apply to the combination of the Contribution 659126SWyllys.Ingersoll@Sun.COM * and the Program if, at the time the Contribution is 669126SWyllys.Ingersoll@Sun.COM * added by the Contributor, such addition of the 679126SWyllys.Ingersoll@Sun.COM * Contribution causes such combination to be covered 689126SWyllys.Ingersoll@Sun.COM * by the Licensed Patents. The patent license shall 699126SWyllys.Ingersoll@Sun.COM * not apply to any other combinations which include 709126SWyllys.Ingersoll@Sun.COM * the Contribution. No hardware per se is licensed 719126SWyllys.Ingersoll@Sun.COM * hereunder. 729126SWyllys.Ingersoll@Sun.COM * 739126SWyllys.Ingersoll@Sun.COM * c) Recipient understands that although each 749126SWyllys.Ingersoll@Sun.COM * Contributor grants the licenses to its 759126SWyllys.Ingersoll@Sun.COM * Contributions set forth herein, no assurances are 769126SWyllys.Ingersoll@Sun.COM * provided by any Contributor that the Program does 779126SWyllys.Ingersoll@Sun.COM * not infringe the patent or other intellectual 789126SWyllys.Ingersoll@Sun.COM * property rights of any other entity. Each 799126SWyllys.Ingersoll@Sun.COM * Contributor disclaims any liability to Recipient 809126SWyllys.Ingersoll@Sun.COM * for claims brought by any other entity based on 819126SWyllys.Ingersoll@Sun.COM * infringement of intellectual property rights or 829126SWyllys.Ingersoll@Sun.COM * otherwise. As a condition to exercising the rights 839126SWyllys.Ingersoll@Sun.COM * and licenses granted hereunder, each Recipient 849126SWyllys.Ingersoll@Sun.COM * hereby assumes sole responsibility to secure any 859126SWyllys.Ingersoll@Sun.COM * other intellectual property rights needed, if any. 869126SWyllys.Ingersoll@Sun.COM * 879126SWyllys.Ingersoll@Sun.COM * For example, if a third party patent license is 889126SWyllys.Ingersoll@Sun.COM * required to allow Recipient to distribute the 899126SWyllys.Ingersoll@Sun.COM * Program, it is Recipient's responsibility to 909126SWyllys.Ingersoll@Sun.COM * acquire that license before distributing the 919126SWyllys.Ingersoll@Sun.COM * Program. 929126SWyllys.Ingersoll@Sun.COM * 939126SWyllys.Ingersoll@Sun.COM * d) Each Contributor represents that to its 949126SWyllys.Ingersoll@Sun.COM * knowledge it has sufficient copyright rights in its 959126SWyllys.Ingersoll@Sun.COM * Contribution, if any, to grant the copyright 969126SWyllys.Ingersoll@Sun.COM * license set forth in this Agreement. 979126SWyllys.Ingersoll@Sun.COM * 989126SWyllys.Ingersoll@Sun.COM * 3. REQUIREMENTS 999126SWyllys.Ingersoll@Sun.COM * 1009126SWyllys.Ingersoll@Sun.COM * A Contributor may choose to distribute the Program in 1019126SWyllys.Ingersoll@Sun.COM * object code form under its own license agreement, provided 1029126SWyllys.Ingersoll@Sun.COM * that: 1039126SWyllys.Ingersoll@Sun.COM * a) it complies with the terms and conditions of 1049126SWyllys.Ingersoll@Sun.COM * this Agreement; and 1059126SWyllys.Ingersoll@Sun.COM * 1069126SWyllys.Ingersoll@Sun.COM * b) its license agreement: 1079126SWyllys.Ingersoll@Sun.COM * i) effectively disclaims on behalf of all 1089126SWyllys.Ingersoll@Sun.COM * Contributors all warranties and conditions, express 1099126SWyllys.Ingersoll@Sun.COM * and implied, including warranties or conditions of 1109126SWyllys.Ingersoll@Sun.COM * title and no - infringement, and implied warranties 1119126SWyllys.Ingersoll@Sun.COM * or conditions of merchantability and fitness for a 1129126SWyllys.Ingersoll@Sun.COM * particular purpose; 1139126SWyllys.Ingersoll@Sun.COM * 1149126SWyllys.Ingersoll@Sun.COM * ii) effectively excludes on behalf of all 1159126SWyllys.Ingersoll@Sun.COM * Contributors all liability for damages, including 1169126SWyllys.Ingersoll@Sun.COM * direct, indirect, special, incidental and 1179126SWyllys.Ingersoll@Sun.COM * consequential damages, such as lost profits; 1189126SWyllys.Ingersoll@Sun.COM * 1199126SWyllys.Ingersoll@Sun.COM * iii) states that any provisions which differ from 1209126SWyllys.Ingersoll@Sun.COM * this Agreement are offered by that Contributor 1219126SWyllys.Ingersoll@Sun.COM * alone and not by any other party; and 1229126SWyllys.Ingersoll@Sun.COM * 1239126SWyllys.Ingersoll@Sun.COM * iv) states that source code for the Program is 1249126SWyllys.Ingersoll@Sun.COM * available from such Contributor, and informs 1259126SWyllys.Ingersoll@Sun.COM * licensees how to obtain it in a reasonable manner 1269126SWyllys.Ingersoll@Sun.COM * on or through a medium customarily used for 1279126SWyllys.Ingersoll@Sun.COM * software exchange. 1289126SWyllys.Ingersoll@Sun.COM * 1299126SWyllys.Ingersoll@Sun.COM * When the Program is made available in source code form: 1309126SWyllys.Ingersoll@Sun.COM * a) it must be made available under this Agreement; 1319126SWyllys.Ingersoll@Sun.COM * and 1329126SWyllys.Ingersoll@Sun.COM * b) a copy of this Agreement must be included with 1339126SWyllys.Ingersoll@Sun.COM * each copy of the Program. 1349126SWyllys.Ingersoll@Sun.COM * 1359126SWyllys.Ingersoll@Sun.COM * Contributors may not remove or alter any copyright notices 1369126SWyllys.Ingersoll@Sun.COM * contained within the Program. 1379126SWyllys.Ingersoll@Sun.COM * 1389126SWyllys.Ingersoll@Sun.COM * Each Contributor must identify itself as the originator of 1399126SWyllys.Ingersoll@Sun.COM * its Contribution, if any, in a manner that reasonably 1409126SWyllys.Ingersoll@Sun.COM * allows subsequent Recipients to identify the originator of 1419126SWyllys.Ingersoll@Sun.COM * the Contribution. 1429126SWyllys.Ingersoll@Sun.COM * 1439126SWyllys.Ingersoll@Sun.COM * 1449126SWyllys.Ingersoll@Sun.COM * 4. COMMERCIAL DISTRIBUTION 1459126SWyllys.Ingersoll@Sun.COM * 1469126SWyllys.Ingersoll@Sun.COM * Commercial distributors of software may accept certain 1479126SWyllys.Ingersoll@Sun.COM * responsibilities with respect to end users, business 1489126SWyllys.Ingersoll@Sun.COM * partners and the like. While this license is intended to 1499126SWyllys.Ingersoll@Sun.COM * facilitate the commercial use of the Program, the 1509126SWyllys.Ingersoll@Sun.COM * Contributor who includes the Program in a commercial 1519126SWyllys.Ingersoll@Sun.COM * product offering should do so in a manner which does not 1529126SWyllys.Ingersoll@Sun.COM * create potential liability for other Contributors. 1539126SWyllys.Ingersoll@Sun.COM * Therefore, if a Contributor includes the Program in a 1549126SWyllys.Ingersoll@Sun.COM * commercial product offering, such Contributor ("Commercial 1559126SWyllys.Ingersoll@Sun.COM * Contributor") hereby agrees to defend and indemnify every 1569126SWyllys.Ingersoll@Sun.COM * other Contributor ("Indemnified Contributor") against any 1579126SWyllys.Ingersoll@Sun.COM * losses, damages and costs (collectively "Losses") arising 1589126SWyllys.Ingersoll@Sun.COM * from claims, lawsuits and other legal actions brought by a 1599126SWyllys.Ingersoll@Sun.COM * third party against the Indemnified Contributor to the 1609126SWyllys.Ingersoll@Sun.COM * extent caused by the acts or omissions of such Commercial 1619126SWyllys.Ingersoll@Sun.COM * Contributor in connection with its distribution of the 1629126SWyllys.Ingersoll@Sun.COM * Program in a commercial product offering. The obligations 1639126SWyllys.Ingersoll@Sun.COM * in this section do not apply to any claims or Losses 1649126SWyllys.Ingersoll@Sun.COM * relating to any actual or alleged intellectual property 1659126SWyllys.Ingersoll@Sun.COM * infringement. In order to qualify, an Indemnified 1669126SWyllys.Ingersoll@Sun.COM * Contributor must: a) promptly notify the Commercial 1679126SWyllys.Ingersoll@Sun.COM * Contributor in writing of such claim, and b) allow the 1689126SWyllys.Ingersoll@Sun.COM * Commercial Contributor to control, and cooperate with the 1699126SWyllys.Ingersoll@Sun.COM * Commercial Contributor in, the defense and any related 1709126SWyllys.Ingersoll@Sun.COM * settlement negotiations. The Indemnified Contributor may 1719126SWyllys.Ingersoll@Sun.COM * participate in any such claim at its own expense. 1729126SWyllys.Ingersoll@Sun.COM * 1739126SWyllys.Ingersoll@Sun.COM * 1749126SWyllys.Ingersoll@Sun.COM * For example, a Contributor might include the Program in a 1759126SWyllys.Ingersoll@Sun.COM * commercial product offering, Product X. That Contributor 1769126SWyllys.Ingersoll@Sun.COM * is then a Commercial Contributor. If that Commercial 1779126SWyllys.Ingersoll@Sun.COM * Contributor then makes performance claims, or offers 1789126SWyllys.Ingersoll@Sun.COM * warranties related to Product X, those performance claims 1799126SWyllys.Ingersoll@Sun.COM * and warranties are such Commercial Contributor's 1809126SWyllys.Ingersoll@Sun.COM * responsibility alone. Under this section, the Commercial 1819126SWyllys.Ingersoll@Sun.COM * Contributor would have to defend claims against the other 1829126SWyllys.Ingersoll@Sun.COM * Contributors related to those performance claims and 1839126SWyllys.Ingersoll@Sun.COM * warranties, and if a court requires any other Contributor 1849126SWyllys.Ingersoll@Sun.COM * to pay any damages as a result, the Commercial Contributor 1859126SWyllys.Ingersoll@Sun.COM * must pay those damages. 1869126SWyllys.Ingersoll@Sun.COM * 1879126SWyllys.Ingersoll@Sun.COM * 1889126SWyllys.Ingersoll@Sun.COM * 5. NO WARRANTY 1899126SWyllys.Ingersoll@Sun.COM * 1909126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE 1919126SWyllys.Ingersoll@Sun.COM * PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT 1929126SWyllys.Ingersoll@Sun.COM * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 1939126SWyllys.Ingersoll@Sun.COM * IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 1949126SWyllys.Ingersoll@Sun.COM * CONDITIONS OF TITLE, NO - INFRINGEMENT, MERCHANTABILITY OR 1959126SWyllys.Ingersoll@Sun.COM * FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 1969126SWyllys.Ingersoll@Sun.COM * responsible for determining the appropriateness of using 1979126SWyllys.Ingersoll@Sun.COM * and distributing the Program and assumes all risks 1989126SWyllys.Ingersoll@Sun.COM * associated with its exercise of rights under this 1999126SWyllys.Ingersoll@Sun.COM * Agreement, including but not limited to the risks and 2009126SWyllys.Ingersoll@Sun.COM * costs of program errors, compliance with applicable laws, 2019126SWyllys.Ingersoll@Sun.COM * damage to or loss of data, programs or equipment, and 2029126SWyllys.Ingersoll@Sun.COM * unavailability or interruption of operations. 2039126SWyllys.Ingersoll@Sun.COM * 2049126SWyllys.Ingersoll@Sun.COM * 6. DISCLAIMER OF LIABILITY 2059126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER 2069126SWyllys.Ingersoll@Sun.COM * RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY 2079126SWyllys.Ingersoll@Sun.COM * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 2089126SWyllys.Ingersoll@Sun.COM * OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 2099126SWyllys.Ingersoll@Sun.COM * LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF 2109126SWyllys.Ingersoll@Sun.COM * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2119126SWyllys.Ingersoll@Sun.COM * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 2129126SWyllys.Ingersoll@Sun.COM * OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE 2139126SWyllys.Ingersoll@Sun.COM * OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE 2149126SWyllys.Ingersoll@Sun.COM * POSSIBILITY OF SUCH DAMAGES. 2159126SWyllys.Ingersoll@Sun.COM * 2169126SWyllys.Ingersoll@Sun.COM * 7. GENERAL 2179126SWyllys.Ingersoll@Sun.COM * 2189126SWyllys.Ingersoll@Sun.COM * If any provision of this Agreement is invalid or 2199126SWyllys.Ingersoll@Sun.COM * unenforceable under applicable law, it shall not affect 2209126SWyllys.Ingersoll@Sun.COM * the validity or enforceability of the remainder of the 2219126SWyllys.Ingersoll@Sun.COM * terms of this Agreement, and without further action by the 2229126SWyllys.Ingersoll@Sun.COM * parties hereto, such provision shall be reformed to the 2239126SWyllys.Ingersoll@Sun.COM * minimum extent necessary to make such provision valid and 2249126SWyllys.Ingersoll@Sun.COM * enforceable. 2259126SWyllys.Ingersoll@Sun.COM * 2269126SWyllys.Ingersoll@Sun.COM * 2279126SWyllys.Ingersoll@Sun.COM * If Recipient institutes patent litigation against a 2289126SWyllys.Ingersoll@Sun.COM * Contributor with respect to a patent applicable to 2299126SWyllys.Ingersoll@Sun.COM * software (including a cros - claim or counterclaim in a 2309126SWyllys.Ingersoll@Sun.COM * lawsuit), then any patent licenses granted by that 2319126SWyllys.Ingersoll@Sun.COM * Contributor to such Recipient under this Agreement shall 2329126SWyllys.Ingersoll@Sun.COM * terminate as of the date such litigation is filed. In 2339126SWyllys.Ingersoll@Sun.COM * addition, If Recipient institutes patent litigation 2349126SWyllys.Ingersoll@Sun.COM * against any entity (including a cros - claim or 2359126SWyllys.Ingersoll@Sun.COM * counterclaim in a lawsuit) alleging that the Program 2369126SWyllys.Ingersoll@Sun.COM * itself (excluding combinations of the Program with other 2379126SWyllys.Ingersoll@Sun.COM * software or hardware) infringes such Recipient's 2389126SWyllys.Ingersoll@Sun.COM * patent(s), then such Recipient's rights granted under 2399126SWyllys.Ingersoll@Sun.COM * Section 2(b) shall terminate as of the date such 2409126SWyllys.Ingersoll@Sun.COM * litigation is filed. 2419126SWyllys.Ingersoll@Sun.COM * 2429126SWyllys.Ingersoll@Sun.COM * All Recipient's rights under this Agreement shall 2439126SWyllys.Ingersoll@Sun.COM * terminate if it fails to comply with any of the material 2449126SWyllys.Ingersoll@Sun.COM * terms or conditions of this Agreement and does not cure 2459126SWyllys.Ingersoll@Sun.COM * such failure in a reasonable period of time after becoming 2469126SWyllys.Ingersoll@Sun.COM * aware of such noncompliance. If all Recipient's rights 2479126SWyllys.Ingersoll@Sun.COM * under this Agreement terminate, Recipient agrees to cease 2489126SWyllys.Ingersoll@Sun.COM * use and distribution of the Program as soon as reasonably 2499126SWyllys.Ingersoll@Sun.COM * practicable. However, Recipient's obligations under this 2509126SWyllys.Ingersoll@Sun.COM * Agreement and any licenses granted by Recipient relating 2519126SWyllys.Ingersoll@Sun.COM * to the Program shall continue and survive. 2529126SWyllys.Ingersoll@Sun.COM * 2539126SWyllys.Ingersoll@Sun.COM * Everyone is permitted to copy and distribute copies of 2549126SWyllys.Ingersoll@Sun.COM * this Agreement, but in order to avoid inconsistency the 2559126SWyllys.Ingersoll@Sun.COM * Agreement is copyrighted and may only be modified in the 2569126SWyllys.Ingersoll@Sun.COM * following manner. The Agreement Steward reserves the right 2579126SWyllys.Ingersoll@Sun.COM * to publish new versions (including revisions) of this 2589126SWyllys.Ingersoll@Sun.COM * Agreement from time to time. No one other than the 2599126SWyllys.Ingersoll@Sun.COM * Agreement Steward has the right to modify this Agreement. 2609126SWyllys.Ingersoll@Sun.COM * 2619126SWyllys.Ingersoll@Sun.COM * IBM is the initial Agreement Steward. IBM may assign the 2629126SWyllys.Ingersoll@Sun.COM * responsibility to serve as the Agreement Steward to a 2639126SWyllys.Ingersoll@Sun.COM * suitable separate entity. Each new version of the 2649126SWyllys.Ingersoll@Sun.COM * Agreement will be given a distinguishing version number. 2659126SWyllys.Ingersoll@Sun.COM * The Program (including Contributions) may always be 2669126SWyllys.Ingersoll@Sun.COM * distributed subject to the version of the Agreement under 2679126SWyllys.Ingersoll@Sun.COM * which it was received. In addition, after a new version of 2689126SWyllys.Ingersoll@Sun.COM * the Agreement is published, Contributor may elect to 2699126SWyllys.Ingersoll@Sun.COM * distribute the Program (including its Contributions) under 2709126SWyllys.Ingersoll@Sun.COM * the new version. Except as expressly stated in Sections 2719126SWyllys.Ingersoll@Sun.COM * 2(a) and 2(b) above, Recipient receives no rights or 2729126SWyllys.Ingersoll@Sun.COM * licenses to the intellectual property of any Contributor 2739126SWyllys.Ingersoll@Sun.COM * under this Agreement, whether expressly, by implication, 2749126SWyllys.Ingersoll@Sun.COM * estoppel or otherwise. All rights in the Program not 2759126SWyllys.Ingersoll@Sun.COM * expressly granted under this Agreement are reserved. 2769126SWyllys.Ingersoll@Sun.COM * 2779126SWyllys.Ingersoll@Sun.COM * 2789126SWyllys.Ingersoll@Sun.COM * This Agreement is governed by the laws of the State of New 2799126SWyllys.Ingersoll@Sun.COM * York and the intellectual property laws of the United 2809126SWyllys.Ingersoll@Sun.COM * States of America. No party to this Agreement will bring a 2819126SWyllys.Ingersoll@Sun.COM * legal action under this Agreement more than one year after 2829126SWyllys.Ingersoll@Sun.COM * the cause of action arose. Each party waives its rights to 2839126SWyllys.Ingersoll@Sun.COM * a jury trial in any resulting litigation. 2849126SWyllys.Ingersoll@Sun.COM * 2859126SWyllys.Ingersoll@Sun.COM * 2869126SWyllys.Ingersoll@Sun.COM * 2879126SWyllys.Ingersoll@Sun.COM * (C) COPYRIGHT International Business Machines Corp. 2001, 2002 2889126SWyllys.Ingersoll@Sun.COM */ 2899126SWyllys.Ingersoll@Sun.COM /* 2909126SWyllys.Ingersoll@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2919126SWyllys.Ingersoll@Sun.COM * Use is subject to license terms. 2929126SWyllys.Ingersoll@Sun.COM */ 2939126SWyllys.Ingersoll@Sun.COM 2949126SWyllys.Ingersoll@Sun.COM #include <alloca.h> 2959126SWyllys.Ingersoll@Sun.COM #include <libgen.h> 2969126SWyllys.Ingersoll@Sun.COM #include <sys/varargs.h> 2979126SWyllys.Ingersoll@Sun.COM 2989126SWyllys.Ingersoll@Sun.COM #include "tpmtok_int.h" 2999126SWyllys.Ingersoll@Sun.COM 3009126SWyllys.Ingersoll@Sun.COM extern API_Proc_Struct_t *Anchor; 3019126SWyllys.Ingersoll@Sun.COM extern int logging; 3029126SWyllys.Ingersoll@Sun.COM 3039126SWyllys.Ingersoll@Sun.COM void logit(int, char *, ...); 3049126SWyllys.Ingersoll@Sun.COM static int enabled = 0; 3059126SWyllys.Ingersoll@Sun.COM 3069126SWyllys.Ingersoll@Sun.COM void 3079126SWyllys.Ingersoll@Sun.COM loginit() { 3089126SWyllys.Ingersoll@Sun.COM if (!enabled) { 3099126SWyllys.Ingersoll@Sun.COM enabled = 1; 3109126SWyllys.Ingersoll@Sun.COM openlog("tpmtoken", LOG_PID | LOG_NDELAY, LOG_DAEMON); 3119126SWyllys.Ingersoll@Sun.COM (void) setlogmask(LOG_UPTO(LOG_DEBUG)); 3129126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, "Logging enabled %d enabled", enabled); 3139126SWyllys.Ingersoll@Sun.COM } 3149126SWyllys.Ingersoll@Sun.COM } 3159126SWyllys.Ingersoll@Sun.COM 3169126SWyllys.Ingersoll@Sun.COM void 3179126SWyllys.Ingersoll@Sun.COM logterm() 3189126SWyllys.Ingersoll@Sun.COM { 319*9453SWyllys.Ingersoll@Sun.COM closelog(); 3209126SWyllys.Ingersoll@Sun.COM enabled = 0; 3219126SWyllys.Ingersoll@Sun.COM } 3229126SWyllys.Ingersoll@Sun.COM 3239126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/ 3249126SWyllys.Ingersoll@Sun.COM void 3259126SWyllys.Ingersoll@Sun.COM logit(int type, char *fmt, ...) 3269126SWyllys.Ingersoll@Sun.COM { 3279126SWyllys.Ingersoll@Sun.COM #ifdef DEBUG 3289126SWyllys.Ingersoll@Sun.COM va_list pvar; 3299126SWyllys.Ingersoll@Sun.COM char buffer[BUFSIZ]; 3309126SWyllys.Ingersoll@Sun.COM 3319126SWyllys.Ingersoll@Sun.COM if (enabled) { 3329126SWyllys.Ingersoll@Sun.COM if (type <= logging) { 3339126SWyllys.Ingersoll@Sun.COM va_start(pvar, fmt); 3349126SWyllys.Ingersoll@Sun.COM (void) vsnprintf(buffer, sizeof (buffer), fmt, pvar); 3359126SWyllys.Ingersoll@Sun.COM va_end(pvar); 3369126SWyllys.Ingersoll@Sun.COM syslog(type, buffer); 3379126SWyllys.Ingersoll@Sun.COM } 3389126SWyllys.Ingersoll@Sun.COM } 3399126SWyllys.Ingersoll@Sun.COM #else 3409126SWyllys.Ingersoll@Sun.COM return; 3419126SWyllys.Ingersoll@Sun.COM #endif /* DEBUG */ 3429126SWyllys.Ingersoll@Sun.COM 3439126SWyllys.Ingersoll@Sun.COM } 3449126SWyllys.Ingersoll@Sun.COM 3459126SWyllys.Ingersoll@Sun.COM void 3469126SWyllys.Ingersoll@Sun.COM AddToSessionList(pSess) 3479126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pSess; 3489126SWyllys.Ingersoll@Sun.COM { 3499126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pCur; 3509126SWyllys.Ingersoll@Sun.COM 3519126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->SessListMutex)); 3529126SWyllys.Ingersoll@Sun.COM 3539126SWyllys.Ingersoll@Sun.COM pCur = Anchor->SessListBeg; 3549126SWyllys.Ingersoll@Sun.COM 3559126SWyllys.Ingersoll@Sun.COM if (! pCur) { 3569126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->ProcMutex)); 3579126SWyllys.Ingersoll@Sun.COM Anchor->SessListBeg = pSess; 3589126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->ProcMutex)); 3599126SWyllys.Ingersoll@Sun.COM pSess->Previous = pSess->Next = NULL; 3609126SWyllys.Ingersoll@Sun.COM } else { 3619126SWyllys.Ingersoll@Sun.COM while (pCur->Next != NULL) { 3629126SWyllys.Ingersoll@Sun.COM pCur = pCur->Next; 3639126SWyllys.Ingersoll@Sun.COM } 3649126SWyllys.Ingersoll@Sun.COM pCur->Next = pSess; 3659126SWyllys.Ingersoll@Sun.COM pSess->Previous = pCur; 3669126SWyllys.Ingersoll@Sun.COM pSess->Next = NULL; 3679126SWyllys.Ingersoll@Sun.COM } 3689126SWyllys.Ingersoll@Sun.COM 3699126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->SessListMutex)); 3709126SWyllys.Ingersoll@Sun.COM } 3719126SWyllys.Ingersoll@Sun.COM 3729126SWyllys.Ingersoll@Sun.COM void 3739126SWyllys.Ingersoll@Sun.COM RemoveFromSessionList(pSess) 3749126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pSess; 3759126SWyllys.Ingersoll@Sun.COM { 3769126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pCur, *pTmp; 3779126SWyllys.Ingersoll@Sun.COM 3789126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->SessListMutex)); 3799126SWyllys.Ingersoll@Sun.COM 3809126SWyllys.Ingersoll@Sun.COM pCur = Anchor->SessListBeg; 3819126SWyllys.Ingersoll@Sun.COM /* 3829126SWyllys.Ingersoll@Sun.COM * Just in case check that there really is a list although 3839126SWyllys.Ingersoll@Sun.COM * the call to ValidSession should have caught this already. 3849126SWyllys.Ingersoll@Sun.COM * But someone may have removed the session already 3859126SWyllys.Ingersoll@Sun.COM * while we were validating the call. 3869126SWyllys.Ingersoll@Sun.COM */ 3879126SWyllys.Ingersoll@Sun.COM if (pCur) { 3889126SWyllys.Ingersoll@Sun.COM if (pCur == pSess) { 3899126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->ProcMutex)); 3909126SWyllys.Ingersoll@Sun.COM pTmp = pSess->Next; 3919126SWyllys.Ingersoll@Sun.COM Anchor->SessListBeg = pSess->Next; 3929126SWyllys.Ingersoll@Sun.COM if (pTmp) { 3939126SWyllys.Ingersoll@Sun.COM pTmp->Previous = NULL; 3949126SWyllys.Ingersoll@Sun.COM } 3959126SWyllys.Ingersoll@Sun.COM free(pSess); 3969126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->ProcMutex)); 3979126SWyllys.Ingersoll@Sun.COM pCur = NULL; 3989126SWyllys.Ingersoll@Sun.COM } else { 3999126SWyllys.Ingersoll@Sun.COM /* 4009126SWyllys.Ingersoll@Sun.COM * First check for a Null element then check 4019126SWyllys.Ingersoll@Sun.COM * next against the desired element. This will 4029126SWyllys.Ingersoll@Sun.COM * allow the loop to terminate at the end of 4039126SWyllys.Ingersoll@Sun.COM * the list even if the desired element is not in 4049126SWyllys.Ingersoll@Sun.COM * the list (should not happen, but be defensive). 4059126SWyllys.Ingersoll@Sun.COM */ 4069126SWyllys.Ingersoll@Sun.COM while (pCur && pCur->Next != pSess) { 4079126SWyllys.Ingersoll@Sun.COM pCur = pCur->Next; 4089126SWyllys.Ingersoll@Sun.COM } 4099126SWyllys.Ingersoll@Sun.COM /* 4109126SWyllys.Ingersoll@Sun.COM * We did not hit the end of the list without finding 4119126SWyllys.Ingersoll@Sun.COM * our element so we can continue to remove it 4129126SWyllys.Ingersoll@Sun.COM */ 4139126SWyllys.Ingersoll@Sun.COM if (pCur != NULL) { 4149126SWyllys.Ingersoll@Sun.COM pTmp = pSess->Next; 4159126SWyllys.Ingersoll@Sun.COM pCur->Next = pTmp; 4169126SWyllys.Ingersoll@Sun.COM if (pTmp) { 4179126SWyllys.Ingersoll@Sun.COM pTmp->Previous = pCur; 4189126SWyllys.Ingersoll@Sun.COM } 4199126SWyllys.Ingersoll@Sun.COM free(pSess); 4209126SWyllys.Ingersoll@Sun.COM } 4219126SWyllys.Ingersoll@Sun.COM } 4229126SWyllys.Ingersoll@Sun.COM } 4239126SWyllys.Ingersoll@Sun.COM 4249126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->SessListMutex)); 4259126SWyllys.Ingersoll@Sun.COM } 4269126SWyllys.Ingersoll@Sun.COM 4279126SWyllys.Ingersoll@Sun.COM int 4289126SWyllys.Ingersoll@Sun.COM Valid_Session(Session_Struct_t *pSession, ST_SESSION_T *rSession) 4299126SWyllys.Ingersoll@Sun.COM { 4309126SWyllys.Ingersoll@Sun.COM int rv = FALSE; 4319126SWyllys.Ingersoll@Sun.COM Session_Struct_t *cSessionp; 4329126SWyllys.Ingersoll@Sun.COM 433*9453SWyllys.Ingersoll@Sun.COM if (!pSession) 434*9453SWyllys.Ingersoll@Sun.COM return (FALSE); 4359126SWyllys.Ingersoll@Sun.COM 4369126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&(Anchor->SessListMutex)); 4379126SWyllys.Ingersoll@Sun.COM 4389126SWyllys.Ingersoll@Sun.COM cSessionp = Anchor->SessListBeg; 4399126SWyllys.Ingersoll@Sun.COM while (cSessionp) { 4409126SWyllys.Ingersoll@Sun.COM if (cSessionp == pSession) { 4419126SWyllys.Ingersoll@Sun.COM rv = TRUE; 4429126SWyllys.Ingersoll@Sun.COM rSession->sessionh = pSession->RealHandle; 4439126SWyllys.Ingersoll@Sun.COM rSession->slotID = pSession->SltId; 4449126SWyllys.Ingersoll@Sun.COM break; 4459126SWyllys.Ingersoll@Sun.COM } 4469126SWyllys.Ingersoll@Sun.COM cSessionp = (Session_Struct_t *)cSessionp->Next; 4479126SWyllys.Ingersoll@Sun.COM } 4489126SWyllys.Ingersoll@Sun.COM 4499126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&(Anchor->SessListMutex)); 4509126SWyllys.Ingersoll@Sun.COM return (rv); 4519126SWyllys.Ingersoll@Sun.COM } 4529126SWyllys.Ingersoll@Sun.COM 4539126SWyllys.Ingersoll@Sun.COM int 4549126SWyllys.Ingersoll@Sun.COM API_Initialized() 4559126SWyllys.Ingersoll@Sun.COM { 4569126SWyllys.Ingersoll@Sun.COM return (Anchor != NULL); 4579126SWyllys.Ingersoll@Sun.COM } 4589126SWyllys.Ingersoll@Sun.COM 4599126SWyllys.Ingersoll@Sun.COM void 4609126SWyllys.Ingersoll@Sun.COM Terminate_All_Process_Sessions() 4619126SWyllys.Ingersoll@Sun.COM { 4629126SWyllys.Ingersoll@Sun.COM CK_RV rv; 4639126SWyllys.Ingersoll@Sun.COM 4649126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, "Terminate_All_Process_Sessions"); 4659126SWyllys.Ingersoll@Sun.COM 4669126SWyllys.Ingersoll@Sun.COM rv = C_CloseAllSessions(TPM_SLOTID); 4679126SWyllys.Ingersoll@Sun.COM /* 4689126SWyllys.Ingersoll@Sun.COM * If the return (code is not OK, we are really hosed 4699126SWyllys.Ingersoll@Sun.COM * since we are terminating the session. 4709126SWyllys.Ingersoll@Sun.COM * For now we will just log it 4719126SWyllys.Ingersoll@Sun.COM */ 4729126SWyllys.Ingersoll@Sun.COM if (rv != CKR_OK) { 4739126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, 4749126SWyllys.Ingersoll@Sun.COM "Terminate_All_Process_Sessions RV %x", rv); 4759126SWyllys.Ingersoll@Sun.COM } 4769126SWyllys.Ingersoll@Sun.COM } 477