2

I want to install Discovery Studio Visualizer but the precompiled binary checks the system for OS version. When it finds that I am not running RHEL, the installer exits.

Is there a way to change or trick programs that call uname into displaying different info?

4
  • You would need to either recompile the kernel (and give it a different name) or recompile the DSV so it does not check, or see how DSV checks your OS.Run the script from here - accelrys.com/products/collaborative-science/… and contact upstream.
    – Panther
    Jul 22, 2015 at 2:48
  • Ive tried upstream contact they arent geting back to me
    – j0h
    Jul 22, 2015 at 2:52
  • 1
    Is there some reason not to run Centos then ? It is difficult to know how they are perfroming OS detection. You could edit /etc/issue perhaps?
    – Panther
    Jul 22, 2015 at 3:20
  • are you sure it checks uname? and not /etc/lsb-release?
    – Rinzwind
    Nov 16, 2015 at 9:31

2 Answers 2

9

You cannot customize uname's output, but you can spoof the installer by making the system run a custom script instead of the "real" /bin/uname.

First you'll need to check the exact command the installer is running to check your system's information; in this example for the sake of easiness I'll pretend that an executable ~/tmp/check is running uname -n and that the output of uname -n should be ubuntu in order for ~/tmp/check to print "Passed!".

~/tmp/check's source (this of course is not relevant, and is just to showcase what the test executable does):

#include <stdio.h>
#include <string.h>

#define MAX_STRING_LENGTH 32

int main(void) {
    FILE* output = popen("/bin/uname -n", "r");
    char expected[] = "ubuntu";
    char hostname[MAX_STRING_LENGTH];
    fgets(hostname, MAX_STRING_LENGTH, output);
    pclose(output);
    if(hostname[strlen(hostname) - 1] == '\n')
        hostname[strlen(hostname) - 1] = '\0';
    if(strcmp(expected, hostname) == 0) {
        printf("Passed!\n");
        return 0;
    }
    return 1;
}
user@debian:~/tmp$ uname -n
debian
user@debian:~/tmp$ ./check
user@debian:~/tmp$ 

It's easy to track the exact command run by the executable using strace:

user@debian:~/tmp$ strace -f ./check 2>&1 > /dev/null | grep execve
execve("./check", ["./check"], [/* 34 vars */]) = 0
[pid 13122] execve("/bin/sh", ["sh", "-c", "/bin/uname -n"], [/* 34 vars */] <unfinished ...>
[pid 13122] <... execve resumed> )      = 0
[pid 13123] execve("/bin/uname", ["/bin/uname", "-n"], [/* 34 vars */]) = 0

So to get around this one should make uname -n output ubuntu: the easiest solution would be to just move /bin/uname and to create a symbolic link /bin/uname linking to a custom script (which will ignore any argument and just output ubuntu):

cat ~/tmp/spoofer.sh:

#!/bin/bash
echo ubuntu
exit 0
user@debian:~/tmp$ sudo mv /bin/uname /bin/uname1
user@debian:~/tmp$ sudo ln -s ~/tmp/spoofer.sh /bin/uname

Let's see if that worked:

user@debian:~/tmp$ uname -n
ubuntu
user@debian:~/tmp$ ./check
Passed!
user@debian:~/tmp$ 

Bingo! (remember to remove /bin/uname and to move /bin/uname1 back to /bin/uname afterwards: sudo rm /bin/uname && sudo mv /bin/uname1 /bin/uname)

0
1

alias uname 'uname \!* | sed s/Ubuntu/RHEL/'

This is c-shell format alias, you might have to change it a bit based on what shell you are using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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