Blame SOURCES/bz2116837-01-fix-ruby-socket-permissions.patch

4160ab
From ed61fee104f6f5a16917004f12b773a49f52ca60 Mon Sep 17 00:00:00 2001
4160ab
From: Tomas Jelinek <tojeline@redhat.com>
4160ab
Date: Wed, 10 Aug 2022 14:47:53 +0200
4160ab
Subject: [PATCH] fix ruby socket permissions
4160ab
4160ab
---
4160ab
 pcsd/rserver.rb | 23 +++++++++++++++++++++++
4160ab
 1 file changed, 23 insertions(+)
4160ab
4160ab
diff --git a/pcsd/rserver.rb b/pcsd/rserver.rb
4160ab
index c37f9df4..a54509fe 100644
4160ab
--- a/pcsd/rserver.rb
4160ab
+++ b/pcsd/rserver.rb
4160ab
@@ -7,6 +7,29 @@ require 'thin'
4160ab
 
4160ab
 require 'settings.rb'
4160ab
 
4160ab
+# Replace Thin::Backends::UnixServer:connect
4160ab
+# The only change is 'File.umask(0o777)' instead of 'File.umask(0)' to properly
4160ab
+# set python-ruby socket permissions
4160ab
+module Thin
4160ab
+  module Backends
4160ab
+    class UnixServer < Base
4160ab
+      def connect
4160ab
+        at_exit { remove_socket_file } # In case it crashes
4160ab
+        old_umask = File.umask(0o077)
4160ab
+        begin
4160ab
+          EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection))
4160ab
+          # HACK EventMachine.start_unix_domain_server doesn't return the connection signature
4160ab
+          #      so we have to go in the internal stuff to find it.
4160ab
+        @signature = EventMachine.instance_eval{@acceptors.keys.first}
4160ab
+        ensure
4160ab
+          File.umask(old_umask)
4160ab
+        end
4160ab
+      end
4160ab
+    end
4160ab
+  end
4160ab
+end
4160ab
+
4160ab
+
4160ab
 def pack_response(response)
4160ab
   return [200, {}, [response.to_json.to_str]]
4160ab
 end
4160ab
-- 
4160ab
2.37.1
4160ab