diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-02 19:11:46 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-02 19:11:46 -0700 |
commit | 7e1a250d70c39607bc1f3e3134d6331cd372f511 (patch) | |
tree | 6f7532f9d77c561f4fe32e8bbad8a8ffea1272be | |
parent | f99dd7c2e43f9117c66e06fc31d10f559c912e86 (diff) | |
download | vyos-cloud-init-7e1a250d70c39607bc1f3e3134d6331cd372f511.tar.gz vyos-cloud-init-7e1a250d70c39607bc1f3e3134d6331cd372f511.zip |
Add a check on the filename provided ensuring it actually exists.
-rwxr-xr-x | tools/mock-meta.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/mock-meta.py b/tools/mock-meta.py index 8a73b43c..5f421c98 100755 --- a/tools/mock-meta.py +++ b/tools/mock-meta.py @@ -8,6 +8,7 @@ import functools import httplib import json import logging +import os import random import string import sys @@ -312,13 +313,15 @@ def extract_opts(): parser.add_option("-p", "--port", dest="port", action="store", type=int, default=80, help="port from which to serve traffic (default: %default)", metavar="PORT") parser.add_option("-f", '--user-data-file', dest='user_data_file', action='store', - help="user data blob to serve back to incoming requests", metavar='FILE') + help="user data filename to serve back to incoming requests", metavar='FILE') (options, args) = parser.parse_args() out = dict() out['extra'] = args out['port'] = options.port out['user_data_file'] = None if options.user_data_file: + if not os.path.isfile(options.user_data_file): + parser.error("Option -f specified a non-existent file") out['user_data_file'] = options.user_data_file return out |