Message ID | 20230602190116.1790314-1-jon.murphy@ipfire.org |
---|---|
State | Accepted |
Commit | 236e89ae87063bb1883875f76080d3f03c0351d5 |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QXsnD4X43z3wmt for <patchwork@web04.haj.ipfire.org>; Fri, 2 Jun 2023 19:02:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QXsnC1nZzzkG; Fri, 2 Jun 2023 19:02:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QXsnC0BpLz2ybC; Fri, 2 Jun 2023 19:02:07 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QXsn937W6z2xN7 for <development@lists.ipfire.org>; Fri, 2 Jun 2023 19:02:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QXsn76XCGzhC; Fri, 2 Jun 2023 19:02:03 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1685732524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=RgcwmWRH9xTOfl0+FD+o2J1VAWzvx23mxK/aLFZRS2o=; b=pT78xYHTUn7NL7naSsggAxnkLZ1oCkM01XRB1T7tcy5TNzi2Xpzig56hhLlbnrDjdotSUf Ur89MSuyGPpcPcDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1685732524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=RgcwmWRH9xTOfl0+FD+o2J1VAWzvx23mxK/aLFZRS2o=; b=Mcwiv1c5Y6E34gQ+JjlG4Vs0x5YFT77SNYIoqeYnIdt7xnYIoAYWC+bV8Y0nSNRcMXJg8R dMwoSZ9MCOJal/8Eg8NH89ELe4IVkTuv/VonIYMr0KjgnR5Bqm09bw/4/o1DntTrR452uj EL1uMtLxj17W6wzTNoOqnjL09KnrKdqg8nece6qV33khaVptCe9i/+fx7tfjb4Lknkl2Jo RGudDcJu8Bk5EkvUIVX4IyV3EbKDTAIr2kZqnVlzln6Q7Pw4FXHh5s/T/vrLm93TwTC/dW Vgp+WzUa79Tyx2mloTM0HCQIuUViYYRNfP8trDwvpg0Kd0EFjc1DTGzdwTaVQQ== From: Jon Murphy <jon.murphy@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH] extrahd.cgi: Fix for Bug #12863 Date: Fri, 2 Jun 2023 14:01:16 -0500 Message-Id: <20230602190116.1790314-1-jon.murphy@ipfire.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <https://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <https://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Series |
extrahd.cgi: Fix for Bug #12863
|
|
Commit Message
jon
June 2, 2023, 7:01 p.m. UTC
-Fixes remove entries in 'extrahd' via the webinterface for extrahd.cgi file.
Suggested-by: Bernhard Bitsch <bbitsch@ipfire.org>
Signed-off-by: Jon Murphy <jon.murphy@ipfire.org>
---
html/cgi-bin/extrahd.cgi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org> The syntax pains me, but this is probably correct :) > On 2 Jun 2023, at 20:01, Jon Murphy <jon.murphy@ipfire.org> wrote: > > -Fixes remove entries in 'extrahd' via the webinterface for extrahd.cgi file. > > Suggested-by: Bernhard Bitsch <bbitsch@ipfire.org> > Signed-off-by: Jon Murphy <jon.murphy@ipfire.org> > --- > html/cgi-bin/extrahd.cgi | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi > index 36c0efc2e..9dd3a0eee 100644 > --- a/html/cgi-bin/extrahd.cgi > +++ b/html/cgi-bin/extrahd.cgi > @@ -103,7 +103,7 @@ END > } > elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) > { > - if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { > + if ( ! &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { > open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; > @tmp = <FILE>; > close FILE; > -- > 2.30.2 >
Would flipping it around hurt less? (I’d don’t speak perl but I think this would work!) ``` if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { $errormessage = "$Lang::tr{'extrahd cant umount'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd maybe the device is in use'}?"; } else { open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; @tmp = <FILE>; close FILE; open( FILE, "> $devicefile" ) or die "Unable to write $devicefile"; foreach $deviceentry (sort @tmp) { @tmpline = split( /\;/, $deviceentry ); if ( $tmpline[2] ne $extrahdsettings{'PATH'} ) { print FILE $deviceentry; } } close FILE; } ``` Jon Murphy jon.murphy@ipfire.org > On Jun 5, 2023, at 5:42 AM, Michael Tremer <michael.tremer@ipfire.org> wrote: > > Reviewed-by: Michael Tremer <michael.tremer@ipfire.org> > > The syntax pains me, but this is probably correct :) > >> On 2 Jun 2023, at 20:01, Jon Murphy <jon.murphy@ipfire.org> wrote: >> >> -Fixes remove entries in 'extrahd' via the webinterface for extrahd.cgi file. >> >> Suggested-by: Bernhard Bitsch <bbitsch@ipfire.org> >> Signed-off-by: Jon Murphy <jon.murphy@ipfire.org> >> --- >> html/cgi-bin/extrahd.cgi | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi >> index 36c0efc2e..9dd3a0eee 100644 >> --- a/html/cgi-bin/extrahd.cgi >> +++ b/html/cgi-bin/extrahd.cgi >> @@ -103,7 +103,7 @@ END >> } >> elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) >> { >> - if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { >> + if ( ! &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { >> open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; >> @tmp = <FILE>; >> close FILE; >> -- >> 2.30.2 >> >
Hello Jon, > On 5 Jun 2023, at 17:53, jon <jon.murphy@ipfire.org> wrote: > > Would flipping it around hurt less? > > (I’d don’t speak perl but I think this would work!) Oh no this wasn’t targeted at the code, just at Perl in general. I don’t find it obvious to read this at all, but there is no way to write this in an absolute intuitive way. So I am happy to have this merged as it is. The most important thing is that it does the right thing. -Michael > ``` > if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { > $errormessage = "$Lang::tr{'extrahd cant umount'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd maybe the device is in use'}?"; > } else { > open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; > @tmp = <FILE>; > close FILE; > open( FILE, "> $devicefile" ) or die "Unable to write $devicefile"; > foreach $deviceentry (sort @tmp) > { > @tmpline = split( /\;/, $deviceentry ); > if ( $tmpline[2] ne $extrahdsettings{'PATH'} ) > { > print FILE $deviceentry; > } > } > close FILE; > } > ``` > > Jon Murphy > jon.murphy@ipfire.org > > > >> On Jun 5, 2023, at 5:42 AM, Michael Tremer <michael.tremer@ipfire.org> wrote: >> >> Reviewed-by: Michael Tremer <michael.tremer@ipfire.org> >> >> The syntax pains me, but this is probably correct :) >> >>> On 2 Jun 2023, at 20:01, Jon Murphy <jon.murphy@ipfire.org> wrote: >>> >>> -Fixes remove entries in 'extrahd' via the webinterface for extrahd.cgi file. >>> >>> Suggested-by: Bernhard Bitsch <bbitsch@ipfire.org> >>> Signed-off-by: Jon Murphy <jon.murphy@ipfire.org> >>> --- >>> html/cgi-bin/extrahd.cgi | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi >>> index 36c0efc2e..9dd3a0eee 100644 >>> --- a/html/cgi-bin/extrahd.cgi >>> +++ b/html/cgi-bin/extrahd.cgi >>> @@ -103,7 +103,7 @@ END >>> } >>> elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) >>> { >>> - if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { >>> + if ( ! &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { >>> open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; >>> @tmp = <FILE>; >>> close FILE; >>> -- >>> 2.30.2 >>> >> >
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> Less painful syntax could be: + unless ( &General::system("/usr/loca/bin/extrahdctrl","umount",$extrahdsettings{'PATH'}")) { Am 02.06.2023 um 21:01 schrieb Jon Murphy: > -Fixes remove entries in 'extrahd' via the webinterface for extrahd.cgi file. > > Suggested-by: Bernhard Bitsch <bbitsch@ipfire.org> > Signed-off-by: Jon Murphy <jon.murphy@ipfire.org> > --- > html/cgi-bin/extrahd.cgi | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi > index 36c0efc2e..9dd3a0eee 100644 > --- a/html/cgi-bin/extrahd.cgi > +++ b/html/cgi-bin/extrahd.cgi > @@ -103,7 +103,7 @@ END > } > elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) > { > - if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { > + if ( ! &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { > open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; > @tmp = <FILE>; > close FILE;
diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 36c0efc2e..9dd3a0eee 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -103,7 +103,7 @@ END } elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) { - if ( &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { + if ( ! &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; @tmp = <FILE>; close FILE;