diff options
-rw-r--r-- | config/filer/filer.inc | 71 | ||||
-rw-r--r-- | config/filer/filer.xml | 57 | ||||
-rw-r--r-- | config/filer/filer_sync.xml | 3 | ||||
-rwxr-xr-x | pkg_config.7.xml | 2 | ||||
-rw-r--r-- | pkg_config.8.xml | 12 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 16 |
6 files changed, 118 insertions, 43 deletions
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 <sullrich@gmail.com> - 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 <sullrich@gmail.com> Copyright (C) 2011 Brian Scholer + Copyright (C) 2012 Marcello Coutinho All rights reserved. */ /* ========================================================================== */ @@ -70,7 +71,6 @@ <tab> <text>XMLRPC Sync</text> <url>/pkg_edit.php?xml=filer_sync.xml</url> - <active/> </tab> </tabs> @@ -90,39 +90,74 @@ </adddeleteeditpagefields> <fields> <field> - <fielddescr>Full path to the file</fielddescr> + <type>listtopic</type> + <fieldname>temp</fieldname> + <name>File configuration</name> + </field> + <field> + <fielddescr>File</fielddescr> <fieldname>fullfile</fieldname> <type>input</type> + <size>60</size> + <description>Enter Full file path</description> <required/> </field> <field> - <fielddescr>Permissions</fielddescr> - <fieldname>mod</fieldname> - <type>input</type> - <description>Blank leaves the permissions alone.</description> - </field> - <field> <fielddescr>Description</fielddescr> <fieldname>description</fieldname> <description>Enter a description for this file.</description> <type>input</type> + <size>60</size> + </field> + <field> + <fielddescr>Permissions</fielddescr> + <fieldname>mod</fieldname> + <type>input</type> + <size>10</size> + <description><![CDATA[Enter file permission you want on this file<br>Blank leaves the permissions alone.]]></description> </field> <field> <fielddescr>File Contents</fielddescr> <fieldname>filedata</fieldname> - <description>Paste the files contents here.</description> + <description>Leave blank to load an existing file from file system or paste the file content you want to save.</description> <type>textarea</type> <encoding>base64</encoding> - <cols>60</cols> - <rows>30</rows> + <cols>75</cols> + <rows>25</rows> <required/> </field> + <field> + <type>listtopic</type> + <fieldname>temp</fieldname> + <name>cmd to run after file save/sync</name> + </field> + <field> + <fielddescr>script</fielddescr> + <fieldname>cmd</fieldname> + <description>Enter script or cmd to run after file save/sync</description> + <type>input</type> + <size>60</size> + </field> + <field> + <fielddescr>execute mode</fielddescr> + <fieldname>background</fieldname> + <type>select</type> + <options> + <option><name>Background (default)</name><value>background</value></option> + <option><name>Foreground</name><value>foreground</value></option> + <option><name>Do not run this script</name><value>disabled</value></option> + </options> + <description>Choose the way script will run.</description> + </field> </fields> <custom_php_install_command> filer_install(); </custom_php_install_command> <custom_php_command_before_form> </custom_php_command_before_form> + <custom_php_validation_command> + filer_validate_input($_POST, &$input_errors); + </custom_php_validation_command> <custom_delete_php_command> sync_package_filer(); </custom_delete_php_command> 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 <sullrich@gmail.com> - Copyright (C) 2011 Marcello Coutinho Copyright (C) 2011 Brian Scholer + Copyright (C) 2012 Marcello Coutinho All rights reserved. */ /* ========================================================================== */ @@ -50,7 +50,6 @@ <tab> <text>Files</text> <url>/pkg.php?xml=filer.xml</url> - <active/> </tab> <tab> <text>XMLRPC Sync</text> diff --git a/pkg_config.7.xml b/pkg_config.7.xml index bed6827e..519eb499 100755 --- a/pkg_config.7.xml +++ b/pkg_config.7.xml @@ -9,7 +9,7 @@ <category>File Management</category> <pkginfolink>http://doc.pfsense.org/index.php/Filer_package</pkginfolink> <config_file>http://www.pfsense.com/packages/config/filer/filer.xml</config_file> - <version>0.50</version> + <version>0.60</version> <status>Beta</status> <required_version>1.2.3</required_version> <maintainer>bscholer@cshl.edu</maintainer> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 4ffb82ff..5307a2a6 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -12,9 +12,9 @@ <category>File Management</category> <pkginfolink>http://doc.pfsense.org/index.php/Filer_package</pkginfolink> <config_file>http://www.pfsense.com/packages/config/filer/filer.xml</config_file> - <version>0.50</version> + <version>0.60</version> <status>Beta</status> - <required_version>1.2.3</required_version> + <required_version>2.0</required_version> <maintainer>bscholer@cshl.edu</maintainer> <configurationfile>filer.xml</configurationfile> </package> @@ -120,12 +120,12 @@ <descr>The Reliable, High Performance TCP/HTTP Load Balancer</descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>1.4.18 pkg v 1.2</version> + <version>1.4.19 pkg v 1.2</version> <status>Release</status> <required_version>2.0</required_version> <config_file>http://www.pfsense.com/packages/config/haproxy/haproxy.xml</config_file> <depends_on_package_base_url>http://e-sac.siteseguro.ws/pfsense/8/All/</depends_on_package_base_url> - <depends_on_package>haproxy-1.4.18.tbz</depends_on_package> + <depends_on_package>haproxy-1.4.19.tbz</depends_on_package> <configurationfile>haproxy.xml</configurationfile> <build_port_path>/usr/ports/net/haproxy</build_port_path> </package> @@ -135,12 +135,12 @@ <descr>The Reliable, High Performance TCP/HTTP Load Balancer package version 1.0</descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>1.4.18 pkg v 1.0</version> + <version>1.4.19 pkg v 1.0</version> <status>Release</status> <required_version>2.0</required_version> <config_file>http://www.pfsense.com/packages/config/haproxy-legacy/haproxy.xml</config_file> <depends_on_package_base_url>http://e-sac.siteseguro.ws/pfsense/8/All/</depends_on_package_base_url> - <depends_on_package>haproxy-1.4.18.tbz</depends_on_package> + <depends_on_package>haproxy-1.4.19.tbz</depends_on_package> <configurationfile>haproxy.xml</configurationfile> </package> <package> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 5328f3f6..1af6ea44 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -12,9 +12,9 @@ <category>File Management</category> <pkginfolink>http://doc.pfsense.org/index.php/Filer_package</pkginfolink> <config_file>http://www.pfsense.com/packages/config/filer/filer.xml</config_file> - <version>0.50</version> + <version>0.60</version> <status>Beta</status> - <required_version>1.2.3</required_version> + <required_version>2.0</required_version> <maintainer>bscholer@cshl.edu</maintainer> <configurationfile>filer.xml</configurationfile> </package> @@ -203,13 +203,13 @@ <descr>The Reliable, High Performance TCP/HTTP Load Balancer</descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>1.4.18 pkg v 1.2</version> + <version>1.4.19 pkg v 1.2</version> <status>Release</status> <required_version>2.0</required_version> <config_file>http://www.pfsense.com/packages/config/haproxy/haproxy.xml</config_file> <configurationfile>haproxy.xml</configurationfile> - <depends_on_package_base_url>http://e-sac.siteseguro.ws/pfsense/8/amd64/All/</depends_on_package_base_url> - <depends_on_package>haproxy-1.4.18.tbz</depends_on_package> + <depends_on_package_base_url>http://e-sac.siteseguro.ws/packages/8/amd64/All/</depends_on_package_base_url> + <depends_on_package>haproxy-1.4.19.tbz</depends_on_package> <build_port_path>/usr/ports/net/haproxy</build_port_path> </package> <package> @@ -218,13 +218,13 @@ <descr>The Reliable, High Performance TCP/HTTP Load Balancer package version 1.0</descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>1.4.18 pkg v 1.0</version> + <version>1.4.19 pkg v 1.0</version> <status>Release</status> <required_version>2.0</required_version> <config_file>http://www.pfsense.com/packages/config/haproxy-legacy/haproxy.xml</config_file> <configurationfile>haproxy.xml</configurationfile> - <depends_on_package_base_url>http://e-sac.siteseguro.ws/pfsense/8/amd64/All/</depends_on_package_base_url> - <depends_on_package>haproxy-1.4.18.tbz</depends_on_package> + <depends_on_package_base_url>http://e-sac.siteseguro.ws/packages/8/amd64/All/</depends_on_package_base_url> + <depends_on_package>haproxy-1.4.19.tbz</depends_on_package> </package> <package> |