Commit a1dd58aa authored by Franco Fichtner's avatar Franco Fichtner

openvpn: remove pbi remnants and add proper 7z package

PR: https://forum.opnsense.org/index.php?topic=2273.0
(cherry picked from commit c831f3c6)
parent ad6c2d61
...@@ -85,6 +85,7 @@ CORE_DEPENDS?= apinger \ ...@@ -85,6 +85,7 @@ CORE_DEPENDS?= apinger \
openssh-portable \ openssh-portable \
openvpn \ openvpn \
opnsense-update \ opnsense-update \
p7zip \
pecl-radius \ pecl-radius \
pftop \ pftop \
phalcon \ phalcon \
......
...@@ -474,21 +474,20 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $veri ...@@ -474,21 +474,20 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $veri
$client_install_exe = "openvpn-install-{$current_openvpn_version}-I6{$current_openvpn_version_rev}-x86_64.exe"; $client_install_exe = "openvpn-install-{$current_openvpn_version}-I6{$current_openvpn_version_rev}-x86_64.exe";
break; break;
default: default:
$client_install_exe = "openvpn-install-{$current_openvpn_version}-I0{$current_openvpn_version_rev}-i686.exe"; $input_errors[] = gettext("Could not find matching OpenVPN architecture.");
return false;
} }
$ovpndir = "/usr/local/opnsense/contrib/openvpn";
$workdir = "{$ovpndir}/client-export";
$validconfig = openvpn_client_export_validate_config($srvid, $usrid, $crtid); $validconfig = openvpn_client_export_validate_config($srvid, $usrid, $crtid);
if (!$validconfig) { if (!$validconfig) {
$input_errors[] = gettext("Could not validate OpenVPN config.");
return false; return false;
} }
list($settings, $server_cert, $server_ca, $servercn, $user, $cert, $nokeys) = $validconfig; list($settings, $server_cert, $server_ca, $servercn, $user, $cert, $nokeys) = $validconfig;
// create template directory // create template directory
$tempdir = "/tmp//openvpn-export-".uniqid(); $tempdir = '/tmp/openvpn-export-' . uniqid();
mkdir($tempdir, 0700, true); mkdir($tempdir, 0700, true);
// create config directory // create config directory
...@@ -498,7 +497,7 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $veri ...@@ -498,7 +497,7 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $veri
} }
// copy the template directory // copy the template directory
exec("cp -r {$workdir}/template/* {$tempdir}"); exec("cp -r /usr/local/opnsense/contrib/openvpn/client-export/template/* {$tempdir}");
// and put the required installer exe in place // and put the required installer exe in place
exec("/bin/cp {$tempdir}/{$client_install_exe} {$tempdir}/openvpn-install.exe"); exec("/bin/cp {$tempdir}/{$client_install_exe} {$tempdir}/openvpn-install.exe");
if (stristr($openvpn_version, "x64")) { if (stristr($openvpn_version, "x64")) {
...@@ -565,11 +564,7 @@ RunProgram="openvpn-postinstall.exe" ...@@ -565,11 +564,7 @@ RunProgram="openvpn-postinstall.exe"
} }
file_put_contents("{$tempdir}/7zipConfig",$procchain); file_put_contents("{$tempdir}/7zipConfig",$procchain);
if (file_exists("/usr/pbi/p7zip-{$uname_p}/bin/7z")) { exec("/usr/local/bin/7z -y a archive.7z {$files}");
exec("/usr/pbi/p7zip-{$uname_p}/bin/7z -y a archive.7z {$files}");
} else {
exec("/usr/local/libexec/p7zip/7z -y a archive.7z {$files}");
}
// create the final installer // create the final installer
$outfile = "{$tempdir}-install.exe"; $outfile = "{$tempdir}-install.exe";
...@@ -587,8 +582,6 @@ function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $usead ...@@ -587,8 +582,6 @@ function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $usead
global $config; global $config;
$uname_p = trim(exec("uname -p")); $uname_p = trim(exec("uname -p"));
$ovpndir = "/usr/local/opnsense/contrib/openvpn/";
$uniq = uniqid(); $uniq = uniqid();
$tempdir = "/tmp/openvpn-export-{$uniq}"; $tempdir = "/tmp/openvpn-export-{$uniq}";
$zipfile = "/tmp/{$uniq}-Viscosity.visc.zip"; $zipfile = "/tmp/{$uniq}-Viscosity.visc.zip";
...@@ -687,11 +680,7 @@ EOF; ...@@ -687,11 +680,7 @@ EOF;
} }
// Zip Viscosity file // Zip Viscosity file
if (file_exists("/usr/pbi/zip-{$uname_p}/bin/zip")) {
exec("cd {$tempdir}/.. && /usr/pbi/zip-{$uname_p}/bin/zip -r {$zipfile} Viscosity.visc");
} else {
exec("cd {$tempdir}/.. && /usr/local/bin/zip -r {$zipfile} Viscosity.visc"); exec("cd {$tempdir}/.. && /usr/local/bin/zip -r {$zipfile} Viscosity.visc");
}
// Remove temporary directory // Remove temporary directory
exec("rm -rf {$tempdir}"); exec("rm -rf {$tempdir}");
...@@ -818,11 +807,7 @@ function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipco ...@@ -818,11 +807,7 @@ function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipco
$shkeyfile = "{$tempdir}/{$shkeyfile}"; $shkeyfile = "{$tempdir}/{$shkeyfile}";
file_put_contents("{$shkeyfile}", base64_decode($settings['shared_key'])); file_put_contents("{$shkeyfile}", base64_decode($settings['shared_key']));
if (file_exists("/usr/pbi/zip-{$uname_p}/bin/zip")) {
exec("cd {$tempdir}/.. && /usr/pbi/zip-{$uname_p}/bin/zip -r /tmp/{$prefix}-config.zip {$prefix}");
} else {
exec("cd {$tempdir}/.. && /usr/local/bin/zip -r /tmp/{$prefix}-config.zip {$prefix}"); exec("cd {$tempdir}/.. && /usr/local/bin/zip -r /tmp/{$prefix}-config.zip {$prefix}");
}
// Remove temporary directory // Remove temporary directory
exec("rm -rf {$tempdir}"); exec("rm -rf {$tempdir}");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment