commit
99bb308e2c
@ -0,0 +1,9 @@
|
|||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
oki-lock.toml
|
||||||
|
oki-packages
|
||||||
|
cmake-build-debug
|
||||||
|
|
||||||
|
*.so
|
||||||
|
*.out
|
@ -0,0 +1,12 @@
|
|||||||
|
CC := gcc
|
||||||
|
CFLAGS := -std=c17 -Wall -Wextra -g
|
||||||
|
|
||||||
|
CPPFLAGS :=
|
||||||
|
LDLIBS :=
|
||||||
|
|
||||||
|
fakeid.so: fakeid.c
|
||||||
|
$(CC) $(CFLAGS) -shared -fPIC -o fakeid.so fakeid.c
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf fakeid.so
|
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LD_PRELOAD=$(dirname "$(readlink -f "$0")")/fakeid.so "$@"
|
@ -0,0 +1,20 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
|
char *username = "alice";
|
||||||
|
|
||||||
|
int getlogin_r(char *buf, size_t bufsize) {
|
||||||
|
strncpy(buf, username, bufsize);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct passwd *getpwuid(uid_t uid) {
|
||||||
|
struct passwd *(*getpwuid)(uid_t) = dlsym(RTLD_NEXT, "getpwuid");
|
||||||
|
struct passwd *pass = getpwuid(uid);
|
||||||
|
pass->pw_name = username;
|
||||||
|
return pass;
|
||||||
|
}
|
Loading…
Reference in new issue