From f9f1333e4c741451a8b53031812fcbdb167b4731 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 24 Jul 2018 12:42:23 +0200 Subject: Add a validator for scripts that are supposed to be in /config --- python/vyos/util.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'python/vyos/util.py') diff --git a/python/vyos/util.py b/python/vyos/util.py index 1419e490b..8b5342575 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . +import os import re import grp import psutil @@ -122,3 +123,11 @@ def seconds_to_human(s, separator=""): def get_cfg_group_id(): group_data = grp.getgrnam(vyos.defaults.cfg_group) return group_data.gr_gid + +def file_is_persistent(path): + if not re.match(r'^(/config|/opt/vyatta/etc/config)', os.path.dirname(path)): + warning = "Warning: file {0} is outside the /config directory\n".format(path) + warning += "It will not be automatically migrated to a new image on system update" + return (False, warning) + else: + return (True, None) -- cgit v1.2.3