Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions lib/drb/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,17 @@ def self.parse_uri(uri) # :nodoc:
def self.open(uri, config)
host, port, = parse_uri(uri)
soc = TCPSocket.open(host, port)
ssl_conf = SSLConfig::new(config)
ssl_conf.setup_ssl_context
ssl = ssl_conf.connect(soc)
self.new(uri, ssl, ssl_conf, true)
stream = soc
begin
ssl_conf = SSLConfig::new(config)
ssl_conf.setup_ssl_context
ssl = ssl_conf.connect(soc)
stream = ssl
self.new(uri, ssl, ssl_conf, true)
rescue Exception
stream.close
raise
end
end

# Returns a DRb::DRbSSLSocket instance as a server-side connection, with
Expand All @@ -286,10 +293,15 @@ def self.open_server(uri, config)
port = soc.addr[1] if port == 0
@uri = "drbssl://#{host}:#{port}"

ssl_conf = SSLConfig.new(config)
ssl_conf.setup_certificate
ssl_conf.setup_ssl_context
self.new(@uri, soc, ssl_conf, false)
begin
ssl_conf = SSLConfig.new(config)
ssl_conf.setup_certificate
ssl_conf.setup_ssl_context
self.new(@uri, soc, ssl_conf, false)
rescue Exception
soc.close
raise
end
end

# This is a convenience method to parse +uri+ and separate out any
Expand Down
36 changes: 24 additions & 12 deletions lib/drb/unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,27 @@ def self.open_server(uri, config)
else
soc = UNIXServer.open(filename)
end
owner = config[:UNIXFileOwner]
group = config[:UNIXFileGroup]
if owner || group
require 'etc'
owner = Etc.getpwnam( owner ).uid if owner
group = Etc.getgrnam( group ).gid if group
File.chown owner, group, filename
end
mode = config[:UNIXFileMode]
File.chmod(mode, filename) if mode
begin
owner = config[:UNIXFileOwner]
group = config[:UNIXFileGroup]
if owner || group
require 'etc'
owner = Etc.getpwnam( owner ).uid if owner
group = Etc.getgrnam( group ).gid if group
File.chown owner, group, filename
end
mode = config[:UNIXFileMode]
File.chmod(mode, filename) if mode

self.new(uri, soc, config, true)
self.new(uri, soc, config, true)
rescue Exception
soc.close
begin
File.unlink(filename)
rescue Errno::ENOENT
end
raise
end
end

def self.uri_option(uri, config)
Expand Down Expand Up @@ -97,8 +106,11 @@ def close
shutdown # DRbProtocol#shutdown
path = @socket.path if @server_mode
@socket.close
File.unlink(path) if @server_mode
@socket = nil
begin
File.unlink(path) if @server_mode
rescue Errno::ENOENT
end
close_shutdown_pipe
end

Expand Down