summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_write_files.py
diff options
context:
space:
mode:
authorAndrew Jorgensen <ajorgens@amazon.com>2014-12-05 14:34:10 -0800
committerScott Moser <smoser@brickies.net>2017-06-15 13:20:58 -0400
commit0fe6a0607408d387f4b0d4482b95afbc5d3f3909 (patch)
treee93fe72e4dd1b27d1331ae70c16042b8ecadc2ee /cloudinit/config/cc_write_files.py
parentb23d9d7c5c112612dbaaf8c8371c9e735500b2eb (diff)
downloadvyos-cloud-init-0fe6a0607408d387f4b0d4482b95afbc5d3f3909.tar.gz
vyos-cloud-init-0fe6a0607408d387f4b0d4482b95afbc5d3f3909.zip
write_file(s): Print permissions as octal, not decimal
Unix file modes are usually represented as octal, but they were being interpreted as decimal, for example 0o644 would be printed as '420'. Reviewed-by: Tom Kirchner <tjk@amazon.com>
Diffstat (limited to 'cloudinit/config/cc_write_files.py')
-rw-r--r--cloudinit/config/cc_write_files.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/cloudinit/config/cc_write_files.py b/cloudinit/config/cc_write_files.py
index 72e1cdd6..1835a31b 100644
--- a/cloudinit/config/cc_write_files.py
+++ b/cloudinit/config/cc_write_files.py
@@ -53,6 +53,7 @@ import six
from cloudinit.settings import PER_INSTANCE
from cloudinit import util
+
frequency = PER_INSTANCE
DEFAULT_OWNER = "root:root"
@@ -119,7 +120,14 @@ def decode_perms(perm, default, log):
# Force to string and try octal conversion
return int(str(perm), 8)
except (TypeError, ValueError):
- log.warn("Undecodable permissions %s, assuming %s", perm, default)
+ reps = []
+ for r in (perm, default):
+ try:
+ reps.append("%o" % r)
+ except TypeError:
+ reps.append("%r" % r)
+ log.warning(
+ "Undecodable permissions {0}, returning default {1}".format(*reps))
return default