Project

General

Profile

Actions

Bug #14969

closed

Process.groups が返す GID が重複している場合がある

Added by mrkn (Kenta Murata) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-08-06 arith_seq 64201) [x86_64-linux]
[ruby-dev:50603]

Description

Ubuntu 16.04 から 18.04 にアップグレードした環境で以下の ruby spec が失敗することに気づきました。

1)
Process.groups gets an Array of the gids of groups in the supplemental group access list FAILED
Expected [4, 24, 27, 30, 46, 110, 114, 120, 120, 121]
to equal [4, 24, 27, 30, 46, 110, 114, 120, 121]

/home/mrkn/src/github.com/ruby/ruby/spec/ruby/core/process/groups_spec.rb:11:in `block (3 levels) in <top (required)>'
/home/mrkn/src/github.com/ruby/ruby/spec/ruby/core/process/groups_spec.rb:3:in `<top (required)>'

根本原因は、この環境に GID=120 のグループが2つ存在するからでした。

$ grep 120 /etc/group
libvirtd:x:120:mrkn
libvirt:x:120:mrkn

Ubuntu の Yakkety を堺にグループ名が libvirtd から libvirt に変わったらしく、私が 16.04 → 18.04 というアップグレードをしたことでこのような状態を作ってしまったようです。

https://help.ubuntu.com/lts/serverguide/libvirt.html.en

In more recent releases (>= Yakkety) the group was renamed to libvirt. Upgraded systems get a new libvirt group with the same gid as the libvirtd group to match that.

失敗したテストは、Process.groupsid -G の結果をソートして比較するものです。Process.groups が中で使っている getgroups(2) は重複した gid があっても重複したまま返すけど、id -G コマンドは結果を uniq して返すので、両者の内容が異なっていてテストが失敗しています。

私は getgroups(2) や Process.groups の用途を正確に理解していないので、Process.groups の方を弄るべきか、失敗したテストを修正すべきか判断できません。
どなたかこの件に詳しい方、どのように修正すべきか教えて頂けますか。

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0