summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-07-09 15:08:27 -0400
committerScott Moser <smoser@ubuntu.com>2012-07-09 15:08:27 -0400
commit492dc7478e0ab3eb03eb3b0b5d0e47812339b83f (patch)
tree1e18f51424a4a72a2733af535cde770501af1f14 /cloudinit/util.py
parent285e127de45f0feed7170bafc79b502170d5b381 (diff)
downloadvyos-cloud-init-492dc7478e0ab3eb03eb3b0b5d0e47812339b83f.tar.gz
vyos-cloud-init-492dc7478e0ab3eb03eb3b0b5d0e47812339b83f.zip
Update chownbyname to catch the key error when users/groups that are not known
are provided and rethrow it as a OSError (which seems reasonable) and adjust its usage in the log file touching/permission modification stage to catch this error and log it.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 44ce9770..e591e306 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -937,12 +937,9 @@ def chownbyname(fname, user=None, group=None):
uid = pwd.getpwnam(user).pw_uid
if group:
gid = grp.getgrnam(group).gr_gid
- except KeyError:
- logexc(LOG, ("Failed changing the ownership of %s using username %s "
- "and groupname %s (do they exist?)"), fname, user, group)
- return False
+ except KeyError as e:
+ raise OSError("Unknown user or group: %s" % (e))
chownbyid(fname, uid, gid)
- return True
# Always returns well formated values