diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-09-18 01:06:31 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-09-18 01:06:31 +0000 |
commit | 7835a9325d329e2eac4fa5afa31ce4f4be7584ee (patch) | |
tree | 9e0a896ead4a4dcaef19f77ffdaa7186db7e80ef /src | |
parent | 06a46ccf084a77eee183fba9f7aa7a609c1070bf (diff) | |
download | bcfg2-7835a9325d329e2eac4fa5afa31ce4f4be7584ee.tar.gz bcfg2-7835a9325d329e2eac4fa5afa31ce4f4be7584ee.tar.bz2 bcfg2-7835a9325d329e2eac4fa5afa31ce4f4be7584ee.zip |
bcfg2-info: refuse to write build output outside of /tmp without -f flag (Resolves Ticket #737)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5439 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rwxr-xr-x | src/sbin/bcfg2-info | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 4b26d7890..31a5ff0f9 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -103,8 +103,16 @@ Usage: [quit|exit]""" def do_build(self, args): '''build client configuration''' - if len(args.split()) == 2: - client, ofile = args.split() + alist = args.split() + path_force = False + if '-f' in args: + alist.remove('-f') + path_force = True + if len(alist) == 2: + client, ofile = alist + if not ofile.startswith('/tmp') and not path_force: + print("Refusing to write files outside of /tmp without -f option") + return output = open(ofile, 'w') data = lxml.etree.tostring(self.BuildConfiguration(client), encoding='UTF-8', xml_declaration=True, @@ -112,7 +120,7 @@ Usage: [quit|exit]""" output.write(data) output.close() else: - print('Usage: build <hostname> <output file>') + print('Usage: build [-f] <hostname> <output file>') def do_buildall(self, args): if len(args.split()) != 1: |