├── .travis.yml ├── terminal.go ├── LICENSE.txt ├── README.md ├── pass.go ├── pass_test.go └── OPENSOLARIS.LICENSE /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | go: 8 | - 1.3 9 | - 1.4 10 | - 1.5 11 | - tip 12 | -------------------------------------------------------------------------------- /terminal.go: -------------------------------------------------------------------------------- 1 | package gopass 2 | 3 | import "github.com/golang/crypto/ssh/terminal" 4 | 5 | type terminalState struct { 6 | state *terminal.State 7 | } 8 | 9 | func isTerminal(fd uintptr) bool { 10 | return terminal.IsTerminal(int(fd)) 11 | } 12 | 13 | func makeRaw(fd uintptr) (*terminalState, error) { 14 | state, err := terminal.MakeRaw(int(fd)) 15 | 16 | return &terminalState{ 17 | state: state, 18 | }, err 19 | } 20 | 21 | func restore(fd uintptr, oldState *terminalState) error { 22 | return terminal.Restore(int(fd), oldState.state) 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012 Chris Howey 4 | 5 | Permission to use, copy, modify, and distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # getpasswd in Go [![GoDoc](https://godoc.org/github.com/howeyc/gopass?status.svg)](https://godoc.org/github.com/howeyc/gopass) [![Build Status](https://secure.travis-ci.org/howeyc/gopass.png?branch=master)](http://travis-ci.org/howeyc/gopass) 2 | 3 | Retrieve password from user terminal or piped input without echo. 4 | 5 | Verified on BSD, Linux, and Windows. 6 | 7 | Example: 8 | ```go 9 | package main 10 | 11 | import "fmt" 12 | import "github.com/howeyc/gopass" 13 | 14 | func main() { 15 | fmt.Printf("Password: ") 16 | 17 | // Silent. For printing *'s use gopass.GetPasswdMasked() 18 | pass, err := gopass.GetPasswd() 19 | if err != nil { 20 | // Handle gopass.ErrInterrupted or getch() read error 21 | } 22 | 23 | // Do something with pass 24 | } 25 | ``` 26 | 27 | Caution: Multi-byte characters not supported! 28 | -------------------------------------------------------------------------------- /pass.go: -------------------------------------------------------------------------------- 1 | package gopass 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "io" 7 | "os" 8 | ) 9 | 10 | type FdReader interface { 11 | io.Reader 12 | Fd() uintptr 13 | } 14 | 15 | var defaultGetCh = func(r io.Reader) (byte, error) { 16 | buf := make([]byte, 1) 17 | if n, err := r.Read(buf); n == 0 || err != nil { 18 | if err != nil { 19 | return 0, err 20 | } 21 | return 0, io.EOF 22 | } 23 | return buf[0], nil 24 | } 25 | 26 | var ( 27 | maxLength = 512 28 | ErrInterrupted = errors.New("interrupted") 29 | ErrMaxLengthExceeded = fmt.Errorf("maximum byte limit (%v) exceeded", maxLength) 30 | 31 | // Provide variable so that tests can provide a mock implementation. 32 | getch = defaultGetCh 33 | ) 34 | 35 | // getPasswd returns the input read from terminal. 36 | // If prompt is not empty, it will be output as a prompt to the user 37 | // If masked is true, typing will be matched by asterisks on the screen. 38 | // Otherwise, typing will echo nothing. 39 | func getPasswd(prompt string, masked bool, r FdReader, w io.Writer) ([]byte, error) { 40 | var err error 41 | var pass, bs, mask []byte 42 | if masked { 43 | bs = []byte("\b \b") 44 | mask = []byte("*") 45 | } 46 | 47 | if isTerminal(r.Fd()) { 48 | if oldState, err := makeRaw(r.Fd()); err != nil { 49 | return pass, err 50 | } else { 51 | defer func() { 52 | restore(r.Fd(), oldState) 53 | fmt.Fprintln(w) 54 | }() 55 | } 56 | } 57 | 58 | if prompt != "" { 59 | fmt.Fprint(w, prompt) 60 | } 61 | 62 | // Track total bytes read, not just bytes in the password. This ensures any 63 | // errors that might flood the console with nil or -1 bytes infinitely are 64 | // capped. 65 | var counter int 66 | for counter = 0; counter <= maxLength; counter++ { 67 | if v, e := getch(r); e != nil { 68 | err = e 69 | break 70 | } else if v == 127 || v == 8 { 71 | if l := len(pass); l > 0 { 72 | pass = pass[:l-1] 73 | fmt.Fprint(w, string(bs)) 74 | } 75 | } else if v == 13 || v == 10 { 76 | break 77 | } else if v == 3 { 78 | err = ErrInterrupted 79 | break 80 | } else if v != 0 { 81 | pass = append(pass, v) 82 | fmt.Fprint(w, string(mask)) 83 | } 84 | } 85 | 86 | if counter > maxLength { 87 | err = ErrMaxLengthExceeded 88 | } 89 | 90 | return pass, err 91 | } 92 | 93 | // GetPasswd returns the password read from the terminal without echoing input. 94 | // The returned byte array does not include end-of-line characters. 95 | func GetPasswd() ([]byte, error) { 96 | return getPasswd("", false, os.Stdin, os.Stdout) 97 | } 98 | 99 | // GetPasswdMasked returns the password read from the terminal, echoing asterisks. 100 | // The returned byte array does not include end-of-line characters. 101 | func GetPasswdMasked() ([]byte, error) { 102 | return getPasswd("", true, os.Stdin, os.Stdout) 103 | } 104 | 105 | // GetPasswdPrompt prompts the user and returns the password read from the terminal. 106 | // If mask is true, then asterisks are echoed. 107 | // The returned byte array does not include end-of-line characters. 108 | func GetPasswdPrompt(prompt string, mask bool, r FdReader, w io.Writer) ([]byte, error) { 109 | return getPasswd(prompt, mask, r, w) 110 | } 111 | -------------------------------------------------------------------------------- /pass_test.go: -------------------------------------------------------------------------------- 1 | package gopass 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "fmt" 7 | "io" 8 | "io/ioutil" 9 | "os" 10 | "testing" 11 | "time" 12 | ) 13 | 14 | // TestGetPasswd tests the password creation and output based on a byte buffer 15 | // as input to mock the underlying getch() methods. 16 | func TestGetPasswd(t *testing.T) { 17 | type testData struct { 18 | input []byte 19 | 20 | // Due to how backspaces are written, it is easier to manually write 21 | // each expected output for the masked cases. 22 | masked string 23 | password string 24 | byesLeft int 25 | reason string 26 | } 27 | 28 | ds := []testData{ 29 | testData{[]byte("abc\n"), "***", "abc", 0, "Password parsing should stop at \\n"}, 30 | testData{[]byte("abc\r"), "***", "abc", 0, "Password parsing should stop at \\r"}, 31 | testData{[]byte("a\nbc\n"), "*", "a", 3, "Password parsing should stop at \\n"}, 32 | testData{[]byte("*!]|\n"), "****", "*!]|", 0, "Special characters shouldn't affect the password."}, 33 | 34 | testData{[]byte("abc\r\n"), "***", "abc", 1, 35 | "Password parsing should stop at \\r; Windows LINE_MODE should be unset so \\r is not converted to \\r\\n."}, 36 | 37 | testData{[]byte{'a', 'b', 'c', 8, '\n'}, "***\b \b", "ab", 0, "Backspace byte should remove the last read byte."}, 38 | testData{[]byte{'a', 'b', 127, 'c', '\n'}, "**\b \b*", "ac", 0, "Delete byte should remove the last read byte."}, 39 | testData{[]byte{'a', 'b', 127, 'c', 8, 127, '\n'}, "**\b \b*\b \b\b \b", "", 0, "Successive deletes continue to delete."}, 40 | testData{[]byte{8, 8, 8, '\n'}, "", "", 0, "Deletes before characters are noops."}, 41 | testData{[]byte{8, 8, 8, 'a', 'b', 'c', '\n'}, "***", "abc", 0, "Deletes before characters are noops."}, 42 | 43 | testData{[]byte{'a', 'b', 0, 'c', '\n'}, "***", "abc", 0, 44 | "Nil byte should be ignored due; may get unintended nil bytes from syscalls on Windows."}, 45 | } 46 | 47 | // Redirecting output for tests as they print to os.Stdout but we want to 48 | // capture and test the output. 49 | for _, masked := range []bool{true, false} { 50 | for _, d := range ds { 51 | pipeBytesToStdin(d.input) 52 | 53 | r, w, err := os.Pipe() 54 | if err != nil { 55 | t.Fatal(err.Error()) 56 | } 57 | 58 | result, err := getPasswd("", masked, os.Stdin, w) 59 | if err != nil { 60 | t.Errorf("Error getting password: %s", err.Error()) 61 | } 62 | leftOnBuffer := flushStdin() 63 | 64 | // Test output (masked and unmasked). Delete/backspace actually 65 | // deletes, overwrites and deletes again. As a result, we need to 66 | // remove those from the pipe afterwards to mimic the console's 67 | // interpretation of those bytes. 68 | w.Close() 69 | output, err := ioutil.ReadAll(r) 70 | if err != nil { 71 | t.Fatal(err.Error()) 72 | } 73 | var expectedOutput []byte 74 | if masked { 75 | expectedOutput = []byte(d.masked) 76 | } else { 77 | expectedOutput = []byte("") 78 | } 79 | if bytes.Compare(expectedOutput, output) != 0 { 80 | t.Errorf("Expected output to equal %v (%q) but got %v (%q) instead when masked=%v. %s", expectedOutput, string(expectedOutput), output, string(output), masked, d.reason) 81 | } 82 | 83 | if string(result) != d.password { 84 | t.Errorf("Expected %q but got %q instead when masked=%v. %s", d.password, result, masked, d.reason) 85 | } 86 | 87 | if leftOnBuffer != d.byesLeft { 88 | t.Errorf("Expected %v bytes left on buffer but instead got %v when masked=%v. %s", d.byesLeft, leftOnBuffer, masked, d.reason) 89 | } 90 | } 91 | } 92 | } 93 | 94 | // TestPipe ensures we get our expected pipe behavior. 95 | func TestPipe(t *testing.T) { 96 | type testData struct { 97 | input string 98 | password string 99 | expError error 100 | } 101 | ds := []testData{ 102 | testData{"abc", "abc", io.EOF}, 103 | testData{"abc\n", "abc", nil}, 104 | testData{"abc\r", "abc", nil}, 105 | testData{"abc\r\n", "abc", nil}, 106 | } 107 | 108 | for _, d := range ds { 109 | _, err := pipeToStdin(d.input) 110 | if err != nil { 111 | t.Log("Error writing input to stdin:", err) 112 | t.FailNow() 113 | } 114 | pass, err := GetPasswd() 115 | if string(pass) != d.password { 116 | t.Errorf("Expected %q but got %q instead.", d.password, string(pass)) 117 | } 118 | if err != d.expError { 119 | t.Errorf("Expected %v but got %q instead.", d.expError, err) 120 | } 121 | } 122 | } 123 | 124 | // flushStdin reads from stdin for .5 seconds to ensure no bytes are left on 125 | // the buffer. Returns the number of bytes read. 126 | func flushStdin() int { 127 | ch := make(chan byte) 128 | go func(ch chan byte) { 129 | reader := bufio.NewReader(os.Stdin) 130 | for { 131 | b, err := reader.ReadByte() 132 | if err != nil { // Maybe log non io.EOF errors, if you want 133 | close(ch) 134 | return 135 | } 136 | ch <- b 137 | } 138 | close(ch) 139 | }(ch) 140 | 141 | numBytes := 0 142 | for { 143 | select { 144 | case _, ok := <-ch: 145 | if !ok { 146 | return numBytes 147 | } 148 | numBytes++ 149 | case <-time.After(500 * time.Millisecond): 150 | return numBytes 151 | } 152 | } 153 | return numBytes 154 | } 155 | 156 | // pipeToStdin pipes the given string onto os.Stdin by replacing it with an 157 | // os.Pipe. The write end of the pipe is closed so that EOF is read after the 158 | // final byte. 159 | func pipeToStdin(s string) (int, error) { 160 | pipeReader, pipeWriter, err := os.Pipe() 161 | if err != nil { 162 | fmt.Println("Error getting os pipes:", err) 163 | os.Exit(1) 164 | } 165 | os.Stdin = pipeReader 166 | w, err := pipeWriter.WriteString(s) 167 | pipeWriter.Close() 168 | return w, err 169 | } 170 | 171 | func pipeBytesToStdin(b []byte) (int, error) { 172 | return pipeToStdin(string(b)) 173 | } 174 | 175 | // TestGetPasswd_Err tests errors are properly handled from getch() 176 | func TestGetPasswd_Err(t *testing.T) { 177 | var inBuffer *bytes.Buffer 178 | getch = func(io.Reader) (byte, error) { 179 | b, err := inBuffer.ReadByte() 180 | if err != nil { 181 | return 13, err 182 | } 183 | if b == 'z' { 184 | return 'z', fmt.Errorf("Forced error; byte returned should not be considered accurate.") 185 | } 186 | return b, nil 187 | } 188 | defer func() { getch = defaultGetCh }() 189 | 190 | for input, expectedPassword := range map[string]string{"abc": "abc", "abzc": "ab"} { 191 | inBuffer = bytes.NewBufferString(input) 192 | p, err := GetPasswdMasked() 193 | if string(p) != expectedPassword { 194 | t.Errorf("Expected %q but got %q instead.", expectedPassword, p) 195 | } 196 | if err == nil { 197 | t.Errorf("Expected error to be returned.") 198 | } 199 | } 200 | } 201 | 202 | func TestMaxPasswordLength(t *testing.T) { 203 | type testData struct { 204 | input []byte 205 | expectedErr error 206 | 207 | // Helper field to output in case of failure; rather than hundreds of 208 | // bytes. 209 | inputDesc string 210 | } 211 | 212 | ds := []testData{ 213 | testData{append(bytes.Repeat([]byte{'a'}, maxLength), '\n'), nil, fmt.Sprintf("%v 'a' bytes followed by a newline", maxLength)}, 214 | testData{append(bytes.Repeat([]byte{'a'}, maxLength+1), '\n'), ErrMaxLengthExceeded, fmt.Sprintf("%v 'a' bytes followed by a newline", maxLength+1)}, 215 | testData{append(bytes.Repeat([]byte{0x00}, maxLength+1), '\n'), ErrMaxLengthExceeded, fmt.Sprintf("%v 0x00 bytes followed by a newline", maxLength+1)}, 216 | } 217 | 218 | for _, d := range ds { 219 | pipeBytesToStdin(d.input) 220 | _, err := GetPasswd() 221 | if err != d.expectedErr { 222 | t.Errorf("Expected error to be %v; isntead got %v from %v", d.expectedErr, err, d.inputDesc) 223 | } 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /OPENSOLARIS.LICENSE: -------------------------------------------------------------------------------- 1 | Unless otherwise noted, all files in this distribution are released 2 | under the Common Development and Distribution License (CDDL). 3 | Exceptions are noted within the associated source files. 4 | 5 | -------------------------------------------------------------------- 6 | 7 | 8 | COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0 9 | 10 | 1. Definitions. 11 | 12 | 1.1. "Contributor" means each individual or entity that creates 13 | or contributes to the creation of Modifications. 14 | 15 | 1.2. "Contributor Version" means the combination of the Original 16 | Software, prior Modifications used by a Contributor (if any), 17 | and the Modifications made by that particular Contributor. 18 | 19 | 1.3. "Covered Software" means (a) the Original Software, or (b) 20 | Modifications, or (c) the combination of files containing 21 | Original Software with files containing Modifications, in 22 | each case including portions thereof. 23 | 24 | 1.4. "Executable" means the Covered Software in any form other 25 | than Source Code. 26 | 27 | 1.5. "Initial Developer" means the individual or entity that first 28 | makes Original Software available under this License. 29 | 30 | 1.6. "Larger Work" means a work which combines Covered Software or 31 | portions thereof with code not governed by the terms of this 32 | License. 33 | 34 | 1.7. "License" means this document. 35 | 36 | 1.8. "Licensable" means having the right to grant, to the maximum 37 | extent possible, whether at the time of the initial grant or 38 | subsequently acquired, any and all of the rights conveyed 39 | herein. 40 | 41 | 1.9. "Modifications" means the Source Code and Executable form of 42 | any of the following: 43 | 44 | A. Any file that results from an addition to, deletion from or 45 | modification of the contents of a file containing Original 46 | Software or previous Modifications; 47 | 48 | B. Any new file that contains any part of the Original 49 | Software or previous Modifications; or 50 | 51 | C. Any new file that is contributed or otherwise made 52 | available under the terms of this License. 53 | 54 | 1.10. "Original Software" means the Source Code and Executable 55 | form of computer software code that is originally released 56 | under this License. 57 | 58 | 1.11. "Patent Claims" means any patent claim(s), now owned or 59 | hereafter acquired, including without limitation, method, 60 | process, and apparatus claims, in any patent Licensable by 61 | grantor. 62 | 63 | 1.12. "Source Code" means (a) the common form of computer software 64 | code in which modifications are made and (b) associated 65 | documentation included in or with such code. 66 | 67 | 1.13. "You" (or "Your") means an individual or a legal entity 68 | exercising rights under, and complying with all of the terms 69 | of, this License. For legal entities, "You" includes any 70 | entity which controls, is controlled by, or is under common 71 | control with You. For purposes of this definition, 72 | "control" means (a) the power, direct or indirect, to cause 73 | the direction or management of such entity, whether by 74 | contract or otherwise, or (b) ownership of more than fifty 75 | percent (50%) of the outstanding shares or beneficial 76 | ownership of such entity. 77 | 78 | 2. License Grants. 79 | 80 | 2.1. The Initial Developer Grant. 81 | 82 | Conditioned upon Your compliance with Section 3.1 below and 83 | subject to third party intellectual property claims, the Initial 84 | Developer hereby grants You a world-wide, royalty-free, 85 | non-exclusive license: 86 | 87 | (a) under intellectual property rights (other than patent or 88 | trademark) Licensable by Initial Developer, to use, 89 | reproduce, modify, display, perform, sublicense and 90 | distribute the Original Software (or portions thereof), 91 | with or without Modifications, and/or as part of a Larger 92 | Work; and 93 | 94 | (b) under Patent Claims infringed by the making, using or 95 | selling of Original Software, to make, have made, use, 96 | practice, sell, and offer for sale, and/or otherwise 97 | dispose of the Original Software (or portions thereof). 98 | 99 | (c) The licenses granted in Sections 2.1(a) and (b) are 100 | effective on the date Initial Developer first distributes 101 | or otherwise makes the Original Software available to a 102 | third party under the terms of this License. 103 | 104 | (d) Notwithstanding Section 2.1(b) above, no patent license is 105 | granted: (1) for code that You delete from the Original 106 | Software, or (2) for infringements caused by: (i) the 107 | modification of the Original Software, or (ii) the 108 | combination of the Original Software with other software 109 | or devices. 110 | 111 | 2.2. Contributor Grant. 112 | 113 | Conditioned upon Your compliance with Section 3.1 below and 114 | subject to third party intellectual property claims, each 115 | Contributor hereby grants You a world-wide, royalty-free, 116 | non-exclusive license: 117 | 118 | (a) under intellectual property rights (other than patent or 119 | trademark) Licensable by Contributor to use, reproduce, 120 | modify, display, perform, sublicense and distribute the 121 | Modifications created by such Contributor (or portions 122 | thereof), either on an unmodified basis, with other 123 | Modifications, as Covered Software and/or as part of a 124 | Larger Work; and 125 | 126 | (b) under Patent Claims infringed by the making, using, or 127 | selling of Modifications made by that Contributor either 128 | alone and/or in combination with its Contributor Version 129 | (or portions of such combination), to make, use, sell, 130 | offer for sale, have made, and/or otherwise dispose of: 131 | (1) Modifications made by that Contributor (or portions 132 | thereof); and (2) the combination of Modifications made by 133 | that Contributor with its Contributor Version (or portions 134 | of such combination). 135 | 136 | (c) The licenses granted in Sections 2.2(a) and 2.2(b) are 137 | effective on the date Contributor first distributes or 138 | otherwise makes the Modifications available to a third 139 | party. 140 | 141 | (d) Notwithstanding Section 2.2(b) above, no patent license is 142 | granted: (1) for any code that Contributor has deleted 143 | from the Contributor Version; (2) for infringements caused 144 | by: (i) third party modifications of Contributor Version, 145 | or (ii) the combination of Modifications made by that 146 | Contributor with other software (except as part of the 147 | Contributor Version) or other devices; or (3) under Patent 148 | Claims infringed by Covered Software in the absence of 149 | Modifications made by that Contributor. 150 | 151 | 3. Distribution Obligations. 152 | 153 | 3.1. Availability of Source Code. 154 | 155 | Any Covered Software that You distribute or otherwise make 156 | available in Executable form must also be made available in Source 157 | Code form and that Source Code form must be distributed only under 158 | the terms of this License. You must include a copy of this 159 | License with every copy of the Source Code form of the Covered 160 | Software You distribute or otherwise make available. You must 161 | inform recipients of any such Covered Software in Executable form 162 | as to how they can obtain such Covered Software in Source Code 163 | form in a reasonable manner on or through a medium customarily 164 | used for software exchange. 165 | 166 | 3.2. Modifications. 167 | 168 | The Modifications that You create or to which You contribute are 169 | governed by the terms of this License. You represent that You 170 | believe Your Modifications are Your original creation(s) and/or 171 | You have sufficient rights to grant the rights conveyed by this 172 | License. 173 | 174 | 3.3. Required Notices. 175 | 176 | You must include a notice in each of Your Modifications that 177 | identifies You as the Contributor of the Modification. You may 178 | not remove or alter any copyright, patent or trademark notices 179 | contained within the Covered Software, or any notices of licensing 180 | or any descriptive text giving attribution to any Contributor or 181 | the Initial Developer. 182 | 183 | 3.4. Application of Additional Terms. 184 | 185 | You may not offer or impose any terms on any Covered Software in 186 | Source Code form that alters or restricts the applicable version 187 | of this License or the recipients' rights hereunder. You may 188 | choose to offer, and to charge a fee for, warranty, support, 189 | indemnity or liability obligations to one or more recipients of 190 | Covered Software. However, you may do so only on Your own behalf, 191 | and not on behalf of the Initial Developer or any Contributor. 192 | You must make it absolutely clear that any such warranty, support, 193 | indemnity or liability obligation is offered by You alone, and You 194 | hereby agree to indemnify the Initial Developer and every 195 | Contributor for any liability incurred by the Initial Developer or 196 | such Contributor as a result of warranty, support, indemnity or 197 | liability terms You offer. 198 | 199 | 3.5. Distribution of Executable Versions. 200 | 201 | You may distribute the Executable form of the Covered Software 202 | under the terms of this License or under the terms of a license of 203 | Your choice, which may contain terms different from this License, 204 | provided that You are in compliance with the terms of this License 205 | and that the license for the Executable form does not attempt to 206 | limit or alter the recipient's rights in the Source Code form from 207 | the rights set forth in this License. If You distribute the 208 | Covered Software in Executable form under a different license, You 209 | must make it absolutely clear that any terms which differ from 210 | this License are offered by You alone, not by the Initial 211 | Developer or Contributor. You hereby agree to indemnify the 212 | Initial Developer and every Contributor for any liability incurred 213 | by the Initial Developer or such Contributor as a result of any 214 | such terms You offer. 215 | 216 | 3.6. Larger Works. 217 | 218 | You may create a Larger Work by combining Covered Software with 219 | other code not governed by the terms of this License and 220 | distribute the Larger Work as a single product. In such a case, 221 | You must make sure the requirements of this License are fulfilled 222 | for the Covered Software. 223 | 224 | 4. Versions of the License. 225 | 226 | 4.1. New Versions. 227 | 228 | Sun Microsystems, Inc. is the initial license steward and may 229 | publish revised and/or new versions of this License from time to 230 | time. Each version will be given a distinguishing version number. 231 | Except as provided in Section 4.3, no one other than the license 232 | steward has the right to modify this License. 233 | 234 | 4.2. Effect of New Versions. 235 | 236 | You may always continue to use, distribute or otherwise make the 237 | Covered Software available under the terms of the version of the 238 | License under which You originally received the Covered Software. 239 | If the Initial Developer includes a notice in the Original 240 | Software prohibiting it from being distributed or otherwise made 241 | available under any subsequent version of the License, You must 242 | distribute and make the Covered Software available under the terms 243 | of the version of the License under which You originally received 244 | the Covered Software. Otherwise, You may also choose to use, 245 | distribute or otherwise make the Covered Software available under 246 | the terms of any subsequent version of the License published by 247 | the license steward. 248 | 249 | 4.3. Modified Versions. 250 | 251 | When You are an Initial Developer and You want to create a new 252 | license for Your Original Software, You may create and use a 253 | modified version of this License if You: (a) rename the license 254 | and remove any references to the name of the license steward 255 | (except to note that the license differs from this License); and 256 | (b) otherwise make it clear that the license contains terms which 257 | differ from this License. 258 | 259 | 5. DISCLAIMER OF WARRANTY. 260 | 261 | COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" 262 | BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 263 | INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED 264 | SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR 265 | PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND 266 | PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY 267 | COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE 268 | INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY 269 | NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF 270 | WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF 271 | ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS 272 | DISCLAIMER. 273 | 274 | 6. TERMINATION. 275 | 276 | 6.1. This License and the rights granted hereunder will terminate 277 | automatically if You fail to comply with terms herein and fail to 278 | cure such breach within 30 days of becoming aware of the breach. 279 | Provisions which, by their nature, must remain in effect beyond 280 | the termination of this License shall survive. 281 | 282 | 6.2. If You assert a patent infringement claim (excluding 283 | declaratory judgment actions) against Initial Developer or a 284 | Contributor (the Initial Developer or Contributor against whom You 285 | assert such claim is referred to as "Participant") alleging that 286 | the Participant Software (meaning the Contributor Version where 287 | the Participant is a Contributor or the Original Software where 288 | the Participant is the Initial Developer) directly or indirectly 289 | infringes any patent, then any and all rights granted directly or 290 | indirectly to You by such Participant, the Initial Developer (if 291 | the Initial Developer is not the Participant) and all Contributors 292 | under Sections 2.1 and/or 2.2 of this License shall, upon 60 days 293 | notice from Participant terminate prospectively and automatically 294 | at the expiration of such 60 day notice period, unless if within 295 | such 60 day period You withdraw Your claim with respect to the 296 | Participant Software against such Participant either unilaterally 297 | or pursuant to a written agreement with Participant. 298 | 299 | 6.3. In the event of termination under Sections 6.1 or 6.2 above, 300 | all end user licenses that have been validly granted by You or any 301 | distributor hereunder prior to termination (excluding licenses 302 | granted to You by any distributor) shall survive termination. 303 | 304 | 7. LIMITATION OF LIABILITY. 305 | 306 | UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT 307 | (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE 308 | INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF 309 | COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE 310 | LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR 311 | CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT 312 | LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK 313 | STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER 314 | COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN 315 | INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF 316 | LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL 317 | INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT 318 | APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO 319 | NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR 320 | CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT 321 | APPLY TO YOU. 322 | 323 | 8. U.S. GOVERNMENT END USERS. 324 | 325 | The Covered Software is a "commercial item," as that term is 326 | defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial 327 | computer software" (as that term is defined at 48 328 | C.F.R. 252.227-7014(a)(1)) and "commercial computer software 329 | documentation" as such terms are used in 48 C.F.R. 12.212 330 | (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 331 | C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all 332 | U.S. Government End Users acquire Covered Software with only those 333 | rights set forth herein. This U.S. Government Rights clause is in 334 | lieu of, and supersedes, any other FAR, DFAR, or other clause or 335 | provision that addresses Government rights in computer software 336 | under this License. 337 | 338 | 9. MISCELLANEOUS. 339 | 340 | This License represents the complete agreement concerning subject 341 | matter hereof. If any provision of this License is held to be 342 | unenforceable, such provision shall be reformed only to the extent 343 | necessary to make it enforceable. This License shall be governed 344 | by the law of the jurisdiction specified in a notice contained 345 | within the Original Software (except to the extent applicable law, 346 | if any, provides otherwise), excluding such jurisdiction's 347 | conflict-of-law provisions. Any litigation relating to this 348 | License shall be subject to the jurisdiction of the courts located 349 | in the jurisdiction and venue specified in a notice contained 350 | within the Original Software, with the losing party responsible 351 | for costs, including, without limitation, court costs and 352 | reasonable attorneys' fees and expenses. The application of the 353 | United Nations Convention on Contracts for the International Sale 354 | of Goods is expressly excluded. Any law or regulation which 355 | provides that the language of a contract shall be construed 356 | against the drafter shall not apply to this License. You agree 357 | that You alone are responsible for compliance with the United 358 | States export administration regulations (and the export control 359 | laws and regulation of any other countries) when You use, 360 | distribute or otherwise make available any Covered Software. 361 | 362 | 10. RESPONSIBILITY FOR CLAIMS. 363 | 364 | As between Initial Developer and the Contributors, each party is 365 | responsible for claims and damages arising, directly or 366 | indirectly, out of its utilization of rights under this License 367 | and You agree to work with Initial Developer and Contributors to 368 | distribute such responsibility on an equitable basis. Nothing 369 | herein is intended or shall be deemed to constitute any admission 370 | of liability. 371 | 372 | -------------------------------------------------------------------- 373 | 374 | NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND 375 | DISTRIBUTION LICENSE (CDDL) 376 | 377 | For Covered Software in this distribution, this License shall 378 | be governed by the laws of the State of California (excluding 379 | conflict-of-law provisions). 380 | 381 | Any litigation relating to this License shall be subject to the 382 | jurisdiction of the Federal Courts of the Northern District of 383 | California and the state courts of the State of California, with 384 | venue lying in Santa Clara County, California. 385 | --------------------------------------------------------------------------------