Changeset 31877
- Timestamp:
- 2017-08-11T17:07:44+12:00 (6 years ago)
- Location:
- main/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/download/DownloadJob.java
r31865 r31877 619 619 620 620 String [] env = null; 621 622 if (Utility.isWindows()) { 623 prcs = new SafeProcess(cmd); 624 } 625 else { 621 626 622 if (proxy_url != null && !proxy_url.equals("")) { 627 623 // Specify proxies as environment variables 628 624 // Need to manually specify GSDLHOME and GSDLOS also 629 env = new String[6]; 630 proxy_url = proxy_url.replaceAll("http://",""); 631 env[0] = "http_proxy=http://"+proxy_url; 632 env[1] = "https_proxy=http://"+proxy_url; // HTTP protocol for https:// too 633 // see also https://wiki.archlinux.org/index.php/proxy_settings 634 env[2] = "ftp_proxy=ftp://"+proxy_url; 625 626 proxy_url = proxy_url.replaceAll("http://",""); 627 628 env = new String[7]; 629 630 env[0] = "http_proxy=http://"+proxy_url; 631 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 632 // see also https://wiki.archlinux.org/index.php/proxy_settings 633 env[2] = "ftp_proxy=ftp://"+proxy_url; 635 634 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 636 635 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 637 636 env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 637 // If PATH is not made available, so that Perl is not on the PATH, then WgetDownload.pm's open3() call 638 // to run wget fails with cryptic failure message. So make PATH available for open3(): 639 env[6] = "PATH="+System.getenv("PATH"); 640 638 641 prcs = new SafeProcess(cmd, env, null); 639 642 } 640 else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled ) {643 else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) { 641 644 // Not Windows, but running client with download panel 642 645 // Need to manually specify GSDLHOME and GSDLOS … … 651 654 prcs = new SafeProcess(cmd); 652 655 } 653 } 656 654 657 //System.out.println(newcmd); 655 658 prcs.setMainHandler(this); // attach handler to clean up before and after process.destroy() -
main/trunk/gli/src/org/greenstone/gatherer/download/ServerInfoDialog.java
r31860 r31877 104 104 String[] command = (String[]) commands.toArray(new String[0]); 105 105 DebugStream.println("Getting server info: "+commands); 106 try { 107 String [] env = null; 106 try { 108 107 SafeProcess prcs = null; 109 108 110 if (Utility.isWindows()) { 111 prcs = new SafeProcess(command); 112 } 113 else { 114 if (proxy_url != null && !proxy_url.equals("")) { 109 if (proxy_url != null && !proxy_url.equals("")) { 115 110 // Specify proxies as environment variables 116 111 // Need to manually specify GSDLHOME and GSDLOS also 117 env = new String[6]; 118 proxy_url = proxy_url.replaceAll("http://",""); 119 env[0] = "http_proxy=http://"+proxy_url; 120 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 112 113 proxy_url = proxy_url.replaceAll("http://",""); 114 115 String [] env = new String[7]; 116 117 env[0] = "http_proxy=http://"+proxy_url; 118 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 121 119 // see also https://wiki.archlinux.org/index.php/proxy_settings 122 120 env[2] = "ftp_proxy=ftp://"+proxy_url; 123 121 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 124 122 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 125 123 env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 124 // If PATH is not made available, so that Perl is not on the PATH, then WgetDownload.pm's open3() call 125 // to run wget fails with cryptic failure message. So make PATH available for open3(): 126 env[6] = "PATH="+System.getenv("PATH"); 127 126 128 prcs = new SafeProcess(command, env, null); 127 129 } … … 130 132 prcs = new SafeProcess(command); 131 133 } 132 }133 134 134 135 // special processing of Process' stderr stream: -
main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java
r31864 r31877 780 780 781 781 // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the following can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this 782 if (Utility.isWindows()) {782 /*if (Utility.isWindows()) { 783 783 784 784 arg = current_download.getArgument("user_name"); … … 790 790 arg.setAssigned(true); 791 791 } 792 else{ 792 793 else{*/ 793 794 String user_name = user_pass.substring(0, user_pass.indexOf("@")); 794 795 String user_pwd = user_pass.substring(user_pass.indexOf("@") + 1); 795 796 proxy_url = user_name+":"+user_pwd+"@"+proxy_host+":"+proxy_port+"/"; 796 797 797 }798 /*}*/ 798 799 799 800 return true; -
main/trunk/greenstone2/perllib/downloaders/WebDownload.pm
r31864 r31877 193 193 my $strBaseCMD = $strOptions." --tries=2 -q -O - \"$self->{'url'}\""; 194 194 195 #&util::print_env(STDERR, "https_proxy", "http_proxy", "HTTPS_PROXY", "HTTP_PROXY", "ftp_proxy", "FTP_PROXY"); 196 #&util::print_env(STDERR); 197 195 198 my $strIdentifyText = $self->useWget($strBaseCMD); 196 199 -
main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm
r31874 r31877 165 165 } 166 166 167 sub getWgetOptions 168 { 169 my ($self) = @_; 170 my $strOptions = ""; 171 172 # If http_proxy ENV VARS are not set, but proxy Perl vars are set, then we're on Windows 173 # and need to use the proxy vars as flags to wget 174 # If http_proxy Env Vars are set, then we're on Linux, wget will use the http(s) proxy 175 # env vars and we shouldn't be passing any proxy perl vars as flags 176 177 # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 178 # http://www.perlmonks.org/?node=what%20is%20true%20and%20false%20in%20Perl%3F 179 180 if (!$ENV{'http_proxy'} && !$ENV{'https_proxy'}) { 167 # Not using this. On Windows, we used to pass proxying settings as flags to wget. But, as that can be 168 # seen with Task Manager, we now have the proxy settings set in the environment and are no longer passing it 169 sub addProxySettingsAsWgetFlags 170 { 171 my ($self) = @_; 172 my $strOptions = ""; 173 181 174 if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 182 175 { … … 193 186 $strOptions .= " --proxy "; 194 187 } 195 } 196 197 if($self->{'no_check_certificate'}) { #&& $self->{'url'} =~ m/^https\:/) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http 188 189 return $strOptions; 190 } 191 192 sub getWgetOptions 193 { 194 my ($self) = @_; 195 my $strOptions = ""; 196 197 # If proxy settings are set up in the environment, wget is ready to use them. More secure. 198 # But if proxy settings are not set up in the environment, pass them as flags to wget 199 # This is less secure, as pwd etc visible in task manager, but it was the original way in 200 # which wget was run on windows. 201 # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 202 # http://www.perlmonks.org/?node=what%20is%20true%20and%20false%20in%20Perl%3F 203 204 if (!$ENV{'http_proxy'} && !$ENV{'https_proxy'}) { 205 $strOptions .= $self->addProxySettingsAsWgetFlags(); 206 } # else wget will use proxy settings in environment, assume enough settings have been provided 207 208 if($self->{'no_check_certificate'}) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http 198 209 199 210 $strOptions .= " --no-check-certificate ";
Note:
See TracChangeset
for help on using the changeset viewer.