extrahd.cgi: Fix broken UUID check

Message ID 20230912182000.4937-1-stefan.schantl@ipfire.org
State Accepted
Commit fe2fd95a9ef320391a09b91304a97bc68bc0573b
Headers
Series extrahd.cgi: Fix broken UUID check |

Commit Message

Stefan Schantl Sept. 12, 2023, 6:20 p.m. UTC
  This check was totaly broken and resulted into not beeing able to
configure/mount more than one extra harddrive.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/extrahd.cgi | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Michael Tremer Sept. 13, 2023, 2:22 p.m. UTC | #1
Thank you for working on this so urgently.

> On 12 Sep 2023, at 19:20, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> This check was totaly broken and resulted into not beeing able to
> configure/mount more than one extra harddrive.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> html/cgi-bin/extrahd.cgi | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
> index 9cdfc69f8..c3a14c9e4 100644
> --- a/html/cgi-bin/extrahd.cgi
> +++ b/html/cgi-bin/extrahd.cgi
> @@ -113,13 +113,16 @@ if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) {
> # Split the line into pieces and assign nice variables.
> my ($uuid, $fs, $path) = split( /\;/, $entry );
> 
> + # Remove tailing UUID= from uuid string.
> + $uuid =~ s{^UUID=}{};
> +
> # Check if the path is allready used.
> if ( "$extrahdsettings{'PATH'}" eq "$path" ) {
> $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'} $Lang::tr{'extrahd because there is already a device mounted'}.";
> }
> 
> # Check if the uuid is allready used.
> - if ("$extrahdsettings{'DEVICE'} eq $uuid") {
> + if ("$extrahdsettings{'UUID'}" eq "$uuid") {
> $errormessage = "$extrahdsettings{'DEVICE'} is allready mounted.";
> }
> }
> -- 
> 2.39.2
>
  

Patch

diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
index 9cdfc69f8..c3a14c9e4 100644
--- a/html/cgi-bin/extrahd.cgi
+++ b/html/cgi-bin/extrahd.cgi
@@ -113,13 +113,16 @@  if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) {
 			# Split the line into pieces and assign nice variables.
 			my ($uuid, $fs, $path) = split( /\;/, $entry );
 
+			# Remove tailing UUID= from uuid string.
+			$uuid =~ s{^UUID=}{};
+
 			# Check if the path is allready used.
 			if ( "$extrahdsettings{'PATH'}" eq "$path" ) {
 				$errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'} $Lang::tr{'extrahd because there is already a device mounted'}.";
 			}
 
 			# Check if the uuid is allready used.
-			if ("$extrahdsettings{'DEVICE'} eq $uuid") {
+			if ("$extrahdsettings{'UUID'}" eq "$uuid") {
 				$errormessage = "$extrahdsettings{'DEVICE'} is allready mounted.";
 			}
 		}