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 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], 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 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 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=< "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" @@ -181,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) @@ -223,7 +222,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)