4

When I am using some code licensed with the MIT license, but it's not in seperate files, is it OK mark it like this?

/* Here starts code licensed under the MIT License (../MIT.txt) */
// code
/* Here is the end of code licensed under the MIT License (../MIT.txt) */

Where in ../MIT.txt file, it would contain the MIT License text and the original author's copyright notices.

Also, when most of code is MIT licensed and I'm only changing some sections of the functions can I mark those parts with the same method as above but with my own license? Yes, it's going to be a lot of kilobytes of comments.

3 Answers 3

4

When you use MIT-licensed code in a non-MIT-licensed project, simply marking the MIT-licensed parts of the source code is not a good strategy. The license allows you to do just about anything with the code – including sublicensing the code –, under this one restriction:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Note that the MIT license should also be displayed to the end user of your software. Where you display your copyright to the user, you should also add something like

This program includes code from the FooBar library, used under the following license:

The "FooBar" library  
Copyright (c) <year> <copyright holders>

<license body>

In addition, you might want to explicitly mark the sections in the code that were taken from an MIT-licensed source. From my understanding, this is not required, but it would be ethical.

When you modify an MIT-licensed source, you should not mark your contributions with a separate license, because this requires an user of the source to follow both the original license and your license. Instead, choose one of the following options:

  • License your contributions under the same license as the rest of the code. You can edit the copyright notice to reflect that you contributed to the source, without marking what exactly you changed.
  • Re-license the MIT-licensed source under your license, in a manner permitted by the MIT license. See above.

Notes:

  • I'm a programmer, not a lawyer.
  • The term “MIT license” is fairly ambiguous. This answer assumes the Expat License, but is also applicable to the X11 License.
2
  • It says "this permission notice" - I'm trying to protect from someone saying in court "You wrote about MIT, I thought that code was also on MIT". About re-licensing - it's not so possible with MIT.
    – Marqin
    Sep 16, 2014 at 13:17
  • @Marqin The term “MIT license” is used for a number of free software licenses. My answer specifically deals with the Expat License, which allows sublicensing. To avoid misunderstandings, make it clear under what license your code is being distributed, and that the recitation of the MIT license is just an acknowledgement for the original source. A reasonable person should be able to figure out using common sense what part is the license, and what is the acknowledgement. You do not have to cater to complete morons.
    – amon
    Sep 16, 2014 at 15:06
1

That's insane. DON'T DO THAT.

If you are working in some one else's code that has an MIT license, then your changes should have the MIT license. If you can't for some reason use the same license as the rest of the project, then you shouldn't be fooling with it. If you have an ethical or whatever disagreement with the licensing of a project, then DON'T WORK ON THAT PROJECT.

It is TOTALLY unreasonable for you to place a veritable copyright compliance minefield throughout each source file. It's NOT reasonable for you to expect users of the code to review every line of every source file in order to determine what the licensing of the thing is.

If you simply MUST do things differently, then pull your code out to separate files, so that someone evaluating the code for their use would have a CHANCE of knowing what license the code was under.

Also: If it came down to a courtroom, I'm unclear how your shenanigans would fare. An unobservant person could legitimately claim to have not noticed your bits being licensed differently, and an unscrupulous one could potentially use the confusion to do things you didn't intend.

0

If you wanted to do this (and you didn't care about the possible backlash) you should at the very least:

  • Add a license file, as you suggest.
  • Point out in the readme file very clearly that the code is licensed as "foo" (whatever the original license is) except where bracketed by "some special start string" and "some special end string" which is MIT licensed. These strings must be unique and never misspelled, so that users could conceivably remove them using a simple script if they don't want your code.

To avoid excessive backlash, you should probably also do this:

  • Provide the user with a link or script to get the code without your differently licensed changes.
  • Make sure the code works (or, at least, all tests pass) if your code is removed.
  • Put your code in separate files or wrap the original project (using for example a Git submodule) to guarantee that you're not modifying the original code.

The biggest issue with this is probably how your code would mesh with the rest of it. You can't modify even a single line of the original code and re-license it, so how are you going to do sane changes? For example, you can't statically link GPL code without changing your license to GPL. There are probably hosts of other issues with specific licenses, and you're very likely just creating problems for yourself and others. If you care about other users enough (assuming you're not selling the compiled project) to release your changes, why do you not care enough to use the original license?

A much simpler solution which has no guarantee of success is to calmly and reasonably explain to the original author(s) why you would like the software to use the MIT license, and whether they would be willing to dual license it.

5
  • 1
    why are you talking about the GPL? This is about the MIT License.
    – amon
    Sep 15, 2014 at 12:12
  • 1
    It's just an example. You didn't say which was the second license in question.
    – l0b0
    Sep 15, 2014 at 12:14
  • 2
    MIT license explicitly permits sublicensing. Sep 15, 2014 at 12:14
  • It's propertiary license. I'm just protecting my code in case of evil co-worker or hacker leak. How about linking to original software repo and say "Code that matches with it is on MIT license, rest is on mine." ?
    – Marqin
    Sep 16, 2014 at 13:14
  • @Marqin Anything security-related should not be part of your code. If that's what you mean you need to fix the way the code is written. That said, your solution could work, but I don't understand why you would want to do that.
    – l0b0
    Sep 16, 2014 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.