B #4392: Detect VNC proxy under Apache Passenger (#4432)

(cherry picked from commit 374b9f6845)
This commit is contained in:
Sergio Betanzos authored and Tino Vazquez committed 2020-03-31 16:45:54 +02:00
1 parent d5b3c20b92
commit 9dc27da0e6
1 file changed
+18
+18
View File
@@ -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 {