krb5: use libresolv-wrapper (#8160)

This commit is contained in:
xtkoba 2021-12-20 18:30:25 +09:00 committed by GitHub
parent 2e096e4698
commit b8b664e508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 5 deletions

View File

@ -4,10 +4,10 @@ TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_LICENSE_FILE="../NOTICE"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.19.2
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://fossies.org/linux/misc/krb5-$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=10453fee4e3a8f8ce6129059e5c050b8a65dab1c257df68b99b3112eaa0cdf6a
TERMUX_PKG_DEPENDS="libandroid-support, libandroid-glob, readline, openssl, libdb"
TERMUX_PKG_DEPENDS="libandroid-support, libandroid-glob, libresolv-wrapper, readline, openssl, libdb"
TERMUX_PKG_BREAKS="krb5-dev"
TERMUX_PKG_REPLACES="krb5-dev"
TERMUX_PKG_CONFFILES="etc/krb5.conf var/krb5kdc/kdc.conf"
@ -15,7 +15,6 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-static
--with-readline
--without-system-verto
--with-netlib=-lc
--enable-dns-for-realm
--sbindir=$TERMUX_PREFIX/bin
--with-size-optimizations
@ -39,7 +38,7 @@ termux_step_pre_configure() {
cp "$TERMUX_PKG_BUILDER_DIR/netbsd_getpass.c" "$TERMUX_PKG_SRCDIR/clients/kpasswd/"
CFLAGS="$CFLAGS -D_PASSWORD_LEN=PASS_MAX"
export LIBS="-landroid-glob"
export LIBS="-landroid-glob -lresolv_wrapper"
}
termux_step_post_make_install() {

View File

@ -0,0 +1,62 @@
--- a/lib/krb5/os/dnsglue.c
+++ b/lib/krb5/os/dnsglue.c
@@ -100,6 +100,41 @@
#else
+#ifdef __ANDROID__
+#include <dlfcn.h>
+typedef int (*res_init_func_t)(void);
+typedef int (*res_search_func_t)(const char *, int, int, unsigned char *, int);
+static res_init_func_t res_init_func = res_init;
+static res_search_func_t res_search_func = res_search;
+#undef res_init
+#undef res_search
+static int res_funcs_initialized;
+
+int
+res_init(void)
+{
+ if (!res_funcs_initialized) {
+ void *wrapper_handle = dlopen("libresolv_wrapper.so", RTLD_NOW);
+ if (wrapper_handle != NULL) {
+ res_init_func_t res_init_wrapper = dlsym(wrapper_handle, "res_init");
+ res_search_func_t res_search_wrapper = dlsym(wrapper_handle, "res_search");
+ if (res_init_wrapper != NULL && res_search_wrapper != NULL) {
+ res_init_func = res_init_wrapper;
+ res_search_func = res_search_wrapper;
+ }
+ }
+ res_funcs_initialized = 1;
+ }
+ return res_init_func();
+}
+
+int
+res_search(const char *dname, int class, int type, unsigned char *answer, int anslen)
+{
+ return res_search_func(dname, class, type, answer, anslen);
+}
+#endif /* __ANDROID__ */
+
/* Use res_init and res_search. */
#define DECLARE_HANDLE(h)
#define INIT_HANDLE(h) (res_init() == 0)
@@ -499,6 +534,9 @@
char *
k5_primary_domain()
{
+#ifdef __ANDROID__
+ return NULL;
+#else
char *domain;
DECLARE_HANDLE(h);
@@ -507,6 +545,7 @@
domain = PRIMARY_DOMAIN(h);
DESTROY_HANDLE(h);
return domain;
+#endif
}
#endif /* not _WIN32 */

View File

@ -3,9 +3,10 @@ TERMUX_PKG_DESCRIPTION="A wrapper for DNS name resolving or DNS faking"
TERMUX_PKG_LICENSE="BSD 3-Clause"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.1.7
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://ftp.samba.org/pub/cwrap/resolv_wrapper-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=460ae7fd5e53485be7dd99a55c5922f1cb1636b9e8821981d49ad16507c8a074
termux_step_pre_configure() {
CFLAGS+=" -DANDROID_CHANGES"
CFLAGS+=" -DANDROID_CHANGES -DLIBC_SO=\\\"libc.so\\\""
}