I'm working on a piece of code which is free to use, but when a license code (or serial key or any other term like that) has been bought will remove some advertising.

The code will be freely available as open source, probably under a GPL license, but of course I would rather not have people messing around with the code that verifies the license code with an external provider.

Is there any way to legally protect this piece of code from being modified, or at least from being distributed after being modified, keeping the rest of the code "open"?

4 Answers 4


You could make the largest part of the code opensource, and then make the small part with the verification closed source. Of course this does mean you have to ensure that there is some crucial code in the closed part, otherwise people would just distribute the open part without it. You could for instance opensource the library, and close-source the interface part of your program.

(but to answer your question: no, that's not possible)

  • This also makes it either harder or impossible to use a GPL license, and reduces some of the benefits of open source. Commented Mar 8, 2011 at 14:44
  • You could double-license it. Or you could use the Lesser GPL, but of course what the OP wants is a bit against the open source mentality as well, so that you lose some benefits seems obvious.
    – markijbema
    Commented Mar 8, 2011 at 15:31

Not if the code is open source; part of the Open Source Definition is that people are allowed to modify the code and distribute their changes. Even if you included a closed-source module for the license check, people could just change the open source part to not call it.


If you consider "open source", and you still want to enable certain extra features for users that wish to pay for it, the either choose to create "nagware" or "adware" (that is, with a nag-screen or with an advertisement, annoying users and tempting them to pay for a nag- or ad-free version), or choose for a dual model, which serves the open source community and commercial firms, without the nagging.

The dual model means two things:

  • Choose an open source license that allows use of the software in copyrighted products, like the LGPL (Lesser GPL) license
  • Create two products: one open source product, like a library or basic functionality, plus an advanced product, that included paid extensions, features or enabled enterprise-usage.

You can expand on this with service contracts, of course. This model is quite widely adopted. Well known are MySql and DotNetNuke. Saxon's XSLT 2.0 processor is another example (XSLT-B processor is open source, XSLT-SA processor is payware, the second being built on top of the first).


Didn't etexteditor as far as I remember, did something similar? They open sourced their code while keeping a small part closed.

Your Answer

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