From: v.ondruch@... Date: 2016-11-23T09:27:21+00:00 Subject: [ruby-core:78274] [Ruby trunk Bug#12910] TestFileUtils#test_chown_R_force might get stuck when process has no supplementary groups Issue #12910 has been updated by Vit Ondruch. > For some reason, the test expects there will be some supplementary groups available, but there are non in the container. The following patch makes the test suite pass, although it apparently doesn't test everything, since some tests expects more than one group: Here is the response of systemd-nspawn maintainer [1]: ``` The getgroups(2) man page is pretty clear: It is unspecified whether the effective group ID of the calling process is included in the returned list. (Thus, an application should also call getegid(2) and add or remove the resulting value.) I don't think there's any bug here. ``` So I think that the proposed patch should be applied. [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1393404#c2 ---------------------------------------- Bug #12910: TestFileUtils#test_chown_R_force might get stuck when process has no supplementary groups https://bugs.ruby-lang.org/issues/12910#change-61640 * Author: Vit Ondruch * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.4.0dev (2016-11-07 trunk 56664) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Testing build of Ruby using systemd-nspawn, the test suite gets always stuck when executing TestFileUtils#test_chown_R_force. Pressing Ctrl+C, it proceeds with following backtrace: ``` 1) Failure: TestFileUtils#test_chown_R_force [/builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1261]: exceptions on 2 threads: #: /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/assertions.rb:762:in `value': (Interrupt) from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/assertions.rb:762:in `assert_join_threads' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:23:in `block in assert_output_lines' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:16:in `pipe' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:16:in `assert_output_lines' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1261:in `test_chown_R_force' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:1029:in `run_test' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1269:in `run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/testcase.rb:18:in `run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:941:in `block in _run_suite' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:934:in `map' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:934:in `_run_suite' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:914:in `_run_suite' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:494:in `block in _run_suites' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:492:in `each' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:492:in `_run_suites' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:530:in `_run_suites' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:885:in `_run_anything' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1096:in `run_tests' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1083:in `block in _run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1082:in `each' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1082:in `_run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1070:in `run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:682:in `run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:33:in `run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:991:in `run' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:995:in `run' from ./test/runner.rb:40:in `
' --- #: /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:201:in `assert': File group ownership of "tmp/dir" unexpected: Expected: <> Actual: <135> (MiniTest::Assertion) from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/assertions.rb:37:in `assert' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/fileasserts.rb:95:in `assert_ownership_group' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1278:in `block (2 levels) in test_chown_R_force' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1273:in `each' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1273:in `block in test_chown_R_force' from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:20:in `block (2 levels) in assert_output_lines' ``` And there are two issues with this: 1. It should simply fail and not get stuck, no matter what. 2. For some reason, the test expects there will be some supplementary groups available, but there are non in the container. The following patch makes the test suite pass, although it apparently doesn't test everything, since some tests expects more than one group: ``` $ git show commit 43934fbbf16c7f19e07ae1de17fce6697fb137cc Author: V��t Ondruch Date: Tue Nov 8 16:25:24 2016 +0100 Use primary group as well as supplementary groups. I might happen in certain environments (systemd-nspawn) that process has no supplementary groups, but primary groups should be enough to pass most of the tests. diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 0ff0aad..fa5b24d 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -142,7 +142,7 @@ def mymkdir(path) def setup @prevdir = Dir.pwd - @groups = Process.groups if have_file_perm? + @groups = [Process.gid, Process.groups].flatten if have_file_perm? tmproot = @tmproot = Dir.mktmpdir "fileutils" Dir.chdir tmproot my_rm_rf 'data'; mymkdir 'data' ``` -- https://bugs.ruby-lang.org/ Unsubscribe: