From 4eb826279c131257c3bc37d42f394208022ef07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Thu, 11 Aug 2016 12:50:52 +0200 Subject: main/busybox: include whois fix from upstream Fixes #4488 --- .../busybox/0016-whois-make-it-actually-work.patch | 185 +++++++++++++++++++++ main/busybox/APKBUILD | 6 +- 2 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 main/busybox/0016-whois-make-it-actually-work.patch (limited to 'main/busybox') diff --git a/main/busybox/0016-whois-make-it-actually-work.patch b/main/busybox/0016-whois-make-it-actually-work.patch new file mode 100644 index 0000000000..fe7cfe17ce --- /dev/null +++ b/main/busybox/0016-whois-make-it-actually-work.patch @@ -0,0 +1,185 @@ +From f8e33d70806d0dee740e5451aedfe5089a4d156a Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko +Date: Wed, 6 Jul 2016 15:45:41 +0200 +Subject: [PATCH 16/16] whois: make it actually work + +It was doing way too simplistic work of just querying the server, +no redirects, no query massaging. This required user to know a lot about whois, +and enter at least three queries for each host to get meaningful information. + +function old new delta +whois_main 209 646 +437 + +Signed-off-by: Denys Vlasenko +--- + networking/whois.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 124 insertions(+), 13 deletions(-) + +diff --git a/networking/whois.c b/networking/whois.c +index bf33033..5ef8367 100644 +--- a/networking/whois.c ++++ b/networking/whois.c +@@ -28,36 +28,147 @@ + + #include "libbb.h" + +-static void pipe_out(int fd) ++static char *query(const char *host, int port, const char *domain) + { ++ int fd; + FILE *fp; +- char buf[1024]; ++ bool success; ++ char *redir = NULL; ++ const char *pfx = ""; ++ char linebuf[1024]; ++ char *buf = NULL; ++ unsigned bufpos = 0; + ++ again: ++ printf("[Querying %s:%d '%s%s']\n", host, port, pfx, domain); ++ fd = create_and_connect_stream_or_die(host, port); ++ success = 0; ++ fdprintf(fd, "%s%s\r\n", pfx, domain); + fp = xfdopen_for_read(fd); +- while (fgets(buf, sizeof(buf), fp)) { +- char *p = strpbrk(buf, "\r\n"); +- if (p) +- *p = '\0'; +- puts(buf); +- } + ++ while (fgets(linebuf, sizeof(linebuf), fp)) { ++ unsigned len = strcspn(linebuf, "\r\n"); ++ linebuf[len++] = '\n'; ++ ++ buf = xrealloc(buf, bufpos + len + 1); ++ memcpy(buf + bufpos, linebuf, len); ++ bufpos += len; ++ ++ if (!redir || !success) { ++ trim(linebuf); ++ str_tolower(linebuf); ++ if (!success) { ++ success = is_prefixed_with(linebuf, "domain:") ++ || is_prefixed_with(linebuf, "domain name:"); ++ } ++ else if (!redir) { ++ char *p = is_prefixed_with(linebuf, "whois server:"); ++ if (!p) ++ p = is_prefixed_with(linebuf, "whois:"); ++ if (p) ++ redir = xstrdup(skip_whitespace(p)); ++ } ++ } ++ } + fclose(fp); /* closes fd too */ ++ if (!success && !pfx[0]) { ++ /* ++ * Looking at jwhois.conf, some whois servers use ++ * "domain = DOMAIN", "DOMAIN ID " ++ * and "domain=DOMAIN_WITHOUT_LAST_COMPONENT" ++ * formats, but those are rare. ++ * (There are a few even more contrived ones.) ++ * We are trying only "domain DOMAIN", the typical one. ++ */ ++ pfx = "domain "; ++ bufpos = 0; ++ goto again; ++ } ++ ++ /* Success */ ++ if (redir && strcmp(redir, host) == 0) { ++ /* Redirect to self does not count */ ++ free(redir); ++ redir = NULL; ++ } ++ if (!redir) { ++ /* Output saved text */ ++ printf("[%s]\n", host); ++ buf[bufpos] = '\0'; ++ fputs(buf, stdout); ++ } ++ free(buf); ++ return redir; + } + ++static void recursive_query(const char *host, int port, const char *domain) ++{ ++ char *free_me = NULL; ++ char *redir; ++ again: ++ redir = query(host, port, domain); ++ free(free_me); ++ if (redir) { ++ printf("[Redirected to %s]\n", redir); ++ host = free_me = redir; ++ port = 43; ++ goto again; ++ } ++} ++ ++/* One of "big" whois implementations has these options: ++ * ++ * $ whois --help ++ * jwhois version 4.0, Copyright (C) 1999-2007 Free Software Foundation, Inc. ++ * -v, --verbose verbose debug output ++ * -c FILE, --config=FILE use FILE as configuration file ++ * -h HOST, --host=HOST explicitly query HOST ++ * -n, --no-redirect disable content redirection ++ * -s, --no-whoisservers disable whois-servers.net service support ++ * -a, --raw disable reformatting of the query ++ * -i, --display-redirections display all redirects instead of hiding them ++ * -p PORT, --port=PORT use port number PORT (in conjunction with HOST) ++ * -r, --rwhois force an rwhois query to be made ++ * --rwhois-display=DISPLAY sets the display option in rwhois queries ++ * --rwhois-limit=LIMIT sets the maximum number of matches to return ++ * ++ * Example of its output: ++ * $ whois cnn.com ++ * [Querying whois.verisign-grs.com] ++ * [Redirected to whois.corporatedomains.com] ++ * [Querying whois.corporatedomains.com] ++ * [whois.corporatedomains.com] ++ * ...text of the reply... ++ * ++ * With -i, reply from each server is printed, after all redirects are done: ++ * [Querying whois.verisign-grs.com] ++ * [Redirected to whois.corporatedomains.com] ++ * [Querying whois.corporatedomains.com] ++ * [whois.verisign-grs.com] ++ * ...text of the reply... ++ * [whois.corporatedomains.com] ++ * ...text of the reply... ++ * ++ * With -a, no "DOMAIN" -> "domain DOMAIN" transformation is attempted. ++ ++ * With -n, the first reply is shown, redirects are not followed: ++ * [Querying whois.verisign-grs.com] ++ * [whois.verisign-grs.com] ++ * ...text of the reply... ++ */ ++ + int whois_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int whois_main(int argc UNUSED_PARAM, char **argv) + { + int port = 43; +- const char *host = "whois-servers.net"; ++ const char *host = "whois.iana.org"; + + opt_complementary = "-1:p+"; + getopt32(argv, "h:p:", &host, &port); +- + argv += optind; ++ + do { +- int fd = create_and_connect_stream_or_die(host, port); +- fdprintf(fd, "%s\r\n", *argv); +- pipe_out(fd); ++ recursive_query(host, port, *argv); + } + while (*++argv); + +-- +2.9.1 + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index 95499c661e..e72b7441c4 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Natanael Copa pkgname=busybox pkgver=1.25.0 -pkgrel=4 +pkgrel=5 pkgdesc="Size optimized toolbox of many common UNIX utilities" url=http://busybox.net arch="all" @@ -31,6 +31,7 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2 0013-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch 0014-ntpd-respond-only-to-client-and-symmetric-active-pac.patch 0015-diff-add-support-for-no-dereference.patch + 0016-whois-make-it-actually-work.patch acpid.logrotate busyboxconfig @@ -162,6 +163,7 @@ f5cd203e6e7acb8b0296e370621aaf63 0012-gzip-fix-compression-level-bug.-Closes-91 f39e2d23f00d9a94a08d5159bd285ea5 0013-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch bcfa838ecc36ea8f2012a27561d6910d 0014-ntpd-respond-only-to-client-and-symmetric-active-pac.patch 83c0e05df23b2327e6e71fa93e911154 0015-diff-add-support-for-no-dereference.patch +6234d8817d3c0ee9f4c01e83bf6a96c4 0016-whois-make-it-actually-work.patch 4046b78ee6a25259954797d73b94f4bd acpid.logrotate 468cf612bd9e06a60fdf41e88a915270 busyboxconfig 378058009a1d6b1e321617b32b933e28 bbsuid.c @@ -183,6 +185,7 @@ a90db1bb2d84f64982aba785f15871d7e2c73f1e9651536fbdafdca7f0a44bd4 0012-gzip-fix- 30aaba169312101b45ee113cd3daa4ca5bfdee76298cb73c692a890484888e23 0013-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch 0c4d7b8ea3844c0f771361deb52e7553f4cf198d3d591ed476fa43be56107a8e 0014-ntpd-respond-only-to-client-and-symmetric-active-pac.patch cbe87aa26c161892f82cd319222c1a21768eabcd5b706c8b582a988e981aca10 0015-diff-add-support-for-no-dereference.patch +1be53b0d1aa3c3f44bff31e092bc786259c7475de4b24dfaa71e70c50672f421 0016-whois-make-it-actually-work.patch f7cbeb5a5a47395ad30454ce8262abcd3e91c33ef803c2ae31a9258d7142dd48 acpid.logrotate 2d8ab0c6ac5610adaf8fd1c094da32727f23fda69434e1ab9cc115744cfa712b busyboxconfig 52bd2c7c44779f910eedd2fea73ec0de520add400894cc132276587e25c73e39 bbsuid.c @@ -204,6 +207,7 @@ c31cb5b26f3fe6aa1e8c34ff78029de43d0e5a4ea261b38bc4142f80323e36b27ffc7e48e46b649c d7a4ee28e0bf924b372ecb2f8da67f566f3c9e78199d81085e83dfb9fc9f5655fb8d6d904285d09bfee07d5e93b50603ea5f04e37e0feaaf01375170f158b829 0013-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch 1e188dfa8c74c9e01f98edab42271260bf6b181b083ef81b76bd3af34ddbca5884a0fe7c3d0352855d0754015d0c0d8da0f1390f5db808b1237153a183a90681 0014-ntpd-respond-only-to-client-and-symmetric-active-pac.patch e04ebc53049be29e5ac0c90dd789b2d275c10175629787f729c06aa323ef688b2ed266961d4f841bae90d00ff4ee454de48d6b92f84f0e5c8729d6c55d9650cd 0015-diff-add-support-for-no-dereference.patch +09cb1bf25c9442986e7d9816277e75591a2af8ba78117869c5cba35d2e189db351455137e9511cf61788864812056133fc9ec5e204f9eb18ae86c34dd8493ae8 0016-whois-make-it-actually-work.patch dadb4c953ebc755b88ee95c1489feb0c2d352f6e44abc716166024e6eea11ab9d10c84fad62c081775834d205cb04aa1be3c994676c88f4284495c54b9188e8b acpid.logrotate 1820adcd6b8759cf568e4b8fb78b22d8f67e1b33f2252fd05a1edd2d65aa7294769c802fdf50edf102675d0a13f8423727ade40ce5bf741ef95225c86675259c busyboxconfig c1dd56509277c59751907a27f067f1622191ddfd498acfe390d83136d36a41f2bdfc2fd4daf35af77219a66fb00fea20483f34112afd5df2ccd9f36ab548e66f bbsuid.c -- cgit v1.2.3