From 98e048d27e190bb8ad69ee74821f93446ee5693a Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 17 Dec 2018 13:52:37 -0800 Subject: [PATCH] Fix test failure if ENV["USER"] doesn't match Process.euid When dropping privileges to run tests, ENV["USER"] could be set to a user that doesn't match Process.euid, which causes this test to fail with Errno::EPERM. Try to get the name for the current euid, and only fallback to ENV["USER"] if that doesn't work. --- test/ruby/test_process.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 6f16ac3062..7911a0cb20 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1567,7 +1567,7 @@ def test_seteuid end def test_seteuid_name - user = ENV["USER"] or return + user = (Etc.getpwuid(Process.euid).name rescue ENV["USER"]) or return assert_nothing_raised(TypeError) {Process.euid = user} rescue NotImplementedError end -- 2.19.2