introduce minifakeroot that also works on macos

This commit is contained in:
Jörg Thalheim
2024-06-27 18:20:16 +02:00
parent 2ed8bba017
commit cb9fbc969b
5 changed files with 55 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
#include <stdint.h>
typedef uint32_t uid_t;
#ifdef __APPLE__
struct dyld_interpose {
const void * replacement;
const void * replacee;
};
#define WRAPPER(ret, name) static ret _fakeroot_wrapper_##name
#define WRAPPER_DEF(name) \
__attribute__((used)) static struct dyld_interpose _fakeroot_interpose_##name \
__attribute__((section("__DATA,__interpose"))) = { &_fakeroot_wrapper_##name, &name };
#else
#define WRAPPER(ret, name) ret name
#define WRAPPER_DEF(name)
#endif
WRAPPER(uid_t, geteuid)(const char * path, int flags, ...)
{
return 0; // Fake root
}
WRAPPER_DEF(geteuid)
WRAPPER(uid_t, getuid)(const char * path, int flags, ...)
{
return 0; // Fake root
}
WRAPPER_DEF(getuid)