From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] ovpnmain.cgi: Do not interpret $? as error code of move()
Date: Thu, 04 Nov 2021 08:06:49 +0000 [thread overview]
Message-ID: <A1B2541A-846D-438B-8EB2-67F5F47C21FD@ipfire.org> (raw)
In-Reply-To: <20211103181855.1758-1-stefan.schantl@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 4530 bytes --]
Thank you for working on this.
I would suggest to include this with c161 since so many people ran into it.
> On 3 Nov 2021, at 18:18, Stefan Schantl <stefan.schantl(a)ipfire.org> wrote:
>
> Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
> ---
> html/cgi-bin/ovpnmain.cgi | 41 +++++++++++++++------------------------
> 1 file changed, 16 insertions(+), 25 deletions(-)
>
> diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
> index 2ebf384ed..f99bfdef7 100644
> --- a/html/cgi-bin/ovpnmain.cgi
> +++ b/html/cgi-bin/ovpnmain.cgi
> @@ -1432,18 +1432,17 @@ END
> unlink ($filename);
> goto UPLOADCA_ERROR;
> } else {
> - # Delete if old key exists
> - if (-f "${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}") {
> - unlink "${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}";
> + # Delete if old key exists
> + if (-f "${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}") {
> + unlink "${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}";
> }
> - move($filename, "${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}");
> - if ($? ne 0) {
> +
> + unless(move($filename, "${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}")) {
> $errormessage = "$Lang::tr{'dh key move failed'}: $!";
> unlink ($filename);
> goto UPLOADCA_ERROR;
> - }
> + }
> }
> -
> ###
> ### Upload CA Certificate
> ###
> @@ -1489,8 +1488,7 @@ END
> unlink ($filename);
> goto UPLOADCA_ERROR;
> } else {
> - move($filename, "${General::swroot}/ovpn/ca/$cgiparams{'CA_NAME'}cert.pem");
> - if ($? ne 0) {
> + unless(move($filename, "${General::swroot}/ovpn/ca/$cgiparams{'CA_NAME'}cert.pem")) {
> $errormessage = "$Lang::tr{'certificate file move failed'}: $!";
> unlink ($filename);
> goto UPLOADCA_ERROR;
> @@ -1814,8 +1812,7 @@ END
> }
> }
>
> - move("$tempdir/cacert.pem", "${General::swroot}/ovpn/ca/cacert.pem");
> - if ($? ne 0) {
> + unless(move("$tempdir/cacert.pem", "${General::swroot}/ovpn/ca/cacert.pem")) {
> $errormessage = "$Lang::tr{'certificate file move failed'}: $!";
> unlink ($filename);
> unlink ("${General::swroot}/ovpn/ca/cacert.pem");
> @@ -1824,8 +1821,7 @@ END
> goto ROOTCERT_ERROR;
> }
>
> - move("$tempdir/hostcert.pem", "${General::swroot}/ovpn/certs/servercert.pem");
> - if ($? ne 0) {
> + unless(move("$tempdir/hostcert.pem", "${General::swroot}/ovpn/certs/servercert.pem")) {
> $errormessage = "$Lang::tr{'certificate file move failed'}: $!";
> unlink ($filename);
> unlink ("${General::swroot}/ovpn/ca/cacert.pem");
> @@ -1834,8 +1830,7 @@ END
> goto ROOTCERT_ERROR;
> }
>
> - move("$tempdir/serverkey.pem", "${General::swroot}/ovpn/certs/serverkey.pem");
> - if ($? ne 0) {
> + unless(move("$tempdir/serverkey.pem", "${General::swroot}/ovpn/certs/serverkey.pem")) {
> $errormessage = "$Lang::tr{'certificate file move failed'}: $!";
> unlink ($filename);
> unlink ("${General::swroot}/ovpn/ca/cacert.pem");
> @@ -3395,22 +3390,19 @@ END
> print FILE "status /var/run/openvpn/$n2nname[0]-n2n 10\n";
> close FILE;
>
> - move("$tempdir/$uplconffilename", "${General::swroot}/ovpn/n2nconf/$n2nname[0]/$uplconffilename2");
> -
> - if ($? ne 0) {
> + unless(move("$tempdir/$uplconffilename", "${General::swroot}/ovpn/n2nconf/$n2nname[0]/$uplconffilename2")) {
> $errormessage = "*.conf move failed: $!";
> unlink ($filename);
> goto N2N_ERROR;
> }
>
> - move("$tempdir/$uplp12name", "${General::swroot}/ovpn/certs/$uplp12name2");
> - chmod 0600, "${General::swroot}/ovpn/certs/$uplp12name";
> -
> - if ($? ne 0) {
> + unless(move("$tempdir/$uplp12name", "${General::swroot}/ovpn/certs/$uplp12name2")) {
> $errormessage = "$Lang::tr{'certificate file move failed'}: $!";
> unlink ($filename);
> goto N2N_ERROR;
> - }
> + }
> +
> + chmod 0600, "${General::swroot}/ovpn/certs/$uplp12name";
>
> my $complzoactive;
> my $mssfixactive;
> @@ -4175,8 +4167,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
> unlink ($filename);
> goto VPNCONF_ERROR;
> } else {
> - move($filename, "${General::swroot}/ovpn/certs/$cgiparams{'NAME'}cert.pem");
> - if ($? ne 0) {
> + unless(move($filename, "${General::swroot}/ovpn/certs/$cgiparams{'NAME'}cert.pem")) {
> $errormessage = "$Lang::tr{'certificate file move failed'}: $!";
> unlink ($filename);
> goto VPNCONF_ERROR;
> --
> 2.30.2
>
prev parent reply other threads:[~2021-11-04 8:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 18:18 Stefan Schantl
2021-11-04 8:06 ` Michael Tremer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A1B2541A-846D-438B-8EB2-67F5F47C21FD@ipfire.org \
--to=michael.tremer@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox