Initial commit

This commit is contained in:
2023-04-20 19:12:27 +02:00
commit 99bb308e2c
5 changed files with 50 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
.idea
.vscode
oki-lock.toml
oki-packages
cmake-build-debug
*.so
*.out

12
Makefile Normal file
View File

@@ -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

3
fakeid Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
LD_PRELOAD=$(dirname "$(readlink -f "$0")")/fakeid.so "$@"

20
fakeid.c Normal file
View File

@@ -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;
}

6
oki.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "fakeid"
version = "0.1.0"
kind = "c"
[dependencies]