[v2,1/2] mail.cgi: add support for implicit TLS usage

Message ID 2a6c0c35-df5a-5b9b-1117-ba533448a51f@ipfire.org
State Accepted
Commit d07286de4633212dea8cf21253314d007ac36825
Headers
Series [v2,1/2] mail.cgi: add support for implicit TLS usage |

Commit Message

Peter Müller Feb. 3, 2020, 6:35 p.m. UTC
  The second version of this patchset fixes reading empty configuration
files and superseds the first version (duh!).

Fixes #12161

Reported-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 html/cgi-bin/mail.cgi | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
  

Comments

Michael Tremer Feb. 4, 2020, 10:22 a.m. UTC | #1
Hello Peter,

This works now. Thank you very much.

-Michael

Tested-by: Michael Tremer <michael.tremer@ipfire.org>

> On 3 Feb 2020, at 18:35, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> The second version of this patchset fixes reading empty configuration
> files and superseds the first version (duh!).
> 
> Fixes #12161
> 
> Reported-by: Michael Tremer <michael.tremer@ipfire.org>
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
> html/cgi-bin/mail.cgi | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/html/cgi-bin/mail.cgi b/html/cgi-bin/mail.cgi
> index 25589046e..7865a1da6 100755
> --- a/html/cgi-bin/mail.cgi
> +++ b/html/cgi-bin/mail.cgi
> @@ -2,7 +2,7 @@
> ###############################################################################
> #                                                                             #
> # IPFire.org - A linux based firewall                                         #
> -# Copyright (C) 2015  IPFire Team  <alexander.marx@ipfire.org>                #
> +# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
> #                                                                             #
> # This program is free software: you can redistribute it and/or modify        #
> # it under the terms of the GNU General Public License as published by        #
> @@ -110,8 +110,8 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ #SaveButton on configsite
> 
> 		$dma{'SMARTHOST'}		= $cgiparams{'txt_mailserver'};
> 		$dma{'PORT'}			= $cgiparams{'txt_mailport'};
> -		$dma{'STARTTLS'}		= '' if ($cgiparams{'mail_tls'});
> -		$dma{'SECURETRANSFER'}	= '' if exists $dma{'STARTTLS'};
> +		$dma{'STARTTLS'}		= '' if ($cgiparams{'mail_tls'} eq 'explicit');
> +		$dma{'SECURETRANSFER'}	= '' if ($cgiparams{'mail_tls'} eq 'explicit' || $cgiparams{'mail_tls'} eq 'implicit');
> 		$dma{'SPOOLDIR'}		= "/var/spool/dma";
> 		$dma{'FULLBOUNCE'}		= '';
> 		$dma{'MAILNAME'}		= "$mainsettings{'HOSTNAME'}.$mainsettings{DOMAINNAME}";
> @@ -140,8 +140,6 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'email testmail'}"){ #Testmail button on
> 
> #FUNCTIONS
> sub configsite{
> -	
> -
> 	#If update set fieldvalues new
> 	if($cgiparams{'update'} eq 'on'){
> 		$mail{'USEMAIL'}	= 'on';
> @@ -156,7 +154,9 @@ sub configsite{
> 	}
> 	#find preselections
> 	$checked{'usemail'}{$mail{'USEMAIL'}}	= 'CHECKED';
> -	$checked{'mail_tls'}{'on'}				= 'CHECKED' if exists $dma{'STARTTLS'};
> +	$selected{'mail_tls'}{'explicit'} = 'selected' if exists $dma{'STARTTLS'};
> +	$selected{'mail_tls'}{'implicit'} = 'selected' if (exists $dma{'SECURETRANSFER'}) and (not exists $dma{'STARTTLS'});
> +	$selected{'mail_tls'}{'disabled'} = 'selected' if (not exists $dma{'SECURETRANSFER'}) and (not exists $dma{'STARTTLS'});
> 	
> 	#Open site
> 	&Header::openpage($Lang::tr{'email settings'}, 1, '');
> @@ -226,7 +226,13 @@ END
> 		</tr>
> 		<tr>
> 			<td>$Lang::tr{'email tls'}</td>
> -			<td><input type='checkbox' name='mail_tls' $checked{'mail_tls'}{'on'}></td>
> +			<td>
> +				<select name='mail_tls'>
> +					<option value='implicit' $selected{'mail_tls'}{'implicit'}>$Lang::tr{'email tls implicit'}</option>
> +					<option value='explicit' $selected{'mail_tls'}{'explicit'}>$Lang::tr{'email tls explicit'}</option>
> +					<option value='disabled' $selected{'mail_tls'}{'disabled'}>$Lang::tr{'disabled'}</option>
> +				</select>
> +			</td>
> 		</tr>
> END
> 		if (! -z $dmafile && $mail{'USEMAIL'} eq 'on' && !$errormessage){
> -- 
> 2.16.4
  

Patch

diff --git a/html/cgi-bin/mail.cgi b/html/cgi-bin/mail.cgi
index 25589046e..7865a1da6 100755
--- a/html/cgi-bin/mail.cgi
+++ b/html/cgi-bin/mail.cgi
@@ -2,7 +2,7 @@ 
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2015  IPFire Team  <alexander.marx@ipfire.org>                #
+# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -110,8 +110,8 @@  if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ #SaveButton on configsite
 
 		$dma{'SMARTHOST'}		= $cgiparams{'txt_mailserver'};
 		$dma{'PORT'}			= $cgiparams{'txt_mailport'};
-		$dma{'STARTTLS'}		= '' if ($cgiparams{'mail_tls'});
-		$dma{'SECURETRANSFER'}	= '' if exists $dma{'STARTTLS'};
+		$dma{'STARTTLS'}		= '' if ($cgiparams{'mail_tls'} eq 'explicit');
+		$dma{'SECURETRANSFER'}	= '' if ($cgiparams{'mail_tls'} eq 'explicit' || $cgiparams{'mail_tls'} eq 'implicit');
 		$dma{'SPOOLDIR'}		= "/var/spool/dma";
 		$dma{'FULLBOUNCE'}		= '';
 		$dma{'MAILNAME'}		= "$mainsettings{'HOSTNAME'}.$mainsettings{DOMAINNAME}";
@@ -140,8 +140,6 @@  if ($cgiparams{'ACTION'} eq "$Lang::tr{'email testmail'}"){ #Testmail button on
 
 #FUNCTIONS
 sub configsite{
-	
-
 	#If update set fieldvalues new
 	if($cgiparams{'update'} eq 'on'){
 		$mail{'USEMAIL'}	= 'on';
@@ -156,7 +154,9 @@  sub configsite{
 	}
 	#find preselections
 	$checked{'usemail'}{$mail{'USEMAIL'}}	= 'CHECKED';
-	$checked{'mail_tls'}{'on'}				= 'CHECKED' if exists $dma{'STARTTLS'};
+	$selected{'mail_tls'}{'explicit'} = 'selected' if exists $dma{'STARTTLS'};
+	$selected{'mail_tls'}{'implicit'} = 'selected' if (exists $dma{'SECURETRANSFER'}) and (not exists $dma{'STARTTLS'});
+	$selected{'mail_tls'}{'disabled'} = 'selected' if (not exists $dma{'SECURETRANSFER'}) and (not exists $dma{'STARTTLS'});
 	
 	#Open site
 	&Header::openpage($Lang::tr{'email settings'}, 1, '');
@@ -226,7 +226,13 @@  END
 		</tr>
 		<tr>
 			<td>$Lang::tr{'email tls'}</td>
-			<td><input type='checkbox' name='mail_tls' $checked{'mail_tls'}{'on'}></td>
+			<td>
+				<select name='mail_tls'>
+					<option value='implicit' $selected{'mail_tls'}{'implicit'}>$Lang::tr{'email tls implicit'}</option>
+					<option value='explicit' $selected{'mail_tls'}{'explicit'}>$Lang::tr{'email tls explicit'}</option>
+					<option value='disabled' $selected{'mail_tls'}{'disabled'}>$Lang::tr{'disabled'}</option>
+				</select>
+			</td>
 		</tr>
 END
 		if (! -z $dmafile && $mail{'USEMAIL'} eq 'on' && !$errormessage){