about summary refs log tree commit homepage
path: root/lib/yahns/worker.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-29 00:02:56 +0000
committerEric Wong <e@80x24.org>2013-10-29 02:37:05 +0000
commitfd5844b2baef6c1acaca9ca1eca0509e3a4f840d (patch)
tree2e9d746f699da0458903b4b54227a3574f774cb1 /lib/yahns/worker.rb
parent556f8ae6f629df51ff41c1918de40e2bb531159e (diff)
downloadyahns-fd5844b2baef6c1acaca9ca1eca0509e3a4f840d.tar.gz
This was documented (incorrectly) and not implemented for either
the master/worker or single process cases.  Implement and test
all (with mocks, so not fully-tested).
Diffstat (limited to 'lib/yahns/worker.rb')
-rw-r--r--lib/yahns/worker.rb24
1 files changed, 0 insertions, 24 deletions
diff --git a/lib/yahns/worker.rb b/lib/yahns/worker.rb
index 980f7bd..0d25acc 100644
--- a/lib/yahns/worker.rb
+++ b/lib/yahns/worker.rb
@@ -31,28 +31,4 @@ class Yahns::Worker # :nodoc:
   def ==(other_nr) # :nodoc:
     @nr == other_nr
   end
-
-  # Changes the worker process to the specified +user+ and +group+
-  # This is only intended to be called from within the worker
-  # process from the +after_fork+ hook.  This should be called in
-  # the +after_fork+ hook after any privileged functions need to be
-  # run (e.g. to set per-worker CPU affinity, niceness, etc)
-  #
-  # Any and all errors raised within this method will be propagated
-  # directly back to the caller (usually the +after_fork+ hook.
-  # These errors commonly include ArgumentError for specifying an
-  # invalid user/group and Errno::EPERM for insufficient privileges
-  def user(user, group = nil)
-    # we do not protect the caller, checking Process.euid == 0 is
-    # insufficient because modern systems have fine-grained
-    # capabilities.  Let the caller handle any and all errors.
-    uid = Etc.getpwnam(user).uid
-    gid = Etc.getgrnam(group).gid if group
-    Yahns::Log.chown_all(uid, gid)
-    if gid && Process.egid != gid
-      Process.initgroups(user, gid)
-      Process::GID.change_privilege(gid)
-    end
-    Process.euid != uid and Process::UID.change_privilege(uid)
-  end
 end