about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-13 12:01:48 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-13 12:06:26 -0700
commit96c29ee3c7bee26237aaa0e76517aaaf6bb8bfa9 (patch)
tree63c7003a31257156a225e57c1de9ae3e82cbcf45
parentf34618e64b254f7792b476acf2e7eb426aa551a2 (diff)
downloadunicorn-96c29ee3c7bee26237aaa0e76517aaaf6bb8bfa9.tar.gz
I don't advocate running Unicorn on unprivileged ports anyways
since Unicorn should never be exposed directly to public
clients.
-rw-r--r--lib/unicorn/configurator.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb
index 548c239..b27121e 100644
--- a/lib/unicorn/configurator.rb
+++ b/lib/unicorn/configurator.rb
@@ -104,6 +104,20 @@ module Unicorn
     #    # per-worker ports can be taken, necessitating another
     #    # HUP after QUIT-ing the original master:
     #    server.listen("127.0.0.1:#{9293 + worker.nr}") rescue nil
+    #
+    #    # drop permissions to "www-data" in the worker
+    #    # generally there's no reason to start Unicorn as a priviledged user
+    #    # as it is not recommended to expose Unicorn to public clients.
+    #    uid, gid = Process.euid, Process.egid
+    #    user, group = 'www-data', 'www-data'
+    #    target_uid = Etc.getpwnam(user).uid
+    #    target_gid = Etc.getgrnam(group).gid
+    #    worker.tempfile.chown(target_uid, target_gid)
+    #    if uid != target_uid || gid != target_gid
+    #      Process.initgroups(user, target_gid)
+    #      Process::GID.change_privilege(target_gid)
+    #      Process::UID.change_privilege(target_uid)
+    #    end
     #  end
     def after_fork(*args, &block)
       set_hook(:after_fork, block_given? ? block : args[0])