From 7bde8d909ec9b2cabd3ab6366ea33d8f52e8e2fc Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 11 Jan 2010 14:13:28 -0500 Subject: correctly mark content type of simple files For user data that is not a mime message, we were not applying the starts with rules. In fact, they were not getting applied at all. Other fix here is to have the 'main' function decompress input --- ec2init/UserDataHandler.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ec2init/UserDataHandler.py b/ec2init/UserDataHandler.py index 71bc3203..0ab1bbec 100644 --- a/ec2init/UserDataHandler.py +++ b/ec2init/UserDataHandler.py @@ -40,15 +40,17 @@ def process_includes(msg,parts): # multipart/* are just containers if part.get_content_maintype() == 'multipart': continue - ctype = part.get_content_type() payload = part.get_payload() + ctype = None + for str, gtype in starts_with_mappings.items(): + if payload.startswith(str): + ctype = gtype + break + if ctype is None: - ctype = 'application/octet-stream' - for str, gtype in starts_with_mappings.items(): - if payload.startswith(str): - ctype = gtype + ctype = part.get_content_type() if ctype == 'text/x-include-url': do_include(payload,parts) @@ -118,7 +120,7 @@ def walk_userdata(str, callbacks, data = None): if __name__ == "__main__": import sys - data = file(sys.argv[1]).read() + data = decomp_str(file(sys.argv[1]).read()) parts = { } process_includes(email.message_from_string(data),parts) print "#found %s parts" % len(parts['content']) -- cgit v1.2.3