From patchwork Mon Oct 14 17:11:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 2519 Return-Path: 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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 46sQ8M1TnBz3yYL for ; Mon, 14 Oct 2019 17:11:47 +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 "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 46sQ8K75fBz2Nq; Mon, 14 Oct 2019 17:11:45 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 46sQ8K6JNgz2yCb; Mon, 14 Oct 2019 17:11:45 +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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 46sQ8J0nv6z2y2r for ; Mon, 14 Oct 2019 17:11:44 +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) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 46sQ8H4ZLlz2Nq; Mon, 14 Oct 2019 17:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1571073103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=XUfydMm0A4HE7s2jUkGPDGWjJQd8wo/V0bN0neGOzt4=; b=j1IRiQlCGpJTkGk/DI5PRFzlgESzN1No1XcMr1ccVSokypmbtCfzRrdtmlV1CnB/dSj3P4 XfFMWCyLm/9bY7Jk7lcY5fBDUwU9E164DVjAq8BfNBH1RAUZDkUE7lqqyykBB/QvcAcDuW 9oPCRzHYoSuU1ZdOipFwnmUrRsTZCPROs/LFJrc9QQRR17a0YGntp0rD/yhNrdxGASXMyR +1TrHpfr5bVr/ChoAKYgRP3P0/auin4xQocjinHEI+YVmcRw5u16rPMDf/1dPkl9MNzNVf QbVlPb7oB/d0SHeT4UrqhUZ9yp/PoyOIBQeBqLF+8FUBbrgy2A832u1at+dhEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1571073103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=XUfydMm0A4HE7s2jUkGPDGWjJQd8wo/V0bN0neGOzt4=; b=1wZ5COijqHtw5xpqUyxAmf4ilPE3RexPUPGFLDlzbIEpYR+oLLDv+SbvJADkmLKajcl2KM xwH1xauYdyGbzJBQ== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] vpnmain.cgi+ovpnmain.cgi: Fix file upload with new versions of Perl Date: Mon, 14 Oct 2019 19:11:37 +0200 Message-Id: <20191014171137.23722-1-michael.tremer@ipfire.org> Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=ms smtp.mailfrom=michael.tremer@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" File uploads did not work since Perl was upgraded. This patch fixes that problem by only checking if an object was returned instead of performing a string comparison. Signed-off-by: Michael Tremer --- html/cgi-bin/ovpnmain.cgi | 16 +++++++--------- html/cgi-bin/vpnmain.cgi | 10 +++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 5b8ca9731..970444a55 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -1372,7 +1372,7 @@ END ### Upload DH key ### } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload dh key'}) { - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto UPLOADCA_ERROR; } @@ -1429,7 +1429,7 @@ END } } - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto UPLOADCA_ERROR; } @@ -1662,8 +1662,7 @@ END } } } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload p12 file'}) { - - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto ROOTCERT_ERROR; } @@ -3218,9 +3217,8 @@ END &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash); -# Check if a file is uploaded - - if (ref ($cgiparams{'FH'}) ne 'Fh') { + # Check if a file is uploaded + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto N2N_ERROR; } @@ -4009,7 +4007,7 @@ if ($cgiparams{'TYPE'} eq 'net') { $errormessage = $Lang::tr{'cant change certificates'}; goto VPNCONF_ERROR; } - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto VPNCONF_ERROR; } @@ -4056,7 +4054,7 @@ if ($cgiparams{'TYPE'} eq 'net') { $errormessage = $Lang::tr{'cant change certificates'}; goto VPNCONF_ERROR; } - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto VPNCONF_ERROR; } diff --git a/html/cgi-bin/vpnmain.cgi b/html/cgi-bin/vpnmain.cgi index 1cd7cb84b..33b504bc9 100644 --- a/html/cgi-bin/vpnmain.cgi +++ b/html/cgi-bin/vpnmain.cgi @@ -604,7 +604,7 @@ END } } - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto UPLOADCA_ERROR; } @@ -830,7 +830,7 @@ END } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload p12 file'}) { &General::log("ipsec", "Importing from p12..."); - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto ROOTCERT_ERROR; } @@ -1531,7 +1531,7 @@ END $errormessage = $Lang::tr{'cant change certificates'}; goto VPNCONF_ERROR; } - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto VPNCONF_ERROR; } @@ -1568,7 +1568,7 @@ END } elsif ($cgiparams{'AUTH'} eq 'pkcs12') { &General::log("ipsec", "Importing from p12..."); - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto ROOTCERT_ERROR; } @@ -1658,7 +1658,7 @@ END $errormessage = $Lang::tr{'cant change certificates'}; goto VPNCONF_ERROR; } - if (ref ($cgiparams{'FH'}) ne 'Fh') { + unless (ref ($cgiparams{'FH'})) { $errormessage = $Lang::tr{'there was no file upload'}; goto VPNCONF_ERROR; }