Commit ae8d44fa authored by Franco Fichtner's avatar Franco Fichtner

src: remove globbing-related unlink_if_exists() usage

parent 1832a5a3
...@@ -204,7 +204,7 @@ function write_config($desc = 'Unknown', $backup = true) ...@@ -204,7 +204,7 @@ function write_config($desc = 'Unknown', $backup = true)
******/ ******/
function reset_factory_defaults($sync = true) function reset_factory_defaults($sync = true)
{ {
unlink_if_exists('/conf/*' . $filename); mwexec('/bin/rm -r /conf/*');
disable_security_checks(); disable_security_checks();
setup_serial_port(); setup_serial_port();
...@@ -217,7 +217,8 @@ function reset_factory_defaults($sync = true) ...@@ -217,7 +217,8 @@ function reset_factory_defaults($sync = true)
} }
} }
function config_restore($conffile) { function config_restore($conffile)
{
global $config, $g; global $config, $g;
if (!file_exists($conffile)) if (!file_exists($conffile))
......
...@@ -2025,9 +2025,10 @@ function upgrade_054_to_055() { ...@@ -2025,9 +2025,10 @@ function upgrade_054_to_055() {
/* Let's save the RRD graphs after we run enable RRD graphing */ /* Let's save the RRD graphs after we run enable RRD graphing */
/* The function will restore the rrd.tgz so we will save it after */ /* The function will restore the rrd.tgz so we will save it after */
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd"); exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
unlink_if_exists("/var/db/rrd/*.xml"); mwexec('/bin/rm /var/db/rrd/*.xml');
if (file_exists("/var/run/booting")) if (file_exists("/var/run/booting")) {
echo "Updating configuration..."; echo "Updating configuration...";
}
} }
function upgrade_055_to_056() { function upgrade_055_to_056() {
......
...@@ -1034,21 +1034,6 @@ function mwexec_bg($command, $mute = false, $clearsigmask = false) ...@@ -1034,21 +1034,6 @@ function mwexec_bg($command, $mute = false, $clearsigmask = false)
mwexec("/usr/sbin/daemon -f {$command}", $mute, $clearsigmask); mwexec("/usr/sbin/daemon -f {$command}", $mute, $clearsigmask);
} }
/* unlink a file or directory, if it exists */
function unlink_if_exists($fn)
{
$to_do = glob($fn);
foreach($to_do as $filename) {
if (is_dir($filename)) {
/* rmdir() is not recursive... */
mwexecf('/bin/rm -r %s', $filename);
} else {
unlink($filename);
}
}
}
/* make a global alias table (for faster lookups) */ /* make a global alias table (for faster lookups) */
function alias_make_table($config) function alias_make_table($config)
{ {
......
...@@ -52,8 +52,8 @@ if ($_POST['apply']) { ...@@ -52,8 +52,8 @@ if ($_POST['apply']) {
$savemsg = $retval; $savemsg = $retval;
/* reset rrd queues */ /* reset rrd queues */
unlink_if_exists("/var/db/rrd/*queuedrops.rrd"); mwexec('/bin/rm /var/db/rrd/*queuedrops.rrd');
unlink_if_exists("/var/db/rrd/*queues.rrd"); mwexec('/bin/rm /var/db/rrd/*queues.rrd');
enable_rrd_graphing(); enable_rrd_graphing();
clear_subsystem_dirty('shaper'); clear_subsystem_dirty('shaper');
......
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