# How to set or make FreeBSD report its OS as "Linux" to fool a (Java) app?



## ikevin8me (Aug 8, 2021)

I'm trying to run a Java app written for Linux on FreeBSD 13. 
The Java app reports the operating system "FreeBSD" as being not recognized.
Is there anyway to set or make FreeBSD output its name as "Linux" to "fool" the Java app?


----------



## eternal_noob (Aug 8, 2021)

Can't you just edit the Java method which detects the OS?


----------



## ct85711 (Aug 8, 2021)

How do I programmatically determine operating system in Java?
					

I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different properties based on whether I am ...




					stackoverflow.com
				




I found this page has some information about OS detection, but also mentions how you could possibly change the detected OS.  The most relevant part, is fairly far down towards the bottom.  The main thing,is more of how the app does the detection (you may need to read through the various responses on what to look on.



> *If you're working in a security sensitive environment, then please read this through.*
> 
> 
> Please refrain from ever trusting a property obtained via the System#getProperty(String) subroutine! Actually, almost every property including os.arch, os.name, and os.version isn't readonly as you'd might expect — instead, they're actually quite the opposite.
> ...


----------



## shkhln (Aug 8, 2021)

ct85711 said:


> The most relevant part, is fairly far down towards the bottom.


That's actually quite nonsensical. End users can also change the source code and recompile the application and do whatever they please in general.


----------



## ikevin8me (Aug 8, 2021)

Well, the Java program is not open source.


----------



## chungy (Aug 8, 2021)

An OS-dependent Java app seems completely contrary to the point of Java 

Probably one of the easiest workarounds is to patch the OpenJDK and build your own version, so it reports the OS name and version as Linux 5.10 or something no matter what.

Alternatives might include trying to binary-patch the class files so they accept FreeBSD, running in a Linux jail*, or patching the FreeBSD kernel so it claims to be Linux.

* If the app is looking for Linux so that it can run JNIs, you may just have to go the jail route.


----------



## covacat (Aug 8, 2021)

try setting env var UNAME_s to linux
see uname(3)


----------



## Geezer (Aug 8, 2021)

chungy said:


> An OS-dependent Java app seems completely contrary to the point of Java


Yes. Java has not worked.


----------



## Jose (Aug 8, 2021)

Geezer said:


> Yes. Java has not worked.


Java can be made to work. I suspect the problem is the programmers of this closed source app.








						Any interest in Tribal Trouble 1?
					

https://github.com/sunenielsen/tribaltrouble  I got it to work under Freebsd 12.1, but I need motivation to work on it further.




					forums.freebsd.org


----------



## ralphbsz (Aug 8, 2021)

chungy said:


> An OS-dependent Java app seems completely contrary to the point of Java


More likely and less obnoxious explanation: The program is actually OS dependent. For example, it might be using facilities like sysctl (on *BSD) versus the /sys file system (on Linux), or have path dependencies that can't be worked around. We have to recognize that efforts to make programs OS-independent (which includes Codasyl, POSIX, Java, ...) have reasonable well succeeded for user-level programs, but when it gets into system tasks, life is still OS dependent. So pretending that FreeBSD is Linux (with a hacked JVM or the UNAME_... environment variable override) is likely to just expose that this program won't work anyway.


----------

