Class: Mongrel::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/packet_mongrel.rb,
lib/packet/packet_mongrel.rb

Instance Method Summary collapse

Instance Method Details

#change_privilege(user, group) ⇒ Object

This version fixes a bug in the regular Mongrel version by adding initialization of groups.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/packet_mongrel.rb', line 186

def change_privilege(user, group)
  if user and group
    log "Initializing groups for {#user}:{#group}."
    Process.initgroups(user,Etc.getgrnam(group).gid)
  end

  if group
    log "Changing group to #{group}."
    Process::GID.change_privilege(Etc.getgrnam(group).gid)
  end

  if user
    log "Changing user to #{user}."
    Process::UID.change_privilege(Etc.getpwnam(user).uid)
  end
rescue Errno::EPERM
  log "FAILED to change user:group #{user}:#{group}: #$!"
  exit 1
end