mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Fix and configure the perms of UNIXServer. Fixes #44
This commit is contained in:
parent
a94e0260a4
commit
3dd7049f49
3 changed files with 30 additions and 3 deletions
|
@ -77,6 +77,14 @@ Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance b
|
|||
|
||||
$ puma -b unix:///var/run/puma.sock
|
||||
|
||||
If you need to change the permissions of the UNIX socket, just add a umask parameter:
|
||||
|
||||
$ puma -b 'unix:///var/run/puma.sock?umask=0777'
|
||||
|
||||
Need a bit of security? Use SSL sockets!
|
||||
|
||||
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
||||
|
||||
## License
|
||||
|
||||
Puma is copyright 2011 Evan Phoenix and contributors. It is licensed under the BSD license. See the include LICENSE file for details.
|
||||
|
|
|
@ -243,7 +243,17 @@ module Puma
|
|||
log "* Listening on #{str}"
|
||||
path = "#{uri.host}#{uri.path}"
|
||||
|
||||
server.add_unix_listener path
|
||||
umask = nil
|
||||
|
||||
if uri.query
|
||||
params = Rack::Utils.parse_query uri.query
|
||||
if u = params['umask']
|
||||
# Use Integer() to respect the 0 prefix as octal
|
||||
umask = Integer(u)
|
||||
end
|
||||
end
|
||||
|
||||
server.add_unix_listener path, umask
|
||||
when "ssl"
|
||||
log "* Listening on #{str}"
|
||||
params = Rack::Utils.parse_query uri.query
|
||||
|
|
|
@ -123,9 +123,18 @@ module Puma
|
|||
|
||||
# Tell the server to listen on +path+ as a UNIX domain socket.
|
||||
#
|
||||
def add_unix_listener(path)
|
||||
def add_unix_listener(path, umask=nil)
|
||||
@unix_paths << path
|
||||
@ios << UNIXServer.new(path)
|
||||
|
||||
# Let anyone connect by default
|
||||
umask ||= 0
|
||||
|
||||
begin
|
||||
old_mask = File.umask(umask)
|
||||
@ios << UNIXServer.new(path)
|
||||
ensure
|
||||
File.umask old_mask
|
||||
end
|
||||
end
|
||||
|
||||
def backlog
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue