X-Git-Url: https://git.distorted.org.uk/~mdw/termux-packages/blobdiff_plain/341654304c557250ec9ee895b3c59ebb01a4ce88..a5efde46ede86145c5678c17a6e58cfee893d2f5:/ndk_patches/pwd.patch diff --git a/ndk_patches/pwd.patch b/ndk_patches/pwd.patch index bee01ee1..1447c38e 100644 --- a/ndk_patches/pwd.patch +++ b/ndk_patches/pwd.patch @@ -1,25 +1,22 @@ diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/pwd.h ./usr/include/pwd.h ---- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/pwd.h 2014-10-14 22:53:49.000000000 -0400 -+++ ./usr/include/pwd.h 2015-07-15 09:42:32.974621965 -0400 -@@ -65,6 +65,9 @@ +--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/pwd.h 2016-03-03 16:54:24.000000000 -0500 ++++ ./usr/include/pwd.h 2016-03-10 08:11:16.795710172 -0500 +@@ -65,6 +65,10 @@ #include #include -+/* For access(): */ ++/* For access() and realpath(): */ +#include ++#include + #define _PATH_PASSWD "/etc/passwd" #define _PATH_MASTERPASSWD "/etc/master.passwd" #define _PATH_MASTERPASSWD_LOCK "/etc/ptmp" -@@ -119,6 +122,41 @@ +@@ -119,7 +123,40 @@ int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**); int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**); -+extern char *realpath(const char *path, char *resolved_path); -+extern void free(void *ptr); -+extern void *memcpy(void *dest, const void *src, size_t n); -+extern size_t strlen(const char *s); -+ +-void endpwent(void); +static void android_setup_pwd(struct passwd* pw) { + static char realpath_buffer[4096/*PATH_MAX*/]; + char* result = realpath("@TERMUX_HOME@/.termux/shell", realpath_buffer); @@ -28,10 +25,13 @@ diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/incl + if (access(bash_path, X_OK) != -1) pw->pw_shell = (char*) bash_path; + else pw->pw_shell = "@TERMUX_PREFIX@/bin/ash"; + } else { -+ pw->pw_shell = realpath_buffer; ++ pw->pw_shell = strcmp(realpath_buffer, "@TERMUX_PREFIX@/bin/busybox") == 0 ? (char*)"@TERMUX_PREFIX@/bin/ash" : realpath_buffer; + } + pw->pw_dir = "@TERMUX_HOME@"; + pw->pw_passwd = "*"; ++#ifdef __LP64__ ++ pw->pw_gecos = ""; /* Avoid NULL field. */ ++#endif +} + +static struct passwd* android_polyfill_getpwuid(uid_t t) { @@ -50,6 +50,6 @@ diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/incl + +#define getpwnam android_polyfill_getpwnam +#define getpwuid android_polyfill_getpwuid - void endpwent(void); ++static void endpwent(void) { /* Do nothing. */ } struct passwd* getpwent(void); int setpwent(void);