Skip to content

Commit

Permalink
Binder#parse - allow for symlinked unix path, add create_activated_fd…
Browse files Browse the repository at this point in the history
…s debug ENV (#2643)

When systemd creates a UNIXSocket with a path that is contained in a symlinked
directory, Ruby may read the path as the real path.
  • Loading branch information
MSP-Greg committed Jun 27, 2021
1 parent 4ff7d75 commit 8264d20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/puma/binder.rb
Expand Up @@ -96,6 +96,7 @@ def create_inherited_fds(env_hash)
# @version 5.0.0
#
def create_activated_fds(env_hash)
@events.debug "ENV['LISTEN_FDS'] #{ENV['LISTEN_FDS'].inspect} env_hash['LISTEN_PID'] #{env_hash['LISTEN_PID'].inspect}"
return [] unless env_hash['LISTEN_FDS'] && env_hash['LISTEN_PID'].to_i == $$
env_hash['LISTEN_FDS'].to_i.times do |index|
sock = TCPServer.for_fd(socket_activation_fd(index))
Expand Down Expand Up @@ -189,7 +190,8 @@ def parse(binds, logger, log_msg = 'Listening')
@unix_paths << path unless abstract
io = inherit_unix_listener path, fd
logger.log "* Inherited #{str}"
elsif sock = @activated_sockets.delete([ :unix, path ])
elsif sock = @activated_sockets.delete([ :unix, path ]) ||
@activated_sockets.delete([ :unix, File.realdirpath(path) ])
@unix_paths << path unless abstract || File.exist?(path)
io = inherit_unix_listener path, sock
logger.log "* Activated #{str}"
Expand Down

0 comments on commit 8264d20

Please sign in to comment.