[70982] trunk/base/src

raimue at macports.org raimue at macports.org
Sat Aug 28 18:45:46 PDT 2010


Revision: 70982
          http://trac.macports.org/changeset/70982
Author:   raimue at macports.org
Date:     2010-08-28 18:45:46 -0700 (Sat, 28 Aug 2010)
Log Message:
-----------
distcheck: Use fetch.ignore_sslcert

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/curl.c
    trunk/base/src/port1.0/portdistcheck.tcl

Modified: trunk/base/src/pextlib1.0/curl.c
===================================================================
--- trunk/base/src/pextlib1.0/curl.c	2010-08-29 01:42:38 UTC (rev 70981)
+++ trunk/base/src/pextlib1.0/curl.c	2010-08-29 01:45:46 UTC (rev 70982)
@@ -452,24 +452,52 @@
 	FILE* theFile = NULL;
 
 	do {
+		int optioncrsr;
+		int lastoption;
+		int ignoresslcert = 0;
 		long theResponseCode = 0;
 		const char* theURL;
 		CURLcode theCurlCode;
 		long theModDate;
 		long userModDate;
 
+		optioncrsr = 2;
+		lastoption = objc - 3;
+		while (optioncrsr <= lastoption) {
+			/* get the option */
+			const char* theOption = Tcl_GetString(objv[optioncrsr]);
+
+			if (strcmp(theOption, "--ignore-ssl-cert") == 0) {
+				ignoresslcert = 1;
+			} else {
+				char theErrorString[512];
+				(void) snprintf(theErrorString, sizeof(theErrorString),
+					"curl isnewer: unknown option %s", theOption);
+				Tcl_SetResult(interp, theErrorString, TCL_VOLATILE);
+				theResult = TCL_ERROR;
+				break;
+			}
+
+			optioncrsr++;
+                }
+
+		if (optioncrsr <= lastoption) {
+			/* something went wrong */
+			break;
+		}
+
 		/* first (second) parameter is the url, second (third) parameter is the date */
-		if (objc != 4) {
-			Tcl_WrongNumArgs(interp, 1, objv, "isnewer url date");
+		if (objc < 4 || objc > 5) {
+			Tcl_WrongNumArgs(interp, 1, objv, "isnewer [--ignore-ssl-cert] url date");
 			theResult = TCL_ERROR;
 			break;
 		}
 
 		/* Retrieve the url */
-		theURL = Tcl_GetString(objv[2]);
+		theURL = Tcl_GetString(objv[objc - 2]);
 
 		/* Get the date */
-		theResult = Tcl_GetLongFromObj(interp, objv[3], &userModDate);
+		theResult = Tcl_GetLongFromObj(interp, objv[objc - 1], &userModDate);
 		if (theResult != TCL_OK) {
 			break;
 		}
@@ -548,6 +576,20 @@
 			break;
 		}
 
+		/* we may want to ignore ssl errors */
+		if (ignoresslcert) {
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYPEER, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYHOST, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+		}
+
 		/* save the modification date */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FILETIME, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -647,20 +689,48 @@
 	FILE* theFile = NULL;
 
 	do {
+		int optioncrsr;
+		int lastoption;
+		int ignoresslcert = 0;
 		char theSizeString[32];
 		const char* theURL;
 		CURLcode theCurlCode;
 		double theFileSize;
 
+		optioncrsr = 2;
+		lastoption = objc - 2;
+		while (optioncrsr <= lastoption) {
+			/* get the option */
+			const char* theOption = Tcl_GetString(objv[optioncrsr]);
+
+			if (strcmp(theOption, "--ignore-ssl-cert") == 0) {
+				ignoresslcert = 1;
+			} else {
+				char theErrorString[512];
+				(void) snprintf(theErrorString, sizeof(theErrorString),
+					"curl getsize: unknown option %s", theOption);
+				Tcl_SetResult(interp, theErrorString, TCL_VOLATILE);
+				theResult = TCL_ERROR;
+				break;
+			}
+
+			optioncrsr++;
+                }
+
+		if (optioncrsr <= lastoption) {
+			/* something went wrong */
+			break;
+		}
+
 		/* first (second) parameter is the url */
-		if (objc != 3) {
-			Tcl_WrongNumArgs(interp, 1, objv, "getsize url");
+		if (objc < 3 || objc > 4) {
+			Tcl_WrongNumArgs(interp, 1, objv, "getsize [--ignore-ssl-cert] url");
 			theResult = TCL_ERROR;
 			break;
 		}
 
 		/* Retrieve the url */
-		theURL = Tcl_GetString(objv[2]);
+		theURL = Tcl_GetString(objv[objc - 1]);
 
 		/* Open the file (dev/null) */
 		theFile = fopen( "/dev/null", "a" );
@@ -736,6 +806,20 @@
 			break;
 		}
 
+		/* we may want to ignore ssl errors */
+		if (ignoresslcert) {
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYPEER, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYHOST, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+		}
+
 		/* skip the header data */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_HEADER, 0);
 		if (theCurlCode != CURLE_OK) {

Modified: trunk/base/src/port1.0/portdistcheck.tcl
===================================================================
--- trunk/base/src/port1.0/portdistcheck.tcl	2010-08-29 01:42:38 UTC (rev 70981)
+++ trunk/base/src/port1.0/portdistcheck.tcl	2010-08-29 01:45:46 UTC (rev 70982)
@@ -54,12 +54,18 @@
 proc portdistcheck::distcheck_main {args} {
     global distcheck.check
     global fetch.type
+    global fetch.ignore_sslcert
     global name portpath
 
     set port_moddate [file mtime ${portpath}/Portfile]
 
     ui_debug "Portfile modification date is [clock format $port_moddate]"
 
+    set curl_options {}
+    if [tbool fetch.ignore_sslcert] {
+        lappend curl_options "--ignore-ssl-cert"
+    }
+
     # Check the distfiles if it's a regular fetch phase.
     if {"${distcheck.check}" != "none"
         && "${fetch.type}" == "standard"} {
@@ -80,7 +86,7 @@
                 foreach site $urlmap($url_var) {
                     ui_debug [format [msgcat::mc "Checking %s from %s"] $distfile $site]
                     set file_url [portfetch::assemble_url $site $distfile]
-                    if {[catch {set urlnewer [curl isnewer $file_url $port_moddate]} error]} {
+                    if {[catch {set urlnewer [eval curl isnewer $curl_options {$file_url} $port_moddate]} error]} {
                         ui_warn "couldn't fetch $file_url for $name ($error)"
                     } else {
                         if {$urlnewer} {
@@ -97,7 +103,7 @@
                 foreach site $urlmap($url_var) {
                     ui_debug [format [msgcat::mc "Checking %s from %s"] $distfile $site]
                     set file_url [portfetch::assemble_url $site $distfile]
-                    if {[catch {set urlsize [curl getsize $file_url]} error]} {
+                    if {[catch {set urlsize [eval curl getsize $curl_options {$file_url}]} error]} {
                         ui_warn "couldn't fetch $file_url for $name ($error)"
                     } else {
                         incr count
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100828/8f4e47b8/attachment.html>


More information about the macports-changes mailing list