From 12a67646986e89d94d1e41d410c7314488aa1cbe Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 8 Apr 2020 22:07:58 +0200 Subject: vyos-util: rename chown_file() > chown() ... to make it clear also directories can be chown(-ed) --- python/vyos/util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'python/vyos/util.py') diff --git a/python/vyos/util.py b/python/vyos/util.py index 16cfae92d..f1fb5ce27 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -93,16 +93,17 @@ def read_file(path): return data -def chown_file(path, user, group): - """ change file owner """ +def chown(path, user, group): + """ change file/directory owner """ from pwd import getpwnam from grp import getgrnam - if os.path.isfile(path): + if os.path.exists(path): uid = getpwnam(user).pw_uid gid = getgrnam(group).gr_gid os.chown(path, uid, gid) + def chmod_x(path): """ make file executable """ from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH -- cgit v1.2.3