From 08235013e5c950967fc807ba9f14e408aa0c9302 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 4 Apr 2020 22:14:12 +0200 Subject: vyos.util: rename chmod_x_file() to chmod_x() Now both files and directories are supported. --- python/vyos/util.py | 4 ++-- src/conf_mode/interfaces-pppoe.py | 10 +++++----- src/conf_mode/interfaces-wirelessmodem.py | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/vyos/util.py b/python/vyos/util.py index 781fd9a2c..c8ab43c11 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -81,11 +81,11 @@ def chown_file(path, user, group): os.chown(path, uid, gid) -def chmod_x_file(path): +def chmod_x(path): """ make file executable """ from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH - if os.path.isfile(path): + if os.path.exists(path): bitmask = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | \ S_IROTH | S_IXOTH os.chmod(path, bitmask) diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 37934263c..a396af4ea 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -24,7 +24,7 @@ from netifaces import interfaces from vyos.config import Config from vyos.defaults import directories as vyos_data_dir from vyos.ifconfig import Interface -from vyos.util import chown_file, chmod_x_file, subprocess_cmd +from vyos.util import chown_file, chmod_x, subprocess_cmd from vyos import ConfigError default_config_data = { @@ -223,10 +223,10 @@ def generate(pppoe): f.write(config_text) # make generated script file executable - chmod_x_file(script_pppoe_pre_up) - chmod_x_file(script_pppoe_ip_up) - chmod_x_file(script_pppoe_ip_down) - chmod_x_file(script_pppoe_ipv6_up) + chmod_x(script_pppoe_pre_up) + chmod_x(script_pppoe_ip_up) + chmod_x(script_pppoe_ip_down) + chmod_x(script_pppoe_ipv6_up) return None diff --git a/src/conf_mode/interfaces-wirelessmodem.py b/src/conf_mode/interfaces-wirelessmodem.py index d00259bf5..9b6de2d12 100755 --- a/src/conf_mode/interfaces-wirelessmodem.py +++ b/src/conf_mode/interfaces-wirelessmodem.py @@ -23,7 +23,7 @@ from netifaces import interfaces from vyos.config import Config from vyos.defaults import directories as vyos_data_dir -from vyos.util import chown_file, chmod_x_file, subprocess_cmd +from vyos.util import chown_file, chmod_x, subprocess_cmd from vyos import ConfigError default_config_data = { @@ -197,9 +197,9 @@ def generate(wwan): f.write(config_text) # make generated script file executable - chmod_x_file(script_wwan_pre_up) - chmod_x_file(script_wwan_ip_up) - chmod_x_file(script_wwan_ip_down) + chmod_x(script_wwan_pre_up) + chmod_x(script_wwan_ip_up) + chmod_x(script_wwan_ip_down) return None -- cgit v1.2.3