Skip to main content
20 events
when toggle format what by license comment
Feb 21, 2023 at 0:07 answer added Yupeng Tang timeline score: 0
Feb 2, 2022 at 2:58 vote accept dave
Jan 7, 2022 at 8:38 comment added Gilles 'SO- stop being evil' You can override system calls in a statically linked executable with ptrace. It's a bit more complicated than LD_PRELOAD. See e.g. stackoverflow.com/questions/13426561/…, nullprogram.com/blog/2018/06/23
Jan 7, 2022 at 5:40 comment added dave @binki: I'll have a test of your LD_PRELOAD when I have hyphens back in my OS Version (I've rebuilt now without them). I thought that trick only worked for dynamic executables and now I'm going to have to look up how it works (if I can't figure it out look out for another Question!)
Jan 7, 2022 at 4:45 comment added binki @dave I hacked up the LD_PRELOAD approach for fun: github.com/binki/binki-fool-java-os-version
Jan 7, 2022 at 3:37 comment added binki But people are right when they say that the package is broken. The Java package is parsing the version string in a way which will break almost everywhere. Also, it is a Java package—why is it even checking the kernel version? The developers need to fix that. However, as people said, you can just use LD_PRELOAD to intercept its call to uname(2) once you figure out how java resolves that through glibc and then you can fool just java about the kernel version.
Jan 7, 2022 at 3:35 comment added binki @dave Well, if you’re willing to rebuild the kernel, see CONFIG_LOCALVERSION. You probably did not set this manually, but using genkernel which only has --kernel-append-localversion which does not let you remove the -gentoo. So you can just not use genkernel to avoid that and have control over the CONFIG_LOCALVERSION.
Jan 7, 2022 at 2:38 answer added dave timeline score: 0
Jan 7, 2022 at 2:03 answer added spybull timeline score: -3
Jan 6, 2022 at 23:13 comment added dave @binki: Java doesn't call uname executable, it uses the uname(2) system call. (Found this using your suggestion of strace. I don't care if I change my OS version system wide, I just need to know how to do it at all, not just for this one application.
Jan 6, 2022 at 20:44 comment added binki Try writing a custom uname, put it in a special folder, and alter PATH prior to invoking just this app. Does it detect the name via shellout or a different way? You can run it under strace to figure that out. If it is getting this information a different way, you might be able to use namespaces to change that just for that application.
Jan 6, 2022 at 15:18 comment added dave LD_PRELOAD isn't going to work because the java executable isn't dynamically linked. So you are back to somehow patching the Java application directly. Is there a Java equivalent of LD_PRELOAD? And if so could you write that as an answer?
Jan 6, 2022 at 15:04 answer added Ome Cor timeline score: -5
Jan 6, 2022 at 14:49 comment added Marcus Müller as said, through preloading
Jan 6, 2022 at 14:10 comment added dave @MarcusMüller:okay, how do I patch a java app which I don't have the source code to and only the class files which I decompiled to find the problem?
Jan 6, 2022 at 13:25 comment added Marcus Müller This breaks an app I'm using which doesn't like the dashes in the version number (it expects just a number, no dashes allowed). That app is the problem, so I'd go ahead and fix the app. You're also running it, it seems, so you can basically preload and modify system libraries. Either you patch os.version, or you patch that application. I'd have a clear favourite.
Jan 6, 2022 at 13:10 comment added Alex Aha, so now it's related to a remote server. askubuntu.com/a/724421 this is how uname pulls kernel related information
Jan 6, 2022 at 13:06 comment added dave @Alex: I can't modify the server I want to connect to, so I have to change something about my system. And it dislikes the dashes in the OS version. Recompiling the kernel won't help if I don't change anything - where does it get the version from?
Jan 6, 2022 at 13:01 comment added Alex Well you cannot do it easily. One option is to recompile the kernel or spoof the uname output. You are looking for a solution in the wrong direction.
Jan 6, 2022 at 12:48 history asked dave CC BY-SA 4.0