diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-07-24 12:42:23 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-07-24 12:42:23 +0200 |
commit | f9f1333e4c741451a8b53031812fcbdb167b4731 (patch) | |
tree | a698b879f41216143a1b9dcf721852cd3587e545 /python/vyos/util.py | |
parent | f70623bd8fbacc2a480acdf616641f0931d0f5e7 (diff) | |
download | vyos-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.py | 9 |
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) |