summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-07-24 12:42:23 +0200
committerDaniil Baturin <daniil@baturin.org>2018-07-24 12:42:23 +0200
commitf9f1333e4c741451a8b53031812fcbdb167b4731 (patch)
treea698b879f41216143a1b9dcf721852cd3587e545 /python/vyos/util.py
parentf70623bd8fbacc2a480acdf616641f0931d0f5e7 (diff)
downloadvyos-1x-f9f1333e4c741451a8b53031812fcbdb167b4731.tar.gz
vyos-1x-f9f1333e4c741451a8b53031812fcbdb167b4731.zip
Add a validator for scripts that are supposed to be in /config
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r--python/vyos/util.py9
1 files changed, 9 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
+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)