hp-toolbox: Use of deprecated Qt API causes infinite authentication loop
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
HPLIP |
New
|
Undecided
|
Unassigned |
Bug Description
Hello,
I discovered on a Fedora 31 installation that the hp-toolbox uses a deprecated Qt API function for QGridLayout named setMargin(). This causes an exception to be thrown by Qt when hp-toolbox is attempting to authenticate the user by asking for the user's username and password. Due to the exception, the password dialog creation fails, and hp-toolbox enters and infinite loop with the CUPS daemon, which spams the system journal...
Here is the problematic code in question:
=== /usr/share/
class PasswordDialog(
def __init__(self, prompt, parent=None, name=None, modal=0, fl=0):
self.prompt = prompt
Layout= QGridLayout(self)
The setMargin API function has been deprecated according to "https:/
Here are the log messages in the system journal indicating the infinite loop:
May 23 08:35:48 cupsd[12123]: [Client 3742370] Empty Basic password.
May 23 08:35:48 cupsd[12123]: REQUEST localhost - - "POST /admin/ HTTP/1.1" 401 121 CUPS-Set-Default successful-ok
May 23 08:35:48 cupsd[12123]: [Client 3742373] Empty Basic password.
May 23 08:35:48 cupsd[12123]: REQUEST localhost - - "POST /admin/ HTTP/1.1" 401 121 CUPS-Set-Default successful-ok
May 23 08:35:48 cupsd[12123]: [Client 3742376] Empty Basic password.
May 23 08:35:48 cupsd[12123]: REQUEST localhost - - "POST /admin/ HTTP/1.1" 401 121 CUPS-Set-Default successful-ok
When I modify the code to catch the exception in showPasswordUI as follows:
=== /usr/share/
def showPasswordUI(
try:
dlg = PasswordDialog(
if dlg.exec_() == QDialog.Accepted:
return (dlg.getUsername(), dlg.getPassword())
except Exception as e:
finally:
pass
return ("", "")
Then, I encounter the following output from hp-toolbox:
error: Exception in password dialog: 'QGridLayout' object has no attribute 'setMargin'
error: Traceback: Traceback (most recent call last):
File "/usr/share/
dlg = PasswordDialog(
File "/usr/share/
Layout.
AttributeError: 'QGridLayout' object has no attribute 'setMargin'
error: Start/Stop printer queue operation fails. Error : client-
All this to say, would it be possible to update the code so that the setMargin(11) call is replaced with the non-obsolete API call setContentsMarg
In addition, would it be possible to catch exceptions in showPasswordUI so that similar problems would be easier to debug in the future?
Thanks!
Hi ~mvb,
I'm Zdenek, RHEL/Fedora/CentOS hplip maintainer - I would like to provide a patch to hplip upstream for fixing the issue you found out and proposed the fix.
I understand what needs to be fixed because of your comment, but I'm not familiar with hp-toolbox so much so I'm not sure how to trigger the issue. I thought it will show up when I create a new print queue in hp-toolbox, but it wasn't the case.
Would you mind telling the exact steps leading to trigger the issue?
Creating a bugzilla ticket at bugzilla.redhat.com would help me too :) .
Thank you in advance!