Check result of file metadata changes

Changing ownership and permissions is not supported on all filesystems.
This patch prints a warning whenever it fails to set these properties,
but continues without a fatal error.
This commit is contained in:
David Klaftenegger 2016-02-13 00:57:28 +01:00 committed by Markus Hauschild
parent e8c82197a9
commit b396f0bb07
1 changed files with 8 additions and 2 deletions

View File

@ -191,8 +191,14 @@ def cert_put(domain, settings):
# set owner and permissions
uid = pwd.getpwnam(crt_user).pw_uid
gid = grp.getgrnam(crt_group).gr_gid
os.chown(crt_path, uid, gid)
os.chmod(crt_path, int(crt_perm, 8))
try:
os.chown(crt_path, uid, gid)
except OSError:
print('Warning: Could not set certificate file ownership!')
try:
os.chmod(crt_path, int(crt_perm, 8))
except OSError:
print('Warning: Could not set certificate file permissions!')
# restart/reload service
subprocess.call(crt_notify.split())