Skip to contentSkip to conversation

proxy config: Factor out http_proxy_envsettings

PATCH New Ian Jackson 1 participant 4 messages Apr 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 proxy config: Factor out http_proxy_envsettings

No overall functional change, other than slight syntax changes to generated shell runes.

---
 Osstest/TestSupport.pm | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Osstest/TestSupport.pm +16 -6
index 6ca8076..1cc09be 100644
@@ -60,6 +60,7 @@ BEGIN {
 		      target_putfilecontents_root_stash
                       target_put_guest_image target_editfile
                       target_editfile_cancel target_fetchurl
+                      http_proxy_envsettings
                       target_editfile_root target_file_exists
                       target_editfile_kvp_replace
                       target_run_apt
@@ -625,15 +626,13 @@ sub target_cmd_build ($$$$) {
         export CCACHE_PREFIX DISTCC_FALLBACK DISTCC_HOSTS
 END
 
-    my $httpproxy = defined($c{HttpProxy}) ? <<END : "";
-        http_proxy=$c{HttpProxy}
-        export http_proxy
-END
+    my $httpproxy = http_proxy_envsetting($ho);
 
-    target_cmd($ho, <<END.$distcc.$httpproxy.<<END.$script, $timeout);
+    target_cmd($ho, <<END.$distcc.<<END.$script, $timeout);
 	set -xe
         LC_ALL=C; export LC_ALL
         PATH=/usr/lib/ccache:\$PATH:/usr/lib/git-core
+        $httpproxy
 END
         exec </dev/null
         cd $builddir
@@ -1880,12 +1879,23 @@ END
 sub target_fetchurl($$$;$) {
     my ($ho, $url, $path, $timeo) = @_;
     $timeo ||= 2000;
-    my $useproxy = $c{HttpProxy} ? "export http_proxy=$c{HttpProxy};" : "";
+    my $useproxy = http_proxy_envsettings($ho);
     target_cmd_root($ho, <<END, $timeo);
     $useproxy wget --progress=dot:mega -O \Q$path\E \Q$url\E
 END
 }
 
+sub http_proxy_envsettings ($) {
+    # returns sh script fragment ending in ;
+    my ($ho) = @_;
+    my $proxy = $c{HttpProxy};
+    return unless $proxy;
+    my @script;
+    foreach my $var (qw(http_proxy)) {
+        push @script, "http_proxy=$proxy", "export http_proxy";
+    }
+    return (join '; ', @script).';';
+}
 
 sub target_put_guest_image ($$;$) {
     my ($ho, $gho, $default) = @_;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/4 proxy config: Add ability to install MITM TLS cert

We want things like build jobs to be able to download things via https. But we want them to be cached. To this end, we are having our squid treat CONNECT as a request to MITM the TLS connection.

But this means that clients will see squid's cert, not the real one. So placate them by installing the cert on each test box.

(The squid becomes part of the TCB for our coverity upload password, but that is fine.)

---
 Osstest/TestSupport.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)
Osstest/TestSupport.pm +10 -0
index 1cc09be..ac9726c 100644
@@ -2587,6 +2587,7 @@ sub host_install_postboot_complete ($) {
     my ($ho) = @_;
     target_core_dump_setup($ho);
     target_cmd_root($ho, "update-rc.d osstest-confirm-booted start 99 2 .");
+    target_https_mitm_proxy_setup($ho);
 }
 
 sub target_core_dump_setup ($) {
@@ -2607,4 +2608,13 @@ END
 				'/etc/security/limits.d/coredumps.conf');
 }
 
+sub target_https_mitm_proxy_setup ($) {
+    my ($ho) = @_;
+    my $cert = $c{HttpsProxyMITMCert};
+    return unless length $cert;
+    target_putfilecontents_root_stash($ho,30,$cert,
+                  '/usr/local/share/ca-certificates/osstest.crt');
+    target_cmd_root($ho, 'update-ca-certificates', 300);
+}
+
 1;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH 3/4 proxy config: Add MITM cert for Massachusetts

In reply to Ian Jackson
---
 production-config | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
production-config +25 -0
index a95e243..07cf5a6 100644
@@ -140,3 +140,28 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDY+wyHPeVjiqPzmKZxSxA0fxQ8r0zKMN1cYxJrryE6
 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCxArew0DKa3mGE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b80rzwB60Puf/0Sp
+5kx8twY8QvR+JthLS4mfSddDq+W+ZwMbrEpp5E8Le+mdrw4YDkdu9bx47NrWOKqF
+z7Q+WONCq75YAWaa0b1Jp6fqQichNbkCdZY3hvemB7ZI+CFWuirOhzcqrZlS88qu
+iF9W0Oj+0O31ZThNVaINUqfrYO3xIbOwJl6qEcp/cAGvFr7ux3KiAg/Tc69xRn+U
+Heh4kbqOlkE8W5wn+0wiei0sEbgi9zxPVnu1XQY1LBh9zh7gbFt7X9ZKka7YlM4H
++IzRHcZl33kY2aVCNF4c6QIDAQABo1AwTjAdBgNVHQ4EFgQUpkoT3BVZ14oKu6qe
+Tt6aMvZ3sKEwHwYDVR0jBBgwFoAUpkoT3BVZ14oKu6qeTt6aMvZ3sKEwDAYDVR0T
+BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAgKYcfH8ykXgnXJVSv1U7carxV/O/
+Io76jrXi3NtqXSugadzakFEOgjkNAfeOrtmQRAF6JuFhPfhweWvnfYGXV/QrxF7N
+nkCVhvNTsyNM2WDeuBtzj/CBoyk0jBkwxdcG3SLEx/sHKPkTPziFuXcPvITdaP2a
+DC+NgIdL3FmEfzaabbDdrgGRt+/vfvu877atvrX1/B5/NOL+7mXaTR6jzuJRQeXK
+ftnS+ZW/GlbttfovPgFN/FjUioenfS9IS1IBwCJ4d9uHDbgOgL6uhEQ0Iq8Ou68f
+L6qOW4qBJldqxl9VX2RqcJExP0YwrvqmdsdC+xsTmXnOtpUkAYKNrvh7dg==
+-----END CERTIFICATE-----
+END
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH 4/4 proxy config: Set https_proxy too

In reply to Ian Jackson

Clients including curl honour https_proxy (not http_proxy) in the environment for https:// urls.

---
 Osstest/TestSupport.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/TestSupport.pm +1 -1
index ac9726c..4ced6c0 100644
@@ -1891,7 +1891,7 @@ sub http_proxy_envsettings ($) {
     my $proxy = $c{HttpProxy};
     return unless $proxy;
     my @script;
-    foreach my $var (qw(http_proxy)) {
+    foreach my $var (qw(http_proxy https_proxy)) {
         push @script, "http_proxy=$proxy", "export http_proxy";
     }
     return (join '; ', @script).';';
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel