From 85f34c19a6b295359be34b0c04f2be37ce0a9be1 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Thu, 9 Dec 2021 18:24:53 +0100 Subject: [PATCH 1/3] Add dummy getpwuid and getpwnam for more POSIX compatibility. This should get around libs/programs that just attempt to get the current users's home directory. --- src/libcglue/Makefile.am | 3 ++- src/libcglue/glue.c | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libcglue/Makefile.am b/src/libcglue/Makefile.am index 9669213a..ca83bcb9 100644 --- a/src/libcglue/Makefile.am +++ b/src/libcglue/Makefile.am @@ -27,7 +27,8 @@ FDMAN_OBJS = __descriptor_data_pool.o __descriptormap.o __fdman_init.o __fdman_g GLUE_OBJS = __fill_stat.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o _open.o _close.o _read.o _write.o _fstat.o \ _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _seekdir.o _link.o _unlink.o \ _rename.o _getpid.o _kill.o _sbrk.o _gettimeofday.o _times.o ftime.o _internal_malloc_lock.o _internal_malloc_unlock.o \ - _isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o + _isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o getpwuid.o \ + getpwnam.o INIT_OBJS = __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index 54b29fd6..daa89899 100644 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -926,4 +927,19 @@ int getentropy(void *buffer, size_t length) { return 0; } -#endif \ No newline at end of file +#endif + +#ifdef F_getpwuid +struct passwd *getpwuid(uid_t uid) { + /* There's no support for users */ + return NULL; +} +#endif + +#ifdef F_getpwnam +struct passwd *getpwnam(const char *name) { + /* There's no support for users */ + return NULL; +} +#endif + From d05f1945d1e8f9f1c016eaa905589d8e60327285 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Thu, 9 Dec 2021 18:29:00 +0100 Subject: [PATCH 2/3] Add getuid/geteuid to return user=0 (root) Hopefully allows some programs to build even though there's no support for users on the system. --- src/libcglue/Makefile.am | 2 +- src/libcglue/glue.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcglue/Makefile.am b/src/libcglue/Makefile.am index ca83bcb9..48c53076 100644 --- a/src/libcglue/Makefile.am +++ b/src/libcglue/Makefile.am @@ -28,7 +28,7 @@ GLUE_OBJS = __fill_stat.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _seekdir.o _link.o _unlink.o \ _rename.o _getpid.o _kill.o _sbrk.o _gettimeofday.o _times.o ftime.o _internal_malloc_lock.o _internal_malloc_unlock.o \ _isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o getpwuid.o \ - getpwnam.o + getpwnam.o getuid.o geteuid.o INIT_OBJS = __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index daa89899..58b78143 100644 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -929,6 +929,20 @@ int getentropy(void *buffer, size_t length) { } #endif +#ifdef F_getuid +uid_t getuid(void) { + /* Not sure if returning root is a good idea */ + return 0; +} +#endif + +#ifdef F_geteuid +uid_t geteuid(void) { + /* Not sure if returning root is a good idea */ + return 0; +} +#endif + #ifdef F_getpwuid struct passwd *getpwuid(uid_t uid) { /* There's no support for users */ From eae72ff954c099a0f734e5a36f8862a1a14c022e Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Thu, 9 Dec 2021 21:24:14 +0100 Subject: [PATCH 3/3] Make getuid/geteuid return 1000 to "look like" a non-root user. --- src/libcglue/glue.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index 58b78143..9d925681 100644 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -931,15 +931,13 @@ int getentropy(void *buffer, size_t length) { #ifdef F_getuid uid_t getuid(void) { - /* Not sure if returning root is a good idea */ - return 0; + return 1000; } #endif #ifdef F_geteuid uid_t geteuid(void) { - /* Not sure if returning root is a good idea */ - return 0; + return 1000; } #endif