From b421a874e08b0d200cd1fc6675c3d78bcacfea2d Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 28 Jul 2011 12:39:40 +0200 Subject: [PATCH] feature #754: simple driver that implements plain auth (that in OpenNebula core). Removed debug messages --- install.sh | 4 +++ src/authm_mad/one_auth_mad.rb | 2 ++ src/authm_mad/remotes/plain/authenticate | 41 +++++++++++++++--------- src/um/UserPool.cc | 3 -- 4 files changed, 31 insertions(+), 19 deletions(-) mode change 100644 => 100755 src/authm_mad/remotes/plain/authenticate diff --git a/install.sh b/install.sh index 709205e2d3..4f10e88013 100755 --- a/install.sh +++ b/install.sh @@ -224,6 +224,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/image \ $VAR_LOCATION/remotes/image/fs \ $VAR_LOCATION/remotes/auth \ + $VAR_LOCATION/remotes/auth/plain \ $VAR_LOCATION/remotes/auth/ssh" SUNSTONE_DIRS="$SUNSTONE_LOCATION/models \ @@ -317,6 +318,7 @@ INSTALL_FILES=( IM_PROBES_XEN_FILES:$VAR_LOCATION/remotes/im/xen.d IM_PROBES_GANGLIA_FILES:$VAR_LOCATION/remotes/im/ganglia.d AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh + AUTH_PLAIN_FILES:$VAR_LOCATION/remotes/auth/plain VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm VMM_EXEC_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll @@ -577,6 +579,8 @@ IM_PROBES_GANGLIA_FILES="src/im_mad/remotes/ganglia.d/ganglia_probe" #------------------------------------------------------------------------------- AUTH_SSH_FILES="src/authm_mad/remotes/ssh/authenticate" +AUTH_PLAIN_FILES="src/authm_mad/remotes/plain/authenticate" + #------------------------------------------------------------------------------- # Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands # - NFS TM, $LIB_LOCATION/tm_commands/nfs diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index 233f58a4de..43b52cd5ca 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -111,6 +111,8 @@ class AuthDriver < OpenNebulaDriver requests.flatten! + #OpenNebula.log_debug("#{request_id} #{user_id} #{requests}") + if @authZ_cmd == nil if requests[-1] == "1" result = RESULT[:success] diff --git a/src/authm_mad/remotes/plain/authenticate b/src/authm_mad/remotes/plain/authenticate old mode 100644 new mode 100755 index 749da483cb..98649b57d7 --- a/src/authm_mad/remotes/plain/authenticate +++ b/src/authm_mad/remotes/plain/authenticate @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + # -------------------------------------------------------------------------- # # Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # # # @@ -14,22 +16,29 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -# Password authentication module. This one just compares stored password -# with the token sent by the client. -class SimpleAuth - # Method called by authentication driver. It should awnser true if - # successful or a string with the error message if failure. All - # parameters are strings 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) - auth=(password==token) - auth="Invalid credentials" if auth!=true or token=='-' - auth - end +ONE_LOCATION=ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" + ETC_LOCATION="/etc/one/" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" + ETC_LOCATION=ONE_LOCATION+"/etc/" end +$: << RUBY_LIB_LOCATION +require 'scripts_common' + +user = ARGV[0] +pass = ARGV[1] +secret = ARGV[2] + +#OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})") + +if pass == secret + exit 0 +else + OpenNebula.error_message "Invalid credentials" + exit -1 +end diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 4adba6427b..746e898346 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -253,9 +253,6 @@ bool UserPool::authenticate(const string& session, ar.add_authenticate(username,u_pass,secret); - NebulaLog::log("AuM********",Log::ERROR,username); - NebulaLog::log("AuM*********",Log::ERROR,u_pass); - NebulaLog::log("AuM**********",Log::ERROR,secret); if ( uid == 0 ) //oneadmin { if (ar.plain_authenticate())