From d31b765993b6351e51e2bbd8b211cfb2f12a29e7 Mon Sep 17 00:00:00 2001 From: Tomas Jelinek Date: Thu, 4 Aug 2022 13:21:44 +0200 Subject: [PATCH] fix ruby socket permissions --- pcsd/rserver.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pcsd/rserver.rb b/pcsd/rserver.rb index e2c5e2a1..8115dafe 100644 --- a/pcsd/rserver.rb +++ b/pcsd/rserver.rb @@ -7,6 +7,26 @@ require 'thin' require 'settings.rb' +module Thin + module Backends + class UnixServer < Base + def connect + at_exit { remove_socket_file } # In case it crashes + old_umask = File.umask(0o077) + begin + EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection)) + # HACK EventMachine.start_unix_domain_server doesn't return the connection signature + # so we have to go in the internal stuff to find it. + @signature = EventMachine.instance_eval{@acceptors.keys.first} + ensure + File.umask(old_umask) + end + end + end + end +end + + def pack_response(response) return [200, {}, [response.to_json.to_str]] end -- 2.31.1