From 4d017584c3dc7965b1bf145b84b14e34d92d25c3 Mon Sep 17 00:00:00 2001 From: marcelloc Date: Tue, 28 Feb 2012 19:38:18 -0300 Subject: haproxy - update haproxy to 1.4.19 haproxy-legacy - update haproxy to 1.4.19 filer - include new features and action after file update --- config/filer/filer.inc | 71 +++++++++++++++++++++++++++++++++++---------- config/filer/filer.xml | 57 +++++++++++++++++++++++++++++------- config/filer/filer_sync.xml | 3 +- 3 files changed, 103 insertions(+), 28 deletions(-) (limited to 'config/filer') diff --git a/config/filer/filer.inc b/config/filer/filer.inc index b4512a49..b89553e4 100644 --- a/config/filer/filer.inc +++ b/config/filer/filer.inc @@ -4,8 +4,8 @@ filerinc part of pfSense (http://www.pfSense.com) Copyright (C) 2010 Scott Ullrich - Copyright (C) 2011 Marcello Coutinho - Copyright (C) 2011 Brian Scholer + Copyright (C) 2012 Marcello Coutinho + Copyright (C) 2012 Brian Scholer All rights reserved. */ /* ========================================================================== */ @@ -48,30 +48,71 @@ function filer_start() { // reserved } +function filer_text_area_decode($text){ + return preg_replace('/\r\n/', "\n",base64_decode($text)); +} function sync_package_filer() { global $config, $g; + $update_conf=0; + #mount filesystem writeable + conf_mount_rw(); + #loop on configured files if($config['installedpackages']['filer']['config']!="") { + $count=0; foreach($config['installedpackages']['filer']['config'] as $file) { - $fname = $file['fullfile']; - $fdata = str_replace("\r", "", base64_decode($file['filedata'])); - if($file['mod']) { - if(!preg_match("/0?[0-7]{3}/", $file['mod'])) - $mod = 0700; - else - $mod = octdec($file['mod']); - } - conf_mount_rw(); - file_put_contents($fname, $fdata); - if($mod) - chmod($fname, $mod); - conf_mount_ro(); + if ($file['filedata']=="" && file_exists($file['fullfile'])){ + $config['installedpackages']['filer']['config'][$count]['filedata']=base64_encode(file_get_contents($file['fullfile'])); + $file['filedata']=base64_encode(file_get_contents($file['fullfile'])); + $update_conf++; + } + $count++; + if(preg_match("/0?[0-7]{3}/", $file['mod'])) + $mod = octdec($file['mod']); + else + $mod = 0700; + + #write file + file_put_contents($file['fullfile'], filer_text_area_decode($file['filedata']),LOCK_EX); + chmod($file['fullfile'], $mod); + + #check if there is a script to run after file save + if($file['cmd']!= "") + switch ($file['background']){ + case "background": + mwexec_bg($file['cmd']); + break; + case "foreground": + mwexec($file['cmd']); + break; + } + } + + #Write config if any file from filesystem was loaded + if ($update_conf > 0) + write_config(); } + #mount filesystem readonly + conf_mount_ro(); filer_sync_on_changes(); } +function filer_validate_input($post, &$input_errors) { + foreach ($post as $key => $value) { + if (empty($value)) + continue; + if (substr($key, 0, 3) == "mod" && !preg_match("/^0?[0-7]{3}$/", $value)) + $input_errors[] = "{$value} is valid permission number"; + if (substr($key, 0, 11) == "description" && !preg_match("@^[a-zA-Z0-9 _/.-]+$@", $value)) + $input_errors[] = "Do not use special characters on description"; + if (substr($key, 0, 8) == "fullfile" && !preg_match("@^[a-zA-Z0-9_/.-]+$@", $value)) + $input_errors[] = "Do not use special characters on filename"; + + } +} + /* Uses XMLRPC to synchronize the changes to a remote node */ function filer_sync_on_changes() { global $config, $g; diff --git a/config/filer/filer.xml b/config/filer/filer.xml index f772feb2..9196f889 100644 --- a/config/filer/filer.xml +++ b/config/filer/filer.xml @@ -10,6 +10,7 @@ part of pfSense (http://www.pfSense.com) Copyright (C) 2010 Scott Ullrich Copyright (C) 2011 Brian Scholer + Copyright (C) 2012 Marcello Coutinho All rights reserved. */ /* ========================================================================== */ @@ -70,7 +71,6 @@ XMLRPC Sync /pkg_edit.php?xml=filer_sync.xml - @@ -90,39 +90,74 @@ - Full path to the file + listtopic + temp + File configuration + + + File fullfile input + 60 + Enter Full file path - - Permissions - mod - input - Blank leaves the permissions alone. - Description description Enter a description for this file. input + 60 + + + Permissions + mod + input + 10 + Blank leaves the permissions alone.]]> File Contents filedata - Paste the files contents here. + Leave blank to load an existing file from file system or paste the file content you want to save. textarea base64 - 60 - 30 + 75 + 25 + + listtopic + temp + cmd to run after file save/sync + + + script + cmd + Enter script or cmd to run after file save/sync + input + 60 + + + execute mode + background + select + + + + + + Choose the way script will run. + filer_install(); + + filer_validate_input($_POST, &$input_errors); + sync_package_filer(); diff --git a/config/filer/filer_sync.xml b/config/filer/filer_sync.xml index ae8e48ba..c51bae86 100644 --- a/config/filer/filer_sync.xml +++ b/config/filer/filer_sync.xml @@ -9,8 +9,8 @@ filer_sync.xml part of pfSense (http://www.pfSense.com) Copyright (C) 2008 Scott Ullrich - Copyright (C) 2011 Marcello Coutinho Copyright (C) 2011 Brian Scholer + Copyright (C) 2012 Marcello Coutinho All rights reserved. */ /* ========================================================================== */ @@ -50,7 +50,6 @@ Files /pkg.php?xml=filer.xml - XMLRPC Sync -- cgit v1.2.3