From 97ab4e2426bca59bfacd597784545a4d57a9b28d Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 22 Jul 2010 18:35:02 +0200 Subject: [PATCH 1/7] bugfix in simple_permissions and modified test --- src/authm_mad/simple_permissions.rb | 4 +--- src/authm_mad/spec/simple_permissions_spec.rb | 14 +++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/authm_mad/simple_permissions.rb b/src/authm_mad/simple_permissions.rb index c6ff92205a..b12fa0e2be 100644 --- a/src/authm_mad/simple_permissions.rb +++ b/src/authm_mad/simple_permissions.rb @@ -33,8 +33,6 @@ class SimplePermissions end def auth(uid, tokens) - STDERR.puts [uid, tokens].inspect - result=true tokens.each do |token| @@ -60,7 +58,7 @@ class SimplePermissions when 'USE' if %w{VM NET IMAGE}.include? object - auth_result = ((owner == uid) || pub) + auth_result = ((owner == uid) | pub) elsif object == 'HOST' auth_result=true end diff --git a/src/authm_mad/spec/simple_permissions_spec.rb b/src/authm_mad/spec/simple_permissions_spec.rb index 67f6401c05..68c49621e2 100644 --- a/src/authm_mad/spec/simple_permissions_spec.rb +++ b/src/authm_mad/spec/simple_permissions_spec.rb @@ -19,6 +19,16 @@ require 'spec_common' require 'client_mock' require 'simple_permissions' +CONF=< Date: Thu, 22 Jul 2010 19:51:31 +0200 Subject: [PATCH 2/7] mad manager sent log before init response --- src/authm_mad/one_auth_mad.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index 565a6a7fd2..1c936ca0d2 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -57,10 +57,10 @@ class AuthorizationManager < OpenNebulaDriver driver=Kernel.const_get(driver_name.to_sym) @authenticate=driver.new - log('-', "Using '#{driver_prefix}' driver for authentication") + STDERR.puts "Using '#{driver_prefix}' driver for authentication" rescue - log('-', "Driver '#{driver_prefix}' not found, "<< - "using SimpleAuth instead") + STDERR.puts "Driver '#{driver_prefix}' not found, "<< + "using SimpleAuth instead" @authenticate=SimpleAuth.new end @@ -72,7 +72,6 @@ class AuthorizationManager < OpenNebulaDriver end def action_authenticate(request_id, user_id, user, password, token) - STDERR.puts [user_id, user, password, token].inspect auth=@authenticate.auth(user_id, user, password, token) if auth==true send_message('AUTHENTICATE', RESULT[:success], From 8647728a7a9abc6d350447e7003c21fb477873d1 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 22 Jul 2010 21:51:41 +0200 Subject: [PATCH 3/7] oneauth now does not use command_parse library --- src/authm_mad/oneauth | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/authm_mad/oneauth b/src/authm_mad/oneauth index 90ce26c5a2..0381424125 100755 --- a/src/authm_mad/oneauth +++ b/src/authm_mad/oneauth @@ -32,17 +32,17 @@ $: << RUBY_LIB_LOCATION require 'OpenNebula' -require 'client_utilities' -require 'command_parse' require 'rubygems' require 'sequel' require 'quota' require 'ssh_auth' -class OneAuthCli < CommandParse - - COMMANDS_HELP=<<-EOT + +COMMANDS_HELP=<<-EOT +Usage: + oneauth [] + Commands: * create (Creates a new user) @@ -56,22 +56,14 @@ Commands: * key (gets public key) oneauth key + +* help (prints help) + oneauth help EOT - def text_commands - COMMANDS_HELP - end - - def text_command_name - "oneauth" - end - - def list_options - table=ShowTable.new(ShowTableUP) - table.print_help - end - +def print_help + puts COMMANDS_HELP end def get_database @@ -88,9 +80,6 @@ def add_quota(uid, cpu, memory) quota.set(uid.to_i, cpu.to_f, memory.to_i, nil) end -oneauth_opts=OneAuthCli.new -oneauth_opts.parse(ARGV) -ops=oneauth_opts.options result=[false, "Unknown error"] @@ -143,8 +132,12 @@ when "key" exit 0 +when "help" + print_help + exit 0 + else - oneauth_opts.print_help + print_help exit -1 end From 5026d0a31d0e8ae15f20b3d5342f9b773ae5e2bb Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 22 Jul 2010 21:51:59 +0200 Subject: [PATCH 4/7] install oneauth command in bin directory --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 7fdffd0d61..8dcd2a4298 100755 --- a/install.sh +++ b/install.sh @@ -261,7 +261,8 @@ BIN_FILES="src/nebula/oned \ src/cli/oneuser \ src/cli/oneimage \ src/cli/onecluster \ - share/scripts/one" + share/scripts/one \ + src/authm_mad/oneauth" #------------------------------------------------------------------------------- # C/C++ OpenNebula API Library & Development files From a3f5d32b3dcfe89d58d2305b368af18fdf794afc Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 23 Jul 2010 13:26:23 +0200 Subject: [PATCH 5/7] Added documentation for simple authentication --- src/authm_mad/simple_auth.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/authm_mad/simple_auth.rb b/src/authm_mad/simple_auth.rb index 793890c6c2..5656932a39 100644 --- a/src/authm_mad/simple_auth.rb +++ b/src/authm_mad/simple_auth.rb @@ -14,16 +14,19 @@ # limitations under the License. # #--------------------------------------------------------------------------- # - +# Password authentication module. This one just compares stored password +# with the token sent by the client. class SimpleAuth - def initialize - end - + # Method called by authentication driver. It should awnser true if + # successful or a string with the error message if failure. All + # parameters are string extracted from the authorization message. + # + # * user_id: OpenNebula user identifier + # * user: user name + # * password: password stored in OpenNebula dabatase + # * token: password sent by the client trying to connect def auth(user_id, user, password, token) - STDERR.puts [user_id, user, password, token].inspect - STDERR.flush t_user, t_password=token.split(':') - #auth=(user==t_user && password==t_password) auth=(password==token) auth="Invalid credentials" if auth!=true auth From 3c12f15607ee2aea91832f5490cb811726c90ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Jul 2010 11:40:44 +0200 Subject: [PATCH 6/7] bug #288: Fixes states mapping for oneimage. --- src/oca/ruby/OpenNebula/Image.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/oca/ruby/OpenNebula/Image.rb b/src/oca/ruby/OpenNebula/Image.rb index 3d64c49131..a699b406c9 100644 --- a/src/oca/ruby/OpenNebula/Image.rb +++ b/src/oca/ruby/OpenNebula/Image.rb @@ -16,11 +16,10 @@ module OpenNebula :delete => "image.delete" } - IMAGE_STATES=%w{INIT LOCKED READY USED DISABLED} + IMAGE_STATES=%w{INIT READY USED DISABLED} SHORT_IMAGE_STATES={ "INIT" => "init", - "LOCKED" => "lock", "READY" => "rdy", "USED" => "used", "DISABLED" => "disa" From 62bf916c7b0d411360c159f515096466ea8c0767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Jul 2010 11:47:51 +0200 Subject: [PATCH 7/7] bug #290: Fixed dd option, and more generic binaries search. --- src/oca/ruby/OpenNebula/Image.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/oca/ruby/OpenNebula/Image.rb b/src/oca/ruby/OpenNebula/Image.rb index a699b406c9..b3c9f53917 100644 --- a/src/oca/ruby/OpenNebula/Image.rb +++ b/src/oca/ruby/OpenNebula/Image.rb @@ -180,8 +180,8 @@ module OpenNebula # Constants and Class Methods # --------------------------------------------------------------------- FS_UTILS = { - :dd => "/bin/dd", - :mkfs => "/bin/mkfs" + :dd => "env dd", + :mkfs => "env mkfs" } def copy(path, source) @@ -221,7 +221,7 @@ module OpenNebula command = "" command << FS_UTILS[:dd] command << " if=/dev/zero of=#{source} ibs=1 count=1" - command << " obs=1048576 oseek=#{size}" + command << " obs=1048576 seek=#{size}" local_command=LocalCommand.run(command)