Signed-off-by: Stefan Schantl Tested-by: Stefan Schantl > From: Stefan Schantl > > Signed-off-by: Stefan Schantl > --- >  html/cgi-bin/vpnmain.cgi | 30 ++++++++++++++++++------------ >  1 file changed, 18 insertions(+), 12 deletions(-) > > diff --git a/html/cgi-bin/vpnmain.cgi b/html/cgi-bin/vpnmain.cgi > index e9064e19c..7bb0d1b35 100644 > --- a/html/cgi-bin/vpnmain.cgi > +++ b/html/cgi-bin/vpnmain.cgi > @@ -675,8 +675,7 @@ END >                 unlink ($filename); >                 goto UPLOADCA_ERROR; >         } else { > -               move($filename, > "${General::swroot}/ca/$cgiparams{'CA_NAME'}cert.pem"); > -               if ($? ne 0) { > +               unless(move($filename, > "${General::swroot}/ca/$cgiparams{'CA_NAME'}cert.pem")) { >                         $errormessage = "$Lang::tr{'certificate file > move failed'}: $!"; >                         unlink ($filename); >                         goto UPLOADCA_ERROR; > @@ -947,20 +946,23 @@ END >   >                 if (!$errormessage) { >                         &General::log("ipsec", "Moving cacert..."); > -                       move("/tmp/newcacert", > "${General::swroot}/ca/cacert.pem"); > -                       $errormessage = "$Lang::tr{'certificate file > move failed'}: $!" if ($? ne 0); > +                       unless(move("/tmp/newcacert", > "${General::swroot}/ca/cacert.pem")) { > +                               $errormessage = > "$Lang::tr{'certificate file move failed'}: $!"; > +                       } >                 } >   >                 if (!$errormessage) { >                         &General::log("ipsec", "Moving host > cert..."); > -                       move("/tmp/newhostcert", > "${General::swroot}/certs/hostcert.pem"); > -                       $errormessage = "$Lang::tr{'certificate file > move failed'}: $!" if ($? ne 0); > +                       unless(move("/tmp/newhostcert", > "${General::swroot}/certs/hostcert.pem")) { > +                               $errormessage = > "$Lang::tr{'certificate file move failed'}: $!"; > +                       } >                 } >   >                 if (!$errormessage) { >                         &General::log("ipsec", "Moving private > key..."); > -                       move("/tmp/newhostkey", > "${General::swroot}/certs/hostkey.pem"); > -                       $errormessage = "$Lang::tr{'certificate file > move failed'}: $!" if ($? ne 0); > +                       unless(move("/tmp/newhostkey", > "${General::swroot}/certs/hostkey.pem")) { > +                               $errormessage = > "$Lang::tr{'certificate file move failed'}: $!"; > +                       } >                 } >   >                 #cleanup temp files > @@ -1979,8 +1981,11 @@ END >                                         while (grep(/Imported-$idx/, > @names) ) {$idx++}; >                                         $cgiparams{'CA_NAME'}="Import > ed-$idx"; >                                         $cgiparams{'CERT_NAME'}=&Head > er::cleanhtml(getCNfromcert ('/tmp/newhostcert')); > -                                       move("/tmp/newcacert", > "${General::swroot}/ca/$cgiparams{'CA_NAME'}cert.pem"); > -                                       $errormessage = > "$Lang::tr{'certificate file move failed'}: $!" if ($? ne 0); > + > +                                       unless(move("/tmp/newcacert", > "${General::swroot}/ca/$cgiparams{'CA_NAME'}cert.pem")) { > +                                               $errormessage = > "$Lang::tr{'certificate file move failed'}: $!"; > +                                       } > + >                                         if (!$errormessage) { >                                                 my $key = > &General::findhasharraykey (\%cahash); >                                                 $cahash{$key}[0] = > $cgiparams{'CA_NAME'}; > @@ -1993,8 +1998,9 @@ END >                 } >                 if (!$errormessage) { >                         &General::log("ipsec", "Moving host > cert..."); > -                       move("/tmp/newhostcert", > "${General::swroot}/certs/$cgiparams{'NAME'}cert.pem"); > -                       $errormessage = "$Lang::tr{'certificate file > move failed'}: $!" if ($? ne 0); > +                       unless(move("/tmp/newhostcert", > "${General::swroot}/certs/$cgiparams{'NAME'}cert.pem")) { > +                               $errormessage = > "$Lang::tr{'certificate file move failed'}: $!"; > +                       } >                 } >   >                 #cleanup temp files