From 3c2ae9dc4046fd240e63cea08f4f7e59a6896b6b Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Mon, 14 Jun 2021 09:37:17 -0500 Subject: [PATCH] Binder#parse - allow for symlinked unix path, add create_activated_fds debug ENV When systemd creates a UNIXSocket with a path that is contained in a symlinked directory, Ruby may read the path as the real path. --- lib/puma/binder.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index 0c209e4772..7507c92af1 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -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)) @@ -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}"