Class: Mongrel::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/never_block/servers/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.



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/never_block/servers/mongrel.rb', line 216

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