Property definitions

privileges $ UserGroup :: defaultinit
# Class to manage user groups
class UserGroup

	# User name
	var user: String

	# Group name
	var group: nullable String

	# Drop privileges of the running program to those of `self`
	#
	# require: `user.user_exists and (group == null or group.group_exists)`
	fun drop_privileges
	do
		var passwd = new Passwd.from_name(user)
		assert not passwd.address_is_null
		var uid = passwd.uid

		var group = group
		var gid
		if group != null then
			var gpasswd = new Group.from_name(group)
			assert not gpasswd.address_is_null
			gid = gpasswd.gid
		else gid = passwd.gid

		sys.gid = gid
		sys.uid = uid
	end
end
lib/privileges/privileges.nit:42,1--71,3