diff --git a/src/sunstone/OpenNebulaVNC.rb b/src/sunstone/OpenNebulaVNC.rb index 120f2a1745..66456634fa 100644 --- a/src/sunstone/OpenNebulaVNC.rb +++ b/src/sunstone/OpenNebulaVNC.rb @@ -190,6 +190,10 @@ class OpenNebulaVNC def proxy(vm_resource) # Check configurations and VM attributes + unless is_lockfile? + return error(400, "VNC Proxy is not running") + end + if !is_running? return error(400, "VNC Proxy is not running") end @@ -344,6 +348,20 @@ class OpenNebulaVNC end alias_method :get_pid, :is_running? + def is_lockfile? + dn = File.dirname(@lock_file) + bn = File.basename(@lock_file) + + # Due to restrictions which doesn't allow to stat the lock file + # when Sunstone is running under Apache with SELinux enabled, + # as a workaround we read content of the whole lock directory. + begin + Dir.entries(dn).include?(bn) + rescue StandardError + false + end + end + if RUBY_VERSION<'1.9' def spawn(*args) fork {