[99755] trunk/base/src
jmr at macports.org
jmr at macports.org
Fri Nov 16 07:04:27 PST 2012
Revision: 99755
https://trac.macports.org/changeset/99755
Author: jmr at macports.org
Date: 2012-11-16 07:04:27 -0800 (Fri, 16 Nov 2012)
Log Message:
-----------
check if DNS is broken and print a warning before fetching
Modified Paths:
--------------
trunk/base/src/package1.0/portarchivefetch.tcl
trunk/base/src/pextlib1.0/Pextlib.c
trunk/base/src/port1.0/fetch_common.tcl
trunk/base/src/port1.0/portfetch.tcl
Modified: trunk/base/src/package1.0/portarchivefetch.tcl
===================================================================
--- trunk/base/src/package1.0/portarchivefetch.tcl 2012-11-16 13:26:44 UTC (rev 99754)
+++ trunk/base/src/package1.0/portarchivefetch.tcl 2012-11-16 15:04:27 UTC (rev 99755)
@@ -295,6 +295,7 @@
if {[info exists all_archive_files] && [llength $all_archive_files] > 0} {
ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching archive for %s"] $subport]"
}
+ portfetch::check_dns
}
# Main archive fetch routine
Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c 2012-11-16 13:26:44 UTC (rev 99754)
+++ trunk/base/src/pextlib1.0/Pextlib.c 2012-11-16 15:04:27 UTC (rev 99755)
@@ -46,6 +46,7 @@
#include <fcntl.h>
#include <grp.h>
#include <limits.h>
+#include <netdb.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdint.h>
@@ -568,6 +569,34 @@
}
#endif
+/* Check if the configured DNS server(s) incorrectly return a result for
+ a nonexistent hostname. Returns true if broken, false if OK. */
+int CheckBrokenDNSCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED)
+{
+ static int already_checked = 0;
+ Tcl_Obj *tcl_result;
+ int broken = 0;
+ struct addrinfo *res = NULL;
+ int error;
+
+ /* Only do the actual test once per run. */
+ if (!already_checked) {
+ error = getaddrinfo("invalid-host.macports.org", NULL, NULL, &res);
+ if (!error) {
+ broken = 1;
+ }
+ if (res) {
+ freeaddrinfo(res);
+ }
+
+ already_checked = 1;
+ }
+
+ tcl_result = Tcl_NewBooleanObj(broken);
+ Tcl_SetObjResult(interp, tcl_result);
+ return TCL_OK;
+}
+
int Pextlib_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
@@ -630,6 +659,8 @@
Tcl_CreateObjCommand(interp, "isatty", IsattyCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "term_get_size", TermGetSizeCmd, NULL, NULL);
+ Tcl_CreateObjCommand(interp, "check_broken_dns", CheckBrokenDNSCmd, NULL, NULL);
+
if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
return TCL_ERROR;
Modified: trunk/base/src/port1.0/fetch_common.tcl
===================================================================
--- trunk/base/src/port1.0/fetch_common.tcl 2012-11-16 13:26:44 UTC (rev 99754)
+++ trunk/base/src/port1.0/fetch_common.tcl 2012-11-16 15:04:27 UTC (rev 99755)
@@ -339,3 +339,11 @@
return $urls
}
+
+# warn if DNS is broken
+proc portfetch::check_dns {} {
+ # check_broken_dns returns true at most once, so we don't have to worry about spamming this message
+ if {[check_broken_dns]} {
+ ui_warn "Your DNS server(s) incorrectly claim to know the address of nonexistent hosts. This may cause checksum mismatches for some ports."
+ }
+}
Modified: trunk/base/src/port1.0/portfetch.tcl
===================================================================
--- trunk/base/src/port1.0/portfetch.tcl 2012-11-16 13:26:44 UTC (rev 99754)
+++ trunk/base/src/port1.0/portfetch.tcl 2012-11-16 15:04:27 UTC (rev 99755)
@@ -598,6 +598,8 @@
}
}
}
+
+ portfetch::check_dns
}
# Main fetch routine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20121116/213174f4/attachment.html>
More information about the macports-changes
mailing list