Under some circumstances HPLIP removes user from all groups

Bug #1112306 reported by Daniel Pielmeier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HPLIP
Fix Released
Undecided
Unassigned
Gentoo Linux
Fix Released
Medium
Suse
New
Undecided
Unassigned

Bug Description

Under some circumstances hplip calls usermod without the "-a" flag which removes the user from all groups except the ones specified in the command. I will link to the corresponding Gentoo bug where more information about the issue and a potential cause for the problem can be found. Thanks for looking at this.

Revision history for this message
In , Opensource-andmarios (opensource-andmarios) wrote :

hplip, under some circumstances that I can not pinpoint, may remove the user who runs it from all groups except his default group and lp.

Long story short:
Yesterday I wanted to print on a HP machine. I installed hplip, connected the printer, started hplip and run `hp-config_usb_printer 004:004` to setup my printer. I didn't know or expect at the time to be detected automatically.

During the setup process hplip asked for my root password only for me to find later, while trying to su, that I had been removed from all groups except lp.

I guess it ran `usermod -G lp` instead of `usermod -a -G lp`.

I try to reproduce this behavior so I can be more specific, alas I fail. I can't get hplip to ask for my root password again.

I am on a ~amd64 system. Sorry I can't provide more information.

Reproducible: Always

Revision history for this message
In , Opensource-andmarios (opensource-andmarios) wrote :

Created attachment 333742
distros.dat patch

I think that this patch may fix the issue but I couldn't replicate the problem in order to test it.

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

I did look up the code and there are three occurrences where usermod is called.

check.py
base/queues.py
installer/core_install.py

check.py looks up the information in installer/distros.dat and if nothing is there it prints a log message.

installer/core_install.py looks up the information in installer/distros.dat and if nothing is there nothing happens.

base/queues.py which I think is responsible for the issue looks up the information in installer/distros.dat and if nothing is there it executes:
usermod -Glp username

So the "-a" is missing here. Your patch should fix the issue for Gentoo, but I think the queues.py should be fixed as well. From looking up installer/distros.dat Suse seems to be the only distribution which does not add the "-a" flag. So leaving it out in the general case seems wrong.

description: updated
Revision history for this message
Johannes Meixner (jsmeix) wrote :

Interesting:
https://bugs.gentoo.org/show_bug.cgi?id=449272#c2 reads:
---------------------------------------------------------------------
From looking up installer/distros.dat Suse seems to be
the only distribution which does not add the "-a" flag.
---------------------------------------------------------------------

Changed in gentoo:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

Maybe this is because Suse has no "-a" option for usermod. AFAIK Suse uses a modified version. Just look up "usermod -h".

Standard usermod only has the -G and the -a option. "-G" defines the groups a user should belong to and removes him from all which are not specified, except "-a" is added then the specified groups are appended to the existing ones. For Suse there is no "-a" but "-A" and "-R" to add or remove groups. However "-G" behaves the same.

So "-Gsys,lp" seems wrong for Suse and should probably use "-AGsys,lp", but I have not a lot experience with Suse.

Revision history for this message
Johannes Meixner (jsmeix) wrote :

On my openSUSE 12.2 machine it works as follows:
------------------------------------------------------------------
# groups johannes
johannes : users video

# usermod -G lp johannes

# groups johannes
johannes : users lp

# usermod -A video johannes

# groups johannes
johannes : users lp video
------------------------------------------------------------------

Therefore to add a user to the group "lp"
up to openSUSE 12.2
# usermod -A lp <username>
must be used.

FYI (on openSUSE 12.2):
------------------------------------------------------------------
# type -a usermod
usermod is /usr/sbin/usermod

# rpm -qf /usr/sbin/usermod
pwdutils-3.2.19-2.1.3
------------------------------------------------------------------

But - surprise surprise - for the upcomming
openSUSE 12.3 things seem to change:

On a openSUSE 12.3 Beta 1 system:
-----------------------------------------------------------------
 $ /usr/sbin/usermod --help

Usage: usermod [options] LOGIN

Options:
...
  -G, --groups GROUPS
        new list of supplementary GROUPS
  -a, --append
        append the user to the supplemental GROUPS
        mentioned by the -G option without removing
        him/her from other groups
-----------------------------------------------------------------

Therefore to add a user to the group "lp"
since openSUSE 12.3
# usermod -a -G lp <username>
must be used.

FYI (on openSUSE 12.2 Beta1):
------------------------------------------------------------------
$ rpm -qf /usr/sbin/usermod
shadow-4.1.5.1-3.2
------------------------------------------------------------------

What a mess with tons of different bits and pieces
that build all those various Linux systems.

Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

Actually the change is a good thing as Suse stops to use a different usermod so it behaves like for all other distributions.

The reason for Opensuse using pwdutils instead of shadow are explained here: http://lists.opensuse.org/opensuse-features/2012-10/msg00035.html. This is also the thread which initiates the change back to shadow.

So the add_user_to_group options have to be adjusted for the Opensuse versions sccordingly using -A for <12-3 and -a for >12.2 in distros.dat

Revision history for this message
Amarnath Chitumalla (amarnath-chitumalla) wrote :

Thanks for the information.

Updated HPLIP code to support 'usermod -A lp' for opensuse. Once opensuse 12.3 is supported, 'usermod -a -G lp' will be added.

Thanks & Regards,
Amarnath

Changed in hplip:
status: New → Fix Committed
Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

Amarnath thanks for fixing this in Suse. However this is not only a Suse bug. I think there is a bug somewhere which causes this behavior if there is no add_user_to_group information in distros.dat. Please read comment 4 from the Gentoo bug and check the code for usermod usage. I think the error is in base/queues.py where if no information from distros.dat is available usermod is called with "usermod -Glp username".

Changed in hplip:
status: Fix Committed → Fix Released
Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

This is fixed in hplip-3-13-10.

Changed in gentoo:
status: New → 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.