Date: Thu, 28 Mar 2002 23:56:21 -0500 (EST) From: Jason Harris <jharris@widomaker.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Makoto MATSUSHITA <matusita@FreeBSD.org>, Jason Harris <jharris@widomaker.com> Subject: ports/36463: ports/net/jwhois - chase CVS version for new domains Message-ID: <200203290456.g2T4uL818797@pm6-10.lft.widomaker.com>
next in thread | raw e-mail | index | archive | help
>Number: 36463 >Category: ports >Synopsis: ports/net/jwhois - chase CVS version for new domains >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Thu Mar 28 21:00:08 PST 2002 >Closed-Date: >Last-Modified: >Originator: Jason Harris >Release: FreeBSD 4.3-RELEASE i386 >Organization: none here >Environment: System: FreeBSD 4.3-RELEASE i386 >Description: Update jwhois to gain features from a recent CVS version: direct lookup of .edu domains new domains: .gt .hr. .sa .tt .name .coop updated domains: .mt .int .us >How-To-Repeat: With the maintainer's approval, _bump PORTREVISION_ and apply the following patch below _in place of_ files/patch-3.1.0-fix. (The patch was created with: cvs diff -l -u -r jwhois_3_1_0 -D "2002-03-29 02:00 UTC" AUTHORS \ ChangeLog example/jwhois.conf src v. grabbing a fleeting tarball.) >Fix: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NotDashEscaped: You need GnuPG to verify this message Index: AUTHORS =================================================================== RCS file: /cvsroot/jwhois/jwhois/AUTHORS,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AUTHORS 25 Sep 2001 20:14:45 -0000 1.6 +++ AUTHORS 20 Mar 2002 18:45:35 -0000 1.7 @@ -1,3 +1,2 @@ jwhois is written and maintained by Jonas Öberg <jonas@gnu.org> -Debian packaging, some modifications and HTTP support by Peter -Karlsson <peterk@debian.org> +and Peter Karlsson <peterk@debian.org> Index: ChangeLog =================================================================== RCS file: /cvsroot/jwhois/jwhois/ChangeLog,v retrieving revision 1.94 retrieving revision 1.107 diff -u -r1.94 -r1.107 --- ChangeLog 9 Jan 2002 18:50:00 -0000 1.94 +++ ChangeLog 28 Mar 2002 12:56:16 -0000 1.107 @@ -1,3 +1,69 @@ +2002-03-28 peter karlsson <peter@softwolves.pp.se> + + * examples/jwhois.conf: Added .edu. + (Lee Maguire, Debian bug#140279) + +2002-03-25 peter karlsson <peter@softwolves.pp.se> + + * examples/jwhois.conf: Added .gt. + (Lee Maguire, Debian bug#139877) + +2002-03-21 peter karlsson <peter@softwolves.pp.se> + + * configure.in, po/id.po: Added Indonesian translation from TP. + +2002-03-20 peter karlsson <peter@softwolves.pp.se> + + * src/http.c, examples/jwhois.conf: Advanced queries for http. + * src/lookup.c: Bugfix for advanced queries. + +2002-03-19 peter karlsson <peter@softwolves.pp.se> + + * src/lookup.c: Added code to split domain name for advanced + queries. + * src/jwhois.c: Fix a memory leak. + * examples/jwhois.conf: Updated .mt data. + (Lee Maguire, Debian bug#138488) + +2002-02-04 Jonas Oberg <jonas@gnu.org> + + * src/rwhois.c (rwhois_parse_line): Fix %info + (rwhois_query_internal): Check for correct return values from + rwhois_read_line + +2002-03-07 peter karlsson <peter@softwolves.pp.se> + + * examples/jwhois.conf: Added .tt data. + (Lee Maguire, Debian bug#137088) + +2002-03-03 peter karlsson <peter@softwolves.pp.se> + + * example/jwhois.conf: Fixed incorrect .dk data. + (Klaus Alexander Seistrup, Debian bug#129018) + +2002-02-28 peter karlsson <peter@softwolves.pp.se> + + * example/jwhois.conf: Updated .int and .us data. + (Lee Maguire, Debian bug#136200) + +2002-02-11 peter karlsson <peter@softwolves.pp.se> + + * example/jwhois.conf: Added .name and .coop data. + (Lee Maguire, Debian bug#133429) + +2002-02-06 peter karlsson <peter@softwolves.pp.se> + + * src/rwhois.c: Applied fix for segmentation fault on certain rwhois + servers. (Colin Phipps, Debian bug#132607) + +2002-01-13 Jonas Oberg <jonas@gnu.org> + + * example/jwhois.conf: Updated .dk definition + +2002-01-12 peter karlsson <peter@softwolves.pp.se> + + * po/sv.po: Some brush-ups to the translation. + 2002-01-09 Jonas Oberg <jonas@gnu.org> * Released 3.1.0 Index: example/jwhois.conf =================================================================== RCS file: /cvsroot/jwhois/jwhois/example/jwhois.conf,v retrieving revision 1.54 retrieving revision 1.63 diff -u -r1.54 -r1.63 --- example/jwhois.conf 8 Dec 2001 17:34:25 -0000 1.54 +++ example/jwhois.conf 28 Mar 2002 12:56:16 -0000 1.63 @@ -77,6 +77,7 @@ "\\.cl$" = "whois.nic.cl"; "\\.edu\\.cn$" = "whois.edu.cn"; "\\.cn$" = "whois.cnnic.net.cn"; + "\\.coop$" = "whois.nic.coop"; "\\.cx$" = "whois.nic.cx"; "\\.cy$" = "whois.ripe.net"; "\\.cz$" = "whois.nic.cz"; @@ -84,6 +85,7 @@ "\\.dk$" = "www.dk-hostmaster.dk"; "\\.do$" = "whois.nic.do"; "\\.dz$" = "whois.ripe.net"; + "\\.edu$" = "whois.educause.net"; "\\.ee$" = "whois.ripe.net"; "\\.eg$" = "whois.ripe.net"; "\\.es$" = "www.nic.es"; @@ -97,16 +99,16 @@ "\\.gm$" = "whois.ripe.net"; "\\.gr$" = "whois.ripe.net"; "\\.gs$" = "whois.adamsnames.tc"; + "\\.gt$" = "www.gt"; "\\.hk$" = "whois.hkdnr.net.hk"; "\\.hm$" = "whois.registry.hm"; - "\\.hr$" = "whois.ripe.net"; - "\\.hu$" = "whois.nic.hu"; + "\\.hr$" = "www.dns.hr"; "\\.id$" = "whois.idnic.net.id"; "\\.ie$" = "whois.domainregistry.ie"; "\\.il$" = "whois.isoc.org.il"; "\\.in$" = "whois.ncst.ernet.in"; "\\.info$" = "whois.afilias.info"; - "\\.int$" = "whois.isi.edu"; + "\\.int$" = "whois.iana.org"; "\\.is$" = "whois.isnet.is"; "\\.it$" = "whois.nic.it"; "\\.je$" = "whois.isles.net"; @@ -128,10 +130,11 @@ "\\.mk$" = "whois.ripe.net"; "\\.mm$" = "whois.nic.mm"; "\\.ms$" = "whois.adamsnames.tc"; - "\\.mt$" = "whois.ripe.net"; + "\\.mt$" = "www.um.edu.mt"; "\\.museum$" = "whois.museum"; "\\.mx$" = "whois.nic.mx"; "\\.my$" = "whois.mynic.net"; + "\\.name$" = "whois.nic.name"; "\\.ng$" = "pgebrehiwot.iat.cnr.it"; "\\.nl$" = "whois.domain-registry.nl"; "\\.no$" = "whois.norid.no"; @@ -144,6 +147,7 @@ "\\.pw$" = "whois.nic.pw"; "\\.ro$" = "whois.rotld.ro"; "\\.ru$" = "whois.ripn.net"; + "\\.sa$" = "www.saudinic.net.sa"; "\\.se$" = "www.nic-se.se"; # "whois.nic-se.se"; "\\.sg$" = "whois.nic.net.sg"; "\\.sh$" = "whois.nic.sh"; @@ -161,12 +165,13 @@ "\\.tn$" = "whois.ripe.net"; "\\.to$" = "whois.tonic.to"; "\\.tr$" = "whois.metu.edu.tr"; + "\\.tt$" = "www.nic.tt"; "\\.tw$" = "whois.twnic.net"; "\\.ua$" = "whois.ripe.net"; "\\.ac\\.uk$" = "whois.ja.net"; "\\.gov\\.uk$" = "whois.ja.net"; "\\.uk$" = "whois.nic.uk"; - "\\.us$" = "whois.isi.edu"; + "\\.us$" = "whois.nic.us"; "\\.va$" = "whois.ripe.net"; "\\.ve$" = "rwhois.nic.ve 4321"; "\\.vg$" = "whois.adamsnames.tc"; @@ -391,8 +396,9 @@ "www\\.dk-hostmaster\\.dk" { http = "true"; http-method = "GET"; - http-action = "/perl/Whois.pl"; + http-action = "/script/whois.php"; form-element = "query"; + form-extra = "lang=eng"; } "www\\.nic\\.es" { @@ -401,6 +407,43 @@ http-action = "/cgi-bin/consulta.whois"; form-element = "key"; form-extra = "list=Dominios&tipo=procesar"; # Other <input> elements + } + + "www\\.nic\\.tt" { + http = "true"; + http-method = "POST"; + http-action = "/cgi-bin/search.pl"; + form-element = "name"; + } + + "www\\.um\\.edu\\.mt" { + http = "true"; + http-method = "GET"; + http-action = "/cgi-bin/nic/whois"; + form-element = "domain"; + } + + "www\\.gt" { + http = "true"; + http-method = "GET"; + http-action = "/cgi-bin/whois.cgi"; + form-element = "domain"; + } + + # This uses an advanced query using the query-format syntax. + # query-format cannot be combined with form-element or form-extra. + "www\\.dns\\.hr" { + http = "true"; + http-method = "POST"; + http-action = "/asp/trazidomenu.asp"; + query-format = "Upit=${+2}"; # All but last domain segment + } + + "www\\.saudinic\\.net\\.sa" { + http = "true"; + http-method = "GET"; + http-action = "/cgi-bin/whois.cgi"; + query-format = "Domain=${+3}&Level=.${2+1}"; } } Index: src/dns.c =================================================================== RCS file: /cvsroot/jwhois/jwhois/src/dns.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- src/dns.c 5 Jan 2002 23:41:30 -0000 1.9 +++ src/dns.c 18 Mar 2002 09:58:42 -0000 1.10 @@ -72,6 +72,8 @@ res->sin_port = htons(IPPORT_WHOIS); else res->sin_port = sp->s_port; + } else { + res->sin_port = htons(port); } #ifdef HAVE_INET_ATON Index: src/http.c =================================================================== RCS file: /cvsroot/jwhois/jwhois/src/http.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- src/http.c 5 Jan 2002 23:41:30 -0000 1.12 +++ src/http.c 22 Mar 2002 16:26:34 -0000 1.13 @@ -32,6 +32,7 @@ #include <whois.h> #include <http.h> #include <utils.h> +#include <lookup.h> #ifdef ENABLE_NLS # include <libintl.h> @@ -52,6 +53,7 @@ const char *action = get_whois_server_option(wq->host, "http-action"); const char *element= get_whois_server_option(wq->host, "form-element"); const char *extra = get_whois_server_option(wq->host, "form-extra"); + const char *format = get_whois_server_option(wq->host, "query-format"); char **command; char *url; char *browser; @@ -62,12 +64,12 @@ struct jconfig *j; /* Check host configuration */ - if (!method || !action || !element) + if (!method || !action || !(element || format)) { printf("[HTTP: %s: %s]\n", wq->host, _("HTTP configuration is incomplete:")); - if (!method) printf("[HTTP: %s: %s]\n", _("Option is missing:"), "http-method"); - if (!action) printf("[HTTP: %s: %s]\n", _("Option is missing:"), "http-action"); - if (!element) printf("[HTTP: %s: %s]\n", _("Option is missing:"), "form-element"); + if (!method) printf("[HTTP: %s %s]\n", _("Option is missing:"), "http-method"); + if (!action) printf("[HTTP: %s %s]\n", _("Option is missing:"), "http-action"); + if (!element && !format) printf("[HTTP: %s %s]\n", _("Option is missing:"), "form-element"); return -1; } @@ -111,14 +113,29 @@ command[1] = command[0]; command[2] = browser_arg; - command[3] = (char *) malloc(strlen("http://") + strlen(wq->host) + - strlen(action) + 1 + strlen(element) + 1 + - strlen(wq->query) + - (extra ? strlen(extra) + 1 : 0) + 1); - if (!command[3]) return -1; - sprintf(command[3], "http://%s%s?%s=%s%s%s", - wq->host, action, element, wq->query, - extra ? "&" : "", extra ? extra : ""); + if (format) + { + /* Query already formatted */ + command[3] = (char *) malloc(strlen("http://") + strlen(wq->host) + + strlen(action) + 1 + + strlen(wq->query) + 1); + if (!command[3]) return -1; + sprintf(command[3], "http://%s%s?%s", + wq->host, action, wq->query); + } + else + { + /* Format query using supplied data */ + command[3] = (char *) malloc(strlen("http://") + strlen(wq->host) + + strlen(action) + 1 + + strlen(element) + 1 + + strlen(wq->query) + + (extra ? strlen(extra) + 1 : 0) + 1); + if (!command[3]) return -1; + sprintf(command[3], "http://%s%s?%s=%s%s%s", + wq->host, action, element, wq->query, + extra ? "&" : "", extra ? extra : ""); + } command[4] = NULL; url = command[3]; @@ -153,7 +170,7 @@ url = command[4]; } - if (verbose>1) + if (verbose > 1) { int i; @@ -212,9 +229,19 @@ if (!isget) { /* Send POST data */ - sprintf(data, "%s=%s%s%s\n---\n", - element, wq->query, - extra ? "&" : "", extra ? extra : ""); + if (format) + { + /* Query already formatted */ + snprintf(data, MAXBUFSIZE, "%s\n---\n", + wq->query); + } + else + { + /* Format query using supplied data */ + snprintf(data, MAXBUFSIZE, "%s=%s%s%s\n---\n", + element, wq->query, + extra ? "&" : "", extra ? extra : ""); + } write(to_browser[1], data, strlen(data) + 1); } Index: src/jwhois.c =================================================================== RCS file: /cvsroot/jwhois/jwhois/src/jwhois.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- src/jwhois.c 5 Jan 2002 23:41:30 -0000 1.42 +++ src/jwhois.c 22 Mar 2002 16:26:34 -0000 1.43 @@ -214,7 +214,11 @@ exit(1); } if (ret > 0) - return jwhois_query(wq, text); + { + int rc = jwhois_query(wq, text); + free(wq->query); + return rc; + } else return 0; } Index: src/lookup.c =================================================================== RCS file: /cvsroot/jwhois/jwhois/src/lookup.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- src/lookup.c 9 Jan 2002 17:53:59 -0000 1.30 +++ src/lookup.c 22 Mar 2002 16:26:34 -0000 1.31 @@ -471,39 +471,223 @@ } } +/* Utility function for lookup_query_format; inserts a string into + * the allocated buffer, growing it if needed. + */ +static void +add_string(char **bufpos, const char *string, size_t stringlen, char **bufstart, size_t *buflen) +{ + /* Check if string needs to be enlarged */ + if ((*bufpos - *bufstart) + stringlen > *buflen) + { + char *new = realloc(*bufstart, *buflen * 2); + if (!new) + { + printf("[%s]\n", _("Error allocating memory")); + exit(1); + } + *buflen *= 2; + *bufpos = new + (*bufpos - *bufstart); + *bufstart = new; + } + + /* Copy string */ + strncpy(*bufpos, string, stringlen); + *bufpos += stringlen; +} + +/* Utility function for lookup_query_format; selects the parts of the + * domain to add into the query string and calls add_string with it. + */ +static void +add_part(char **bufpos, const char *string, size_t begin, size_t end, char **bufstart, size_t *buflen) +{ + size_t count = 1; + const char *first = string, *last = string, *p; + + /* Find begin of first section to copy */ + while (count < begin) + { + first = strchr(first, '.'); + if (!first) + return; + count ++; + first ++; + if (!*first) + return; + last = first; + } + + /* Find begin of last section to copy */ + while (count < end) + { + last = strchr(last, '.'); + if (!last) + break; + count ++; + last ++; + if (!*last) + break; + } + + /* Find end of last section to copy */ + if (last) + { + p = strchr(last, '.'); + if (p) + last = p; + else + last = last + strlen(last); + } + else + last = string + strlen(string); + + /* Copy */ + add_string(bufpos, first, last - first, bufstart, buflen); +} + /* * This function looks into the query-format configuration and tries * to find out if we need any special considerations for the host we're * querying. If so, it returns the proper string for the query. If not, - * it simply returns qstring. + * it simply returns a copy of qstring. */ char * lookup_query_format(struct s_whois_query *wq) { char *ret = NULL, *tmpqstring, *tmpptr; struct jconfig *j = NULL; + size_t buflen, bufused, dots; if (wq->domain) j = jconfig_getone(wq->domain, "query-format"); if (!j) { - ret = (char *)get_whois_server_option(wq->host, "query-format"); + ret = get_whois_server_option(wq->host, "query-format"); if (!ret) - return wq->query; + return strdup(wq->query); } else { ret = j->value; } - tmpqstring = malloc(strlen(wq->query)+strlen(ret)+2); - strncpy(tmpqstring, ret, strlen(ret)+1); - tmpptr = (char *)strstr(tmpqstring, "$*"); - if (!tmpptr) - return wq->query; + /* Count number of dots in domain name */ + dots = 0; + tmpptr = wq->query; + while (NULL != (tmpptr = strchr(tmpptr, '.'))) + { + dots ++; + tmpptr ++; + } + + /* Allocate a buffer to work in, we grow it when needed */ + buflen = strlen(ret) + strlen(wq->query) * 5; + tmpqstring = malloc(buflen); + if (!tmpqstring) + { + printf("[%s]\n", _("Error allocating memory")); + exit(1); + } + tmpptr = tmpqstring; + + while (*ret) + { + /* Copy verbatim data */ + const char *dollar = strchr(ret, '$'); + size_t chars = dollar ? (dollar - ret) : strlen(ret); + if (chars) + add_string(&tmpptr, ret, chars, &tmpqstring, &buflen); + ret += chars; + + /* Handle parameter */ + if ('$' == *ret) + { + ret ++; + switch (*ret) + { + case '*': /* Entire hostname */ + add_string(&tmpptr, wq->query, strlen(wq->query) - 1, &tmpqstring, &buflen); + ret ++; + break; + + case '{': /* Field range */ + { + size_t startfield = 0, endfield = 0; + int right = 0; + char *p; + ret ++; + + /* Parse start field */ + if (isdigit((unsigned char) *ret)) + { + startfield = strtol(ret, &p, 10); + if (*p) ret = p; + } + + /* Check direction to count from */ + if ('+' == *ret) + right = 1; + + /* Check if range */ + if ('+' == *ret || '-' == *ret) + ret ++; + else + endfield = startfield; + + /* Parse end field */ + if (isdigit((unsigned char) *ret)) + { + endfield = strtol(ret, &p, 10); + if (*p) ret = p; + } + + /* End parsing */ + if ('}' == *ret) + { + ret ++; + /* Calculate field numbers */ + if (right) + { + if (startfield) + { + startfield = dots + 2 - startfield; + if (startfield < 0) + startfield = 1; + } + if (endfield) + endfield = dots + 2 - endfield; + } + + if (startfield && !endfield) + { + endfield = dots + 1; + } + + if (!startfield && endfield) + { + startfield = 1; + } + + /* Add fields if we have a valid range */ + if ((startfield || endfield) && startfield <= endfield) + { + add_part(&tmpptr, wq->query, startfield, endfield, &tmpqstring, &buflen); + } + } + break; + } + + case '$': /* Literal */ + add_string(&tmpptr, "$", 1, &tmpqstring, &buflen); + ret ++; + break; + } + } + } - strncpy(tmpptr, wq->query, strlen(wq->query)+1); - strncat(tmpptr, strstr(ret, "$*")+2, strlen((char *)strstr(ret, "$*"))-1); + /* Null-terminate */ + add_string(&tmpptr, "", 1, &tmpqstring, &buflen); return tmpqstring; } Index: src/rwhois.c =================================================================== RCS file: /cvsroot/jwhois/jwhois/src/rwhois.c,v retrieving revision 1.11 retrieving revision 1.13 diff -u -r1.11 -r1.13 --- src/rwhois.c 5 Jan 2002 23:41:30 -0000 1.11 +++ src/rwhois.c 18 Mar 2002 09:58:42 -0000 1.13 @@ -133,7 +133,7 @@ info_on = 0; sockfd = make_connect(wq->host, wq->port); - if (!sockfd) + if (sockfd < 0) { printf(_("[Unable to connect to remote host]\n")); return -1; @@ -153,7 +153,7 @@ { ret = rwhois_read_line(f, reply, text); } - while (ret != REP_OK && ret != REP_ERROR); + while (ret != REP_INIT && ret != REP_ERROR && ret != REP_OK); if (ret == REP_ERROR) printf(_("[RWHOIS: Protocol error while sending -rwhois option]\n")); @@ -400,7 +400,9 @@ exit(1); } - fgets(ptr, MAXBUFSIZE-1, f); + if (!fgets(ptr, MAXBUFSIZE-1, f)) + return REP_ERROR; + if (!ptr) { return REP_ERROR; @@ -414,22 +416,24 @@ int rwhois_parse_line(const char *reply, char **text) { - char *capab, *tmpptr; + char *tmpptr; tmpptr = (char *)strchr(reply, '\n'); if (tmpptr) *tmpptr = '\0'; - if (info_on) + if (info_on && strncasecmp(reply, "%info", 5) != 0) { add_text_to_buffer(text, create_string("%s\n", reply)); return REP_CONT; } + if (strncasecmp(reply, "%rwhois", 7) == 0) { - capab = (char *)strchr(reply, ':')+1; + char *capab = (char *)strchr(reply, ':'); if (!capab) return REP_ERROR; + capab++; /* skip past first : */ tmpptr = (char *)strchr(capab, ':'); if (!tmpptr) return REP_ERROR; -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE8o+ziSypIl9OdoOMRArztAKDRdpApZITPOLDgsfPIP7nkjsuYbwCfQ9uM DTb0ojE/Sn1lxh0/S5Gw4m0= =82bj -----END PGP SIGNATURE----- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203290456.g2T4uL818797>