diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-09 15:08:27 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-07-09 15:08:27 -0400 |
commit | 492dc7478e0ab3eb03eb3b0b5d0e47812339b83f (patch) | |
tree | 1e18f51424a4a72a2733af535cde770501af1f14 /cloudinit/stages.py | |
parent | 285e127de45f0feed7170bafc79b502170d5b381 (diff) | |
download | vyos-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/stages.py')
-rw-r--r-- | cloudinit/stages.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py index 8fd6aa5d..3beeb36e 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -133,12 +133,24 @@ class Init(object): if log_file: util.ensure_file(log_file) if perms: - (u, g) = perms.split(':', 1) - if u == "-1" or u == "None": + perms_parted = perms.split(':', 1) + u = perms_parted[0] + if len(perms_parted) == 2: + g = perms_parted[1] + else: + g = '' + u = u.strip() + g = g.strip() + if u == "-1" or u.lower() == "none": u = None - if g == "-1" or g == "None": + if g == "-1" or g.lower() == "none": g = None - util.chownbyname(log_file, u, g) + try: + util.chownbyname(log_file, u, g) + except OSError: + util.logexc(LOG, ("Unable to change the ownership" + " of %s to user %s, group %s"), + log_file, u, g) def read_cfg(self, extra_fns=None): # None check so that we don't keep on re-loading if empty |