[v2] tor.cgi: fix calling Perl location module functions

Message ID 190f0a6c-c334-24d3-28ca-7f732aa0fc85@ipfire.org
State Accepted
Commit 5fe798b52f25a2895dced9e69dafe99491e61b39
Headers
Series [v2] tor.cgi: fix calling Perl location module functions |

Commit Message

Peter Müller Oct. 9, 2020, 7:20 p.m. UTC
  The second version of this patch avoids re-defining $db_handle.

Fixes: #12492

Cc: Stefan Schantl <stefan.schantl@ipfire.org
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 html/cgi-bin/tor.cgi | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Michael Tremer Oct. 10, 2020, 11:46 a.m. UTC | #1
Could anyone please test this and confirm that it works?

> On 9 Oct 2020, at 20:20, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> The second version of this patch avoids re-defining $db_handle.
> 
> Fixes: #12492
> 
> Cc: Stefan Schantl <stefan.schantl@ipfire.org
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
> html/cgi-bin/tor.cgi | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi
> index 28dec6cf0..7447bd791 100644
> --- a/html/cgi-bin/tor.cgi
> +++ b/html/cgi-bin/tor.cgi
> @@ -322,14 +322,13 @@ END
> 					<select name='TOR_EXIT_COUNTRY'>
> 						<option value=''>- $Lang::tr{'tor exit country any'} -</option>
> END
> -
> -		my @country_codes = &Location::database_countries();
> +		my @country_codes = &Location::database_countries($db_handle);
> 		foreach my $country_code (@country_codes) {
> 			# Convert country code into upper case format.
> 			$country_code = uc($country_code);
> 
> 			# Get country name.
> -			my $country_name = &Location::Functions::get_country_name($country_code);
> +			my $country_name = &Location::Functions::get_full_country_name($country_code);
> 
> 			print "<option value='$country_code'";
> 
> -- 
> 2.26.2
  
Adolf Belka Oct. 11, 2020, 12:18 p.m. UTC | #2
Hi Michael,

I installed tor and confirmed that the last part of the tor page was missing.
I then patched the tor.cgi file with Peter's patch and then the whole tor page was now being shown. I was able to enable tor and save and tor was then shown as running.

I can confirm that the patch works.

Regards,
Adolf.

On 10/10/2020 13:46, Michael Tremer wrote:
> Could anyone please test this and confirm that it works?
> 
>> On 9 Oct 2020, at 20:20, Peter Müller <peter.mueller@ipfire.org> wrote:
>>
>> The second version of this patch avoids re-defining $db_handle.
>>
>> Fixes: #12492
>>
>> Cc: Stefan Schantl <stefan.schantl@ipfire.org
>> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
>> ---
>> html/cgi-bin/tor.cgi | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi
>> index 28dec6cf0..7447bd791 100644
>> --- a/html/cgi-bin/tor.cgi
>> +++ b/html/cgi-bin/tor.cgi
>> @@ -322,14 +322,13 @@ END
>> 					<select name='TOR_EXIT_COUNTRY'>
>> 						<option value=''>- $Lang::tr{'tor exit country any'} -</option>
>> END
>> -
>> -		my @country_codes = &Location::database_countries();
>> +		my @country_codes = &Location::database_countries($db_handle);
>> 		foreach my $country_code (@country_codes) {
>> 			# Convert country code into upper case format.
>> 			$country_code = uc($country_code);
>>
>> 			# Get country name.
>> -			my $country_name = &Location::Functions::get_country_name($country_code);
>> +			my $country_name = &Location::Functions::get_full_country_name($country_code);
>>
>> 			print "<option value='$country_code'";
>>
>> -- 
>> 2.26.2
>
  
Stefan Schantl Oct. 11, 2020, 5:39 p.m. UTC | #3
Hello Peter,

very good found and thanks for the patch.

Acked-By: Stefan Schantl <stefan.schantl@ipfire.org>

> The second version of this patch avoids re-defining $db_handle.
> 
> Fixes: #12492
> 
> Cc: Stefan Schantl <stefan.schantl@ipfire.org
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
>  html/cgi-bin/tor.cgi | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi
> index 28dec6cf0..7447bd791 100644
> --- a/html/cgi-bin/tor.cgi
> +++ b/html/cgi-bin/tor.cgi
> @@ -322,14 +322,13 @@ END
>  					<select
> name='TOR_EXIT_COUNTRY'>
>  						<option value=''>-
> $Lang::tr{'tor exit country any'} -</option>
>  END
> -
> -		my @country_codes = &Location::database_countries();
> +		my @country_codes =
> &Location::database_countries($db_handle);
>  		foreach my $country_code (@country_codes) {
>  			# Convert country code into upper case format.
>  			$country_code = uc($country_code);
>  
>  			# Get country name.
> -			my $country_name =
> &Location::Functions::get_country_name($country_code);
> +			my $country_name =
> &Location::Functions::get_full_country_name($country_code);
>  
>  			print "<option value='$country_code'";
>
  
Michael Tremer Oct. 11, 2020, 5:42 p.m. UTC | #4
Hi Stefan,

Did you see that the same problem exists for the firewall rule pages?

-Michael

> On 11 Oct 2020, at 18:39, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> Hello Peter,
> 
> very good found and thanks for the patch.
> 
> Acked-By: Stefan Schantl <stefan.schantl@ipfire.org>
> 
>> The second version of this patch avoids re-defining $db_handle.
>> 
>> Fixes: #12492
>> 
>> Cc: Stefan Schantl <stefan.schantl@ipfire.org
>> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
>> ---
>> html/cgi-bin/tor.cgi | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi
>> index 28dec6cf0..7447bd791 100644
>> --- a/html/cgi-bin/tor.cgi
>> +++ b/html/cgi-bin/tor.cgi
>> @@ -322,14 +322,13 @@ END
>> 					<select
>> name='TOR_EXIT_COUNTRY'>
>> 						<option value=''>-
>> $Lang::tr{'tor exit country any'} -</option>
>> END
>> -
>> -		my @country_codes = &Location::database_countries();
>> +		my @country_codes =
>> &Location::database_countries($db_handle);
>> 		foreach my $country_code (@country_codes) {
>> 			# Convert country code into upper case format.
>> 			$country_code = uc($country_code);
>> 
>> 			# Get country name.
>> -			my $country_name =
>> &Location::Functions::get_country_name($country_code);
>> +			my $country_name =
>> &Location::Functions::get_full_country_name($country_code);
>> 
>> 			print "<option value='$country_code'";
>> 
>
  

Patch

diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi
index 28dec6cf0..7447bd791 100644
--- a/html/cgi-bin/tor.cgi
+++ b/html/cgi-bin/tor.cgi
@@ -322,14 +322,13 @@  END
 					<select name='TOR_EXIT_COUNTRY'>
 						<option value=''>- $Lang::tr{'tor exit country any'} -</option>
 END
-
-		my @country_codes = &Location::database_countries();
+		my @country_codes = &Location::database_countries($db_handle);
 		foreach my $country_code (@country_codes) {
 			# Convert country code into upper case format.
 			$country_code = uc($country_code);
 
 			# Get country name.
-			my $country_name = &Location::Functions::get_country_name($country_code);
+			my $country_name = &Location::Functions::get_full_country_name($country_code);
 
 			print "<option value='$country_code'";