Backlog #458

Check the file type when executing onevm create

Added by Gian Uberto Lauri over 10 years ago. Updated over 6 years ago.

Status:ClosedStart date:12/23/2010
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:CLIEstimated time:2.00 hours
Target version:-

Description

If something can go wrong, something will go wrong. If an user can do a stupid thing, an user will do that stupid thing.

When the stupid thing is issuing the onevm create command passing the name of an image file instead of a template field, it hurts at kernel level on the front end machine. Adding a file check (at least under *nix & GNU Linux) is really easy

-bash-3.2$ file one-images/quickposta-0.1.qemu
one-images/quickposta-0.1.qemu: x86 boot sector; partition 1: ID=0x82, starthead 1, startsector 63, 497952 sectors; partition 2: ID=0x83, starthead 0, startsector 498015, 3694950 sectors, code offset 0x48
-bash-3.2$ file one-templates/quickposta-0.1.one
one-templates/quickposta-0.1.one: ASCII text

According to http://stackoverflow.com/questions/51572/determine-file-type-in-ruby, there should be a ruby way to perform this using libmagic ruby bindings, available via gem (gem install ruby-filemagic).

0001-oneimage-try-to-catch-mistakes-by-refusing-image-tem.patch Magnifier - simple patch to reject large image templates (789 Bytes) Stefan Praszalowicz, 01/06/2011 03:06 PM


Related issues

Related to Feature #1353: Improve CLI commands Closed 07/12/2012

Associated revisions

Revision 36fb636d
Added by Abel Coronado almost 4 years ago

B #5347: Solved bug VM Template disk advanced params layout error (#458)

Revision 92fbdb3d
Added by Abel Coronado almost 4 years ago

B #5347: Solved bug VM Template disk advanced params layout error (#458)

(cherry picked from commit 36fb636d20f81463cd4ac2e02c4069186532bdd0)

History

#1 Updated by Stefan Praszalowicz over 10 years ago

I agree, as I made the same mistake a few times... I used a simple patch to avoid further issues:

diff --git a/src/cli/oneimage b/src/cli/oneimage
index abb6305..ea53753 100755
--- a/src/cli/oneimage
+++ b/src/cli/oneimage
@ -299,6 +299,11 @ def get_user_flags
end

def get_template(template_path)
+ if File.size?(ARGV[0]) > 1048576
+ puts "Template #{ARGV[0]} is a very large file, this looks like a mistake"
+ exit -1
+ end
+
begin
template = File.read(ARGV[0])
rescue

#2 Updated by Stefan Praszalowicz over 10 years ago

oops.. properly formatted patch against one-2.0 attached

#3 Updated by Ruben S. Montero about 8 years ago

  • Category set to CLI

#4 Updated by Ruben S. Montero about 8 years ago

  • Priority changed from Normal to Low

#5 Updated by Ruben S. Montero over 7 years ago

  • Tracker changed from Feature to Backlog
  • Status changed from New to Pending

#6 Updated by Ruben S. Montero over 7 years ago

  • Priority changed from Low to Normal

#7 Updated by Ruben S. Montero over 6 years ago

  • Status changed from Pending to Closed

Now that we can use options for commands I'm closing this one...

Also available in: Atom PDF