Fails to install correctly if /etc/group contains any line matching "kvm"

Bug #286872 reported by Jan Lübbe
4
Affects Status Importance Assigned to Milestone
kvm (Debian)
Fix Released
Unknown
kvm (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: kvm

This is a copy of the same debian bug which also affects ubuntu.

In debian i uploaded kvm-72+dfsg-2 to fix it, which is now migrating to Lenny.

kvm's preinst contains the following code:
> GROUP=kvm
>
> # Workaround for bug in addgroup
> . /etc/adduser.conf
> [ -z "$FIRST_SYSTEM_UID" ] && exit 1
> [ -z "$LAST_SYSTEM_UID" ] && exit 2
>
> GID=$(grep ${GROUP} /etc/group >/dev/null && grep ${GROUP} /etc/group | cut -d ':' -f 3)
>
> if [ -n "$GID" ] \
> && [ "$GID" -lt "$FIRST_SYSTEM_UID" \
> -o "$GID" -gt "$LAST_SYSTEM_UID" ]; then
> cat >&2 <<EOF
>
> Error: The kvm package needs to create a group named "${GROUP}" in
> /etc/group to be used for /dev/kvm, but the group ${GROUP} already exists
> and it is not a group in the system range (${FIRST_SYSTEM_UID}..${LAST_SYSTEM_UID}). Depending on
> the circumstances, you may want to remove or rename the currently
> existing ${GROUP} group before reinstalling the kvm package.
>
> Aborting the installation of kvm now.
>
> EOF
> exit 3
> fi
>
> if [ -z "$GID" ]; then
> /usr/sbin/addgroup --system ${GROUP}
> if [ $? -ne 0 ]; then
> echo >&2 "Error: failed to add the group ${GROUP}."
> exit 4
> fi
> else
> echo >&2 "kvm: Using the existing group \"$GROUP\" (gid $GID) for /dev/kvm"
> fi

In particular, note that it simply does "grep ${GROUP} /etc/group".
This will match any line in /etc/group which contains the string
"kvm". This can lead to two possible failures:

* If an /etc/group line for a non-system group contains "kvm"
  somewhere, the install will incorrectly complain that the group
  already exists.

* If an /etc/group line for a system group contains "kvm" somewhere,
  kvm will use it rather than creating a group "kvm".

Might I suggest "getent group kvm"?

(Also, I haven't seen code like this in any other package that creates
a group.)

- Josh Triplett

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thank you for your bug report. It seems that this has been fixed in Debian. I will prepare a fixed Ubuntu package when I get home from work if somebody else has not done so already.

Changed in kvm:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Dustin Kirkland  (kirkland) wrote : Re: [Bug 286872] Re: Fails to install correctly if /etc/group contains any line matching "kvm"

Chris-

It's very unlikely for this to make it into Intrepid.

We will be syncing/merging packages for Jaunty in the coming weeks.
You're most certainly welcome to merge the Debian unstable package for
Jaunty. Otherwise, we'll get to it soon.

:-Dustin

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Thanks for the bug report, and the link against the Debian bug.

I'm marking this bug "Fix Released". Per my testing, kvm version 1:79+dfsg-0ubuntu4 is currently in Jaunty, and does not suffer this problem.

:-Dustin

Changed in kvm:
status: Triaged → Fix Released
Changed in kvm (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.