Catch exception during calling os.chmod in set_configs.py

set_perms may fail in some case, but it is not critical. Just leave a
warning rather than exit.

Change-Id: I757c7b60611fb6c0547bd1b26ec8a8af03684e5f
Closes-Bug: 1689454
This commit is contained in:
Jeffrey Zhang 2017-05-09 11:18:39 +08:00
parent 5841abe910
commit 97467c38c4
1 changed files with 7 additions and 1 deletions

View File

@ -354,7 +354,13 @@ def handle_permissions(config):
def set_perms(path, uid, gid):
LOG.info('Setting permission for %s', path)
os.chown(path, uid, gid)
if not os.path.exists(path):
LOG.warning('file %s do not exist', path)
return
try:
os.chown(path, uid, gid)
except OSError:
LOG.exception('Set file permission failed for %s', path)
for dest in glob.glob(path):
set_perms(dest, uid, gid)