summaryrefslogtreecommitdiff
path: root/test/ruby/test_process.rb
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-17 22:48:57 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-17 22:48:57 +0000
commit5245ed6b9f7f7bc96b5311e923932e3c7f5af4ea (patch)
treea4076f7bb63b01db4abd9a6f1d1995ee069e5bc0 /test/ruby/test_process.rb
parentb824c871174fc33519ce5344a8f08cbbc3980d62 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_process.rb')
-rw-r--r--test/ruby/test_process.rb2
1 files changed, 1 insertions, 1 deletions
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 @@ class TestProcess < Test::Unit::TestCase
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