Class: Mongrel::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/pdtp/common/http_server.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.



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/pdtp/common/http_server.rb', line 202

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