From b1d0505eef8c0d30e20adb2d514f7f135acc5e9d Mon Sep 17 00:00:00 2001 From: bmeeks8 Date: Sat, 20 Sep 2014 17:46:01 -0400 Subject: Replace '/bin/rm' calls with rmdir_recursive() function. --- config/suricata/suricata_blocked.php | 2 +- config/suricata/suricata_check_for_rule_updates.php | 6 +++--- config/suricata/suricata_download_updates.php | 2 +- config/suricata/suricata_interfaces.php | 4 ++-- config/suricata/suricata_uninstall.php | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'config') diff --git a/config/suricata/suricata_blocked.php b/config/suricata/suricata_blocked.php index 842d4073..8f708a14 100644 --- a/config/suricata/suricata_blocked.php +++ b/config/suricata/suricata_blocked.php @@ -126,7 +126,7 @@ if ($_POST['download']) // Clean up the temp files and directory @unlink("/tmp/{$file_name}"); - exec("/bin/rm -fr /tmp/suricata_blocked"); + rmdir_recursive("/tmp/suricata_blocked"); } else $savemsg = gettext("An error occurred while creating archive"); } else diff --git a/config/suricata/suricata_check_for_rule_updates.php b/config/suricata/suricata_check_for_rule_updates.php index 065825b6..b38ebf3d 100644 --- a/config/suricata/suricata_check_for_rule_updates.php +++ b/config/suricata/suricata_check_for_rule_updates.php @@ -405,7 +405,7 @@ function suricata_fetch_new_rules($file_url, $file_dst, $file_md5, $desc = "") { /* remove old $tmpfname files if present */ if (is_dir("{$tmpfname}")) - exec("/bin/rm -r {$tmpfname}"); + rmdir_recursive("{$tmpfname}"); /* Make sure required suricatadirs exsist */ exec("/bin/mkdir -p {$suricatadir}rules"); @@ -415,7 +415,7 @@ exec("/bin/mkdir -p {$suricatalogdir}"); /* See if we need to automatically clear the Update Log based on 1024K size limit */ if (file_exists($suricata_rules_upd_log)) { if (1048576 < filesize($suricata_rules_upd_log)) - exec("/bin/rm -r {$suricata_rules_upd_log}"); + unlink_if_exists("{$suricata_rules_upd_log}"); } /* Log start time for this rules update */ @@ -753,7 +753,7 @@ if (is_dir("{$tmpfname}")) { update_status(gettext("Cleaning up after rules extraction...")); update_output_window(gettext("Removing {$tmpfname} directory...")); } - exec("/bin/rm -r {$tmpfname}"); + rmdir_recursive("{$tmpfname}"); } if ($pkg_interface <> "console") { diff --git a/config/suricata/suricata_download_updates.php b/config/suricata/suricata_download_updates.php index 2b8d6e3c..9426099f 100644 --- a/config/suricata/suricata_download_updates.php +++ b/config/suricata/suricata_download_updates.php @@ -116,7 +116,7 @@ if ($snortcommunityrules == 'on' && file_exists("{$suricatadir}{$snort_community /* Check for postback to see if we should clear the update log file. */ if ($_POST['clear']) { if (file_exists("{$suricata_rules_upd_log}")) - mwexec("/bin/rm -f {$suricata_rules_upd_log}"); + unlink_if_exists("{$suricata_rules_upd_log}"); } if ($_POST['update']) { diff --git a/config/suricata/suricata_interfaces.php b/config/suricata/suricata_interfaces.php index 3d093d45..5a6a58c2 100644 --- a/config/suricata/suricata_interfaces.php +++ b/config/suricata/suricata_interfaces.php @@ -68,8 +68,8 @@ if ($_POST['del_x']) { $if_real = get_real_interface($a_nat[$rulei]['interface']); $suricata_uuid = $a_nat[$rulei]['uuid']; suricata_stop($a_nat[$rulei], $if_real); - exec("/bin/rm -r {$suricatalogdir}suricata_{$if_real}{$suricata_uuid}"); - exec("/bin/rm -r {$suricatadir}suricata_{$suricata_uuid}_{$if_real}"); + rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}"); + rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_{$if_real}"); unset($a_nat[$rulei]); } conf_mount_ro(); diff --git a/config/suricata/suricata_uninstall.php b/config/suricata/suricata_uninstall.php index c7023ec6..e55a43b2 100644 --- a/config/suricata/suricata_uninstall.php +++ b/config/suricata/suricata_uninstall.php @@ -81,15 +81,15 @@ install_cron_job("{$suri_pf_table}" , false); if ($config['installedpackages']['suricata']['config'][0]['clearlogs'] == 'on') { log_error(gettext("[Suricata] Clearing all Suricata-related log files...")); @unlink("{$suricata_rules_upd_log}"); - mwexec("/bin/rm -rf {$suricatalogdir}"); + rmdir_recursive("{$suricatalogdir}"); } // Mount filesystem read-write to remove our files conf_mount_rw(); /* Remove the Suricata GUI app directories */ -mwexec("/bin/rm -rf /usr/local/pkg/suricata"); -mwexec("/bin/rm -rf /usr/local/www/suricata"); +rmdir_recursive("/usr/local/pkg/suricata"); +rmdir_recursive("/usr/local/www/suricata"); /* Remove our associated Dashboard widget config and files. */ /* If "save settings" is enabled, then save old widget */ @@ -125,9 +125,9 @@ if ($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] ! unset($config['installedpackages']['suricata']); unset($config['installedpackages']['suricatasync']); @unlink("{$suricata_rules_upd_log}"); - mwexec("/bin/rm -rf {$suricatalogdir}"); - mwexec("/bin/rm -rf {$sidmodspath}"); - mwexec("/bin/rm -rf {$iprep_path}"); + rmdir_recursive("{$suricatalogdir}"); + rmdir_recursive("{$sidmodspath}"); + rmdir_recursive("{$iprep_path}"); log_error(gettext("[Suricata] The package has been removed from this system...")); } -- cgit v1.2.3