termux-packages/ndk-patches/pwd.h.patch
Vishal Biswas 160d3aeb06 update ndk to 17 and switch some packages to clang build (#2415)
* update ndk to 17

* bump NDK version in setup-android script

* libnl: fix for ndk r17

* libpixman: use clang's __builtin_shufflevector instead of __builtin_shuffle (#1)

Required to make package build with ndk17.

* fix as for arm

* ndk17 still uses ld.bfd on aarch64

* use -fno-integrated-as for clang only

* glib: remove patch unnecessary after ndk17

* torsocks: remove unneeded patch after ndk17

* subversion: fix build as clang++ now errors out for mismatched flags

* libpulseaudio: fix build with ndk17

https://github.com/termux/termux-packages/pull/2415#issuecomment-388296684

* gst-plugins-good: disable video4linux2

ioctl is defined as __overloadable in ndk17 headers which
  conflicts with v4l2object's member ioctl

* libzmq: disable Werror to build with ndk17

* ltrace: hardcode symbol not available in ndk17

* busybox: build with clang for all arches except arm

* dropbear: build with clang instead of gcc

* gnupg: build with clang instead of gcc

* openssl: use clang for all arches except arm

* picolisp: build with clang instead of gcc

* valgrind: use clang on all arches except aarch64

* Revert "gst-plugins-good: disable video4linux2"

This reverts commit 43850b81ccf60033c25cb13dfd326c1b0528773a.
Already applied on base branch.

* libllvm: use default arm triple
2018-05-27 14:55:20 +02:00

65 lines
2.1 KiB
Diff

diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/pwd.h ./usr/include/pwd.h
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/pwd.h 2017-06-20 17:41:56.000000000 +0200
+++ ./usr/include/pwd.h 2017-06-26 11:45:26.036064547 +0200
@@ -89,7 +91,6 @@
struct passwd* getpwent(void) __INTRODUCED_IN(26);
void setpwent(void) __INTRODUCED_IN(26);
-void endpwent(void) __INTRODUCED_IN(26);
#endif /* __ANDROID_API__ >= 26 */
@@ -97,6 +98,52 @@
int getpwnam_r(const char* __name, struct passwd* __pwd, char* __buf, size_t __n, struct passwd** __result) __INTRODUCED_IN(12);
int getpwuid_r(uid_t __uid, struct passwd* __pwd, char* __buf, size_t __n, struct passwd** __result) __INTRODUCED_IN(12);
+
+int access(const char* __path, int __mode);
+
+static void android_setup_pwd(struct passwd* pw) {
+ char const* result = "@TERMUX_PREFIX@/bin/login";
+ if (result == NULL || access(result, /*X_OK*/1) == -1) {
+ pw->pw_shell = "@TERMUX_PREFIX@/bin/bash";
+ } else {
+ pw->pw_shell = (char*) result;
+ }
+ 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) {
+ struct passwd* pw = getpwuid(t);
+ if (pw == NULL) return NULL;
+ android_setup_pwd(pw);
+ return pw;
+}
+
+static struct passwd* android_polyfill_getpwnam(const char* name) {
+ struct passwd* pw = getpwnam(name);
+ if (pw == NULL) return NULL;
+ android_setup_pwd(pw);
+ return pw;
+}
+
+static int android_polyfill_getpwuid_r(uid_t uid,
+ struct passwd *pwd,
+ char *buffer,
+ size_t bufsize,
+ struct passwd **result) {
+ int ret = getpwuid_r(uid, pwd, buffer, bufsize, result);
+ if (ret != 0) return ret;
+ android_setup_pwd(pwd);
+ return 0;
+}
+
+#define getpwnam android_polyfill_getpwnam
+#define getpwuid android_polyfill_getpwuid
+#define getpwuid_r android_polyfill_getpwuid_r
+static void endpwent(void) { /* Do nothing. */ }
__END_DECLS