Skip to content

Instantly share code, notes, and snippets.

@DamnedFacts
Last active September 29, 2020 04:18
Show Gist options
  • Save DamnedFacts/5239593 to your computer and use it in GitHub Desktop.
Save DamnedFacts/5239593 to your computer and use it in GitHub Desktop.
Fake uname information in order to make tools, such as megacli, work: Gentoo-11 tmp # gcc -Wall -fPIC -c fake-uname.c Gentoo-11 tmp # gcc -Wall -shared -o libfake-uname.so fake-uname.o Now we get libfake-uname.so, use LD_PRELOAD=./libfake-uname.so to preload it, over uname from glibc: Gentoo-11 tmp # LD_PRELOAD=./libfake-uname.so LD_LIBRARY_PATH…
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <string.h>
int uname(struct utsname *buf)
{
int ret;
ret = syscall(SYS_uname, buf);
printf("uname release: \"%s\"\n", buf->release);
strcpy(buf->release, "2.6.40");
printf("uname release set to: \"%s\"\n", buf->release);
printf("uname version: \"%s\"\n", buf->version);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment