From d00126c167fc06d913d99cfc184bf3402cb8cf53 Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Tue, 31 Mar 2020 17:57:23 +0200 Subject: Fix cloud-init ignoring some misdeclared mimetypes in user-data. On some platforms (old heat on OpenTelekomCloud), the user-data mime part is mislabeled x-shellscript. cloud-init would not accept this unexpected mime-type in multipart user-data. Cloud-init will now run find_ctype() on the content of the mime-part to check if it matches known include types. This patch is from Ryan Harper (inspired by my bug report and a suggestion from Scott Moser) from the discussion on PR #234. Signed-off-by: Kurt Garloff --- cloudinit/user_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cloudinit/user_data.py') diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index 6f41b03a..670dbee6 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -25,6 +25,7 @@ LOG = logging.getLogger(__name__) NOT_MULTIPART_TYPE = handlers.NOT_MULTIPART_TYPE PART_FN_TPL = handlers.PART_FN_TPL OCTET_TYPE = handlers.OCTET_TYPE +INCLUDE_MAP = handlers.INCLUSION_TYPES_MAP # Saves typing errors CONTENT_TYPE = 'Content-Type' @@ -115,7 +116,8 @@ class UserDataProcessor(object): # Attempt to figure out the payloads content-type if not ctype_orig: ctype_orig = UNDEF_TYPE - if ctype_orig in TYPE_NEEDED: + if ctype_orig in TYPE_NEEDED or (ctype_orig in + INCLUDE_MAP.values()): ctype = find_ctype(payload) if ctype is None: ctype = ctype_orig -- cgit v1.2.3