Skip to content

Instantly share code, notes, and snippets.

@ProjectMoon
Last active January 6, 2023 17:31
Show Gist options
  • Save ProjectMoon/1318300 to your computer and use it in GitHub Desktop.
Save ProjectMoon/1318300 to your computer and use it in GitHub Desktop.
Patch that disables Subsonic license checking and validation

Update 2020 Edition: Use something like Airsonic instead. Subsonic's code is closed source at this point, and thus this patch is useless, unless you are using a 9 year old verison of Subsonic for some reason.


A patch to disable the licensing functionality in Subsonic, a GPL-licensed media streaming server/web interface. Use of the mobile apps requires you to get a license after 30 days of trial. You obtain a license via donation.

Except that's not a donation. So, here's a patch to fix that. Support the Subsonic project with a donation that's actually a donation. The program is developed and maintained very well.

Steps to victory

svn co https://subsonic.svn.sourceforge.net/svnroot/subsonic/trunk subsonic

Check out a different branch if you want a specific version.

From the branch root:

patch -p0 < nolicense.patch
mvn install
cd subsonic-booter/
mvn install

Replace the downloaded subsonic.war and subsonic-booter-with-dependencies.jar with the newly compiled ones. Compilation of subsonic-booter is probably optional. It's just a precaution in case the branch you are compiling is newer than whatever version you downloaded.

Index: subsonic-main/src/main/java/net/sourceforge/subsonic/service/SettingsService.java
===================================================================
--- subsonic-main/src/main/java/net/sourceforge/subsonic/service/SettingsService.java (revision 2462)
+++ subsonic-main/src/main/java/net/sourceforge/subsonic/service/SettingsService.java (working copy)
@@ -589,10 +589,7 @@
}
public boolean isLicenseValid(String email, String license) {
- if (email == null || license == null) {
- return false;
- }
- return license.equalsIgnoreCase(StringUtil.md5Hex(email.toLowerCase()));
+ return true;
}
public String getDownsamplingCommand() {
@@ -1136,31 +1133,7 @@
}
private void validateLicense() {
- String email = getLicenseEmail();
- Date date = getLicenseDate();
-
- if (email == null || date == null) {
- licenseValidated = false;
- return;
- }
-
licenseValidated = true;
-
- HttpClient client = new DefaultHttpClient();
- HttpConnectionParams.setConnectionTimeout(client.getParams(), 120000);
- HttpConnectionParams.setSoTimeout(client.getParams(), 120000);
- HttpGet method = new HttpGet("http://subsonic.org/backend/validateLicense.view" + "?email=" + email +
- "&date=" + date.getTime() + "&version=" + versionService.getLocalVersion());
- try {
- ResponseHandler<String> responseHandler = new BasicResponseHandler();
- String content = client.execute(method, responseHandler);
- licenseValidated = content != null && content.contains("true");
- LOG.debug("License validated: " + licenseValidated);
- } catch (Throwable x) {
- LOG.warn("Failed to validate license.", x);
- } finally {
- client.getConnectionManager().shutdown();
- }
}
public void validateLicenseAsync() {
@ProjectMoon
Copy link
Author

The instructions assume you are on a Unix command line. You will need Maven and SVN installed. It's a list of commands you need to enter. This can be done under Windows as well. You will still need all the dependencies. If you don't understand the instructions, I suggest you read up on using Subversion and Maven on the Windows command line.

@OakRaider4Life
Copy link

When patching I got the errors "Hunk #1 failed at 589" and "Hunk #2 failed at 1136." Pulled down the nolicense.patch from the git clone URL and the subsonic directory from the subversion url as directed.. am I missing something here?

@ProjectMoon
Copy link
Author

http://www.markusbe.com/2009/11/how-to-apply-a-patch-and-solve-hunk-failed-cant-find-file-to-patch-and-others/#hunk-failed

The file has probably changed since this patch was created. I don't remember the specific commit I checked out. But really all you need to do is set licenseValidated to true, and return true from isLicenseValid.

@OakRaider4Life
Copy link

Is there a different file I need to edit if I'm trying to compile for an ubuntu server?

@OakRaider4Life
Copy link

Ok, what I did to successfully make this patch work on an Ubuntu Server:

Find lines of code pointed to in patch, in file specified by patch (/subsonic-main/src/main/java/net/sourceforge/subsonic/service/SettingsService.java) and make changes specified by ProjectMoon (also specified in code of patch). Follow instructions to compile as described in readme, then
cd [SUBSONIC ROOT]/subsonic-installer-debian
mvn install

This will compile a new subsonic.war and subsonic-booter-jar-with-dependencies.jar in [SUBSONIC ROOT]/subsonic-installer-debian/target/deb/usr/share/subsonic
Copy the .war (and .jar if needed) to /usr/share/subsonic, run
/etc/init.d/subsonic restart
and server is patched.

@ProjectMoon
Copy link
Author

If you know what commit you checked out, you can submit a new patch and I can specify the commit in the gist.

@EugeneKay
Copy link

I am maintaining a git-svn checkout of the Subsonic project here with the licensing code removed, similar to this patch. I have released a .war, and will be making a best effort to keep up-to-date with release versions.

@jonathanebetts
Copy link

Thank you SO much EugeneKay ... I was wondering why people wouldn't just fork this software into something that didn't contain the license checking and my searches led me here. Now ..... how would a non-programmer go about compiling your new fork to a working version of subsonic-4.6-setup.exe (i.e. windows) ..... ? I'm no slacker, but have no clue how to turn a set of files on github into compiled java software ..... Any hints? Thanks!

@ProjectMoon
Copy link
Author

Instructions would be the same as they are in this gist, minus the part about applying the patch. You need to install maven and then do mvn install on the root of the repository and in the subsonic-booter subproject.

@ProjectMoon
Copy link
Author

Also, just randomly found this: http://forum.subsonic.org/forum/viewtopic.php?f=3&t=3521&start=15

Edit: Ok, apparently this is another fork. See the GitHub repo here: https://github.com/Mach5/supersonic

That one already has 16 followers.

@EugeneKay
Copy link

I was not aware of that fork, but they appear to be doing quite a bit of rebranding and modification. I'm unsure what effect that will have on the end product, but I happen to like the lil yellow submarine logo. The license on this code is GPL v3, with none of the Section 7 terms being applied, which would restrict said branding. I nevertheless will be making some effort to indicate that this is not a subsonic.org release, on the Downloads page I will be putting up and in the About page in the software.

I will do what I can to get some more formats built & uploaded today - I put up the .war because that's what I use(I have an existing Tomcat6 server).

@oktane
Copy link

oktane commented Aug 30, 2012

so I had no luck with replacing the WAR, nor finding a complete supersonic download, and I do not think that recompiling the thing every time, not to mention setting up the development environment, is an easy thing for most non-dev people. The simplest solution for me was to fool the license check via a hosts DNS redirect to a local (or remote) server that serves up /backend/validateLicense.view, and returns true.

A killer solution would be to integrate this hack into subsonic itself, by placing the file into installdir/jetty/3081/webapp (varies I think) so that it's own server would serve it up, then just applying the dns change via whatever means. (local HOSTS file on server, router, dnsmasq) But I couldn't get that to work, since if a GET is made for a .view file on subsonic's jetty, it does it's java function lookup instead of delivering the file. (lookup fails since there is no backend classes obviously) Does anyone know any jetty voodoo like similar to an apache redirect, which could be installed by simply placing a file in that jetty 'server-root' folder? For now, I just used a different server to host the file, and it validates the license check fine. (success is donation link/heart goes away) But it would be nice if the solution was all in one, more elegant I suppose.

Note that this kills the following (fairly useless) features: remote settings storage, new version alerts, etc.. that DNS redirect will prevent all phoning home.

Cheers, from a person that would donate if they could.

@Rovanion
Copy link

Here's a current diff for upstream version 4.7 of Subsonic: https://gist.github.com/3767624

@aijcoa
Copy link

aijcoa commented Jun 4, 2013

I can't get this to work. I've installed subsonic from source in my home dir ~/subsonic, I make a file in this dir called noLicence.patch and run the commands, but I get "Hunk #1 Failed [...]" errors. How can I fix this?

@EugeneKay
Copy link

In case anybody is still encountering this Gist on Google, please note that there have been recent changes to licensing code which invalidates this patch entirely. My Fork is the only one I'm aware of that is keeping current with upstream Subsonic and does not add bells+whistles.

@denilsonsa
Copy link

Also for anyone also finding this Gist from search engines, consider looking at https://github.com/airsonic/airsonic , which is a fork based on the latest open-source subsonic code.

@ProjectMoon
Copy link
Author

Didn't even realize this was still relevant. In fact, forgot it even existed. I updated the gist again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment