From 06a66c936672073525ea2626b85ccc42db104f16 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Thu, 16 Jul 2015 10:25:50 -0300 Subject: Fix stunnel PBI directories and update to 5.20. Fixes #4295 --- config/stunnel/stunnel.inc | 60 +++++++++++++++++++++++++++------------------- config/stunnel/stunnel.xml | 4 ++-- pkg_config.10.xml | 4 ++-- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/config/stunnel/stunnel.inc b/config/stunnel/stunnel.inc index 552603b6..dd3eee5c 100644 --- a/config/stunnel/stunnel.inc +++ b/config/stunnel/stunnel.inc @@ -1,5 +1,13 @@ "); if($_cert['hash']) { if(openssl_x509_check_private_key($_POST['cert_chain'], $_POST['cert_key'])) { - file_put_contents('/usr/local/etc/stunnel/'.$_cert['hash'].'.key', + file_put_contents(STUNNEL_ETCDIR . '/'.$_cert['hash'].'.key', $_POST['cert_key']); - file_put_contents('/usr/local/etc/stunnel/'.$_cert['hash'].'.chain', + file_put_contents(STUNNEL_ETCDIR . '/'.$_cert['hash'].'.chain', $_POST['cert_chain']); - file_put_contents('/usr/local/etc/stunnel/'.$_cert['hash'].'.pem', + file_put_contents(STUNNEL_ETCDIR . '/'.$_cert['hash'].'.pem', $_POST['cert_key']."\n".$_POST['cert_chain']); - system('chown stunnel:stunnel /usr/local/etc/stunnel/*'); - chmod('/usr/local/etc/stunnel/'.$_cert['hash'].'.key', 0600); - chmod('/usr/local/etc/stunnel/'.$_cert['hash'].'.pem', 0600); + system('chown stunnel:stunnel ' . STUNNEL_ETCDIR . '/*'); + chmod(STUNNEL_ETCDIR . '/'.$_cert['hash'].'.key', 0600); + chmod(STUNNEL_ETCDIR . '/'.$_cert['hash'].'.pem', 0600); $_POST['filename']=$_cert['hash']; $_POST['expiry_raw']=$_cert['validTo_time_t']; @@ -191,29 +201,29 @@ function stunnel_save_cert($config) { $_POST['cert_chain']=base64_encode($_POST['cert_chain']); $_fname=$GLOBALS['config']['installedpackages']['stunnelcerts']['config'][$_POST['id']]['filename']; if($_fname and $_fname!=$_POST['filename']) { - unlink_if_exists('/usr/local/etc/stunnel/'.$_fname.'.chain'); - unlink_if_exists('/usr/local/etc/stunnel/'.$_fname.'.key'); - unlink_if_exists('/usr/local/etc/stunnel/'.$_fname.'.pem'); + unlink_if_exists(STUNNEL_ETCDIR . '/'.$_fname.'.chain'); + unlink_if_exists(STUNNEL_ETCDIR . '/'.$_fname.'.key'); + unlink_if_exists(STUNNEL_ETCDIR . '/'.$_fname.'.pem'); } } } function stunnel_install() { - safe_mkdir("/usr/local/etc/stunnel"); - system("/usr/bin/openssl req -new -x509 -days 365 -nodes -out /usr/local/etc/stunnel/stunnel.pem -keyout /usr/local/etc/stunnel/stunnel.pem 2>/dev/null"); - chmod("/usr/local/etc/stunnel/stunnel.pem", 0600); + safe_mkdir(STUNNEL_ETCDIR); + system("/usr/bin/openssl req -new -x509 -days 365 -nodes -out " . STUNNEL_ETCDIR . "/stunnel.pem -keyout " . STUNNEL_ETCDIR . "/stunnel.pem 2>/dev/null"); + chmod(STUNNEL_ETCDIR . "/stunnel.pem", 0600); @mkdir("/var/tmp/stunnel/var/tmp/run/stunnel", 0755, true); system("/usr/sbin/chown -R stunnel:stunnel /var/tmp/stunnel"); $_rcfile['file']='stunnel.sh'; - $_rcfile['start'].="/usr/local/bin/stunnel /usr/local/etc/stunnel/stunnel.conf \n\t"; + $_rcfile['start'].= STUNNEL_LOCALBASE . "/bin/stunnel " . STUNNEL_ETCDIR . "/stunnel.conf \n\t"; $_rcfile['stop'].="killall stunnel \n\t"; write_rcfile($_rcfile); unlink_if_exists("/usr/local/etc/rc.d/stunnel"); conf_mount_rw(); config_lock(); - $fout = fopen("/usr/local/etc/stunnel/stunnel.conf","w"); - fwrite($fout, "cert = /usr/local/etc/stunnel/stunnel.pem \n"); + $fout = fopen(STUNNEL_ETCDIR . "/stunnel.conf","w"); + fwrite($fout, "cert = " . STUNNEL_ETCDIR . "/stunnel.pem \n"); fwrite($fout, "chroot = /var/tmp/stunnel \n"); fwrite($fout, "setuid = stunnel \n"); fwrite($fout, "setgid = stunnel \n"); @@ -233,7 +243,7 @@ function stunnel_install() { function stunnel_deinstall() { rmdir_recursive("/var/tmp/stunnel"); - rmdir_recursive("/usr/local/etc/stunnel*"); + rmdir_recursive(STUNNEL_ETCDIR); unlink_if_exists("/usr/local/etc/rc.d/stunnel.sh"); } diff --git a/config/stunnel/stunnel.xml b/config/stunnel/stunnel.xml index 11334000..bb66d196 100644 --- a/config/stunnel/stunnel.xml +++ b/config/stunnel/stunnel.xml @@ -116,7 +116,7 @@ input - Client Mode? + Client Mode client Use client mode for this tunnel (i.e. connect to an SSL server, do not act as an SSL server) checkbox @@ -180,4 +180,4 @@ stunnel_addcerts($config); - \ No newline at end of file + diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 63e70208..5dbdf482 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -929,8 +929,8 @@ http://www.stunnel.org/ An SSL encryption wrapper between remote client and local or remote servers. Network Management - stunnel-5.07-##ARCH##.pbi - 5.07.1 + stunnel-5.20-##ARCH##.pbi + 5.20 Stable https://doc.pfsense.org/index.php/Stunnel_package 2.2 -- cgit v1.2.3