From 200bd3eefa95b80ab43d11b6d67d6aa97f9c17ec Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 22 Mar 2017 06:38:05 +0100 Subject: [PATCH] plugins: protect against faulty updates Switching the tty causes the terminal to exit, which means the package upgrade jobs are not done, leaving files in the system that shouldn't be there. The $search parameter is unused. --- src/etc/inc/plugins.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/plugins.inc b/src/etc/inc/plugins.inc index 2b419a859..8a86b4888 100644 --- a/src/etc/inc/plugins.inc +++ b/src/etc/inc/plugins.inc @@ -30,9 +30,10 @@ * scan plugins for legacy system * @return array */ -function plugins_scan($search = '') +function plugins_scan() { $path = '/usr/local/etc/inc/plugins.inc.d/'; + $clash = '/usr/local/etc/inc/'; $ext = '.inc'; $ret = array(); @@ -47,7 +48,8 @@ function plugins_scan($search = '') foreach ($plugins as $plugin) { $name = preg_replace('/' . preg_quote($path, '/') . '/', '', $plugin); $name = preg_replace('/' . preg_quote($ext, '/') . '/', '', $name); - if (!empty($search) && $search !== $name) { + /* if the old file still exists upgrade went wrong */ + if (file_exists($clash . $name . $ext)) { continue; } $ret[$name] = $plugin;