Bug 2242710 - Incorrect curl parameters causes hp-plugin to fail
Summary: Incorrect curl parameters causes hp-plugin to fail
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: hplip
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Zdenek Dohnal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2242723 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-10-08 09:54 UTC by Mikhail
Modified: 2024-03-03 04:25 UTC (History)
5 users (show)

Fixed In Version: hplip-3.23.8-1.fc38 hplip-3.23.8-1.fc37 hplip-3.23.8-1.fc39
Clone Of:
Environment:
Last Closed: 2023-10-12 01:45:13 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
screenshot (247.83 KB, image/png)
2023-10-08 14:50 UTC, Mikhail
no flags Details

Description Mikhail 2023-10-08 09:54:27 UTC
Needed mitigation of impossibility download plug-in:

-----------------------------------------
| PLUG-IN INSTALLATION FOR HPLIP 3.23.5 |
-----------------------------------------

  Option      Description                                       
  ----------  --------------------------------------------------
  d           Download plug-in from HP (recommended)            
  p           Specify a path to the plug-in (advanced)          
  q           Quit hp-plugin (skip installation)                

Enter option (d=download*, p=specify path, q=quit) ? 

-------------------
| DOWNLOAD PLUGIN |
-------------------

Checking for network connection...
Downloading plug-in from: 
Downloading plug-in: [\                                                                                                                                                                                                 ] 0%     
error: Plugin download failed with error code = 2

error:  file does not match its checksum. File may have been corrupted or altered
error: Failed to install Plugin.
error: The device you are trying to setup requires a binary plug-in. Some functionalities may not work as expected without plug-ins. Please run 'hp-plugin' as normal user to install plug-ins.Visit http://hplipopensource.com for more infomation.
❯ 
❯ 


Maybe enough show url address where I can download plug-in manually and where I should be place this file in the system.
Or provide command for manually downloading. Which can be showed to ISP for debugging.

======================

---------------
| COPY PLUGIN |
---------------

Downloading plug-in from: file:///home/mikhail/Downloads/hplip-3.23.5-plugin.run
Downloading plug-in: [\                                                                                                                                                                                                 ] 0%     
1100%Receiving digital keys: /usr/bin/gpg --homedir /home/mikhail/.hplip/.gnupg --no-permission-warning --keyserver keyserver.ubuntu.com --recv-keys 0x4ABA2F66DBD5A95894910E0673D770CDA59047B9
 

----------------------
| INSTALLING PLUG-IN |
----------------------

Creating directory hplip-3.23.5
Verifying archive integrity...  100%   All good.
Uncompressing HPLIP 3.23.5 Self Extracting Archive  100%  
/home/mikhail/.hplip/hplip-3.23.5/base/g.py:305: SyntaxWarning: invalid escape sequence '\|'
  spinner = "\|/-\|/-"
/home/mikhail/.hplip/hplip-3.23.5/base/g.py:355: SyntaxWarning: invalid escape sequence '\d'
  m = re.search('python(\d(\.\d){0,2})', ext_path)            #get the python version where the .so file is found
/home/mikhail/.hplip/hplip-3.23.5/base/logger.py:438: SyntaxWarning: invalid escape sequence '\<'
  elem_start = re.findall("(\<\W{0,1}\w+) ?", line)[0]
/home/mikhail/.hplip/hplip-3.23.5/base/logger.py:439: SyntaxWarning: invalid escape sequence '\]'
  elem_finished = re.findall("([?|\]\]]*\>)", line)[0]
/home/mikhail/.hplip/hplip-3.23.5/base/logger.py:441: SyntaxWarning: invalid escape sequence '\S'
  attrs = re.findall("(\S*?\=\".*?\")", line)
Traceback (most recent call last):
  File "/home/mikhail/.hplip/hplip-3.23.5/./install.py", line 38, in <module>
    from base.g import *
  File "/home/mikhail/.hplip/hplip-3.23.5/base/g.py", line 240, in <module>
    sys_conf = SysConfig()
               ^^^^^^^^^^^
  File "/home/mikhail/.hplip/hplip-3.23.5/base/g.py", line 185, in __init__
    ConfigBase.__init__(self, '/etc/hp/hplip.conf')
  File "/home/mikhail/.hplip/hplip-3.23.5/base/g.py", line 90, in __init__
    self.read()
  File "/home/mikhail/.hplip/hplip-3.23.5/base/g.py", line 131, in read
    self.conf.readfp(fp)
    ^^^^^^^^^^^^^^^^
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?
error: Python gobject/dbus may be not installed
 
Done.

---------------------
| PRINT QUEUE SETUP |
---------------------


Please enter a name for this print queue (m=use model name:'HP_LaserJet_Professional_M1132_MFP'*, q=quit) ?
Using queue name: HP_LaserJet_Professional_M1132_MFP
Locating PPD file... Please wait.

Found PPD file: drv:///hp/hpcups.drv/hp-laserjet_professional_m1132_mfp.ppd
Description: 

Note: The model number may vary slightly from the actual model number on the device.

Does this PPD file appear to be the correct one (y=yes*, n=no, q=quit) ? 
Enter a location description for this printer (q=quit) ?
Enter additonal information or notes for this printer (q=quit) ?

Adding print queue to CUPS:
Device URI: hp:/usb/HP_LaserJet_Professional_M1132_MFP?serial=000000000QH707YTSI1c
Queue name: HP_LaserJet_Professional_M1132_MFP
PPD file: drv:///hp/hpcups.drv/hp-laserjet_professional_m1132_mfp.ppd
Location: 
Information: 


---------------------
| PRINTER TEST PAGE |
---------------------


Would you like to print a test page (y=yes*, n=no, q=quit) ? 

HP Linux Imaging and Printing System (ver. 3.23.5)
Testpage Print Utility ver. 6.0

Copyright (c) 2001-18 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

warning: Unable to start hp-systray
error: Device is busy or in an error state. Please check device and try again.

note: If an error occured, or the test page failed to print, refer to the HPLIP website
note: at: http://hplip.sourceforge.net for troubleshooting and support.



Reproducible: Always

Comment 1 Mikhail 2023-10-08 14:46:05 UTC
I debug that is happens here:
diff --git a/installer/pluginhandler.py b/installer/pluginhandler.py
index 56683fb..031ceec 100755
--- a/installer/pluginhandler.py
+++ b/installer/pluginhandler.py
@@ -185,14 +185,19 @@ class PluginHandle(object):
                 if self.__plugin_conf_file.startswith('file://'):
                     status, filename = utils.download_from_network(self.__plugin_conf_file, local_conf, True)
                 else:
-                    wget = utils.which("wget", True)
-                    if wget:
-                        status, output = utils.run("%s --tries=3 --timeout=60 --output-document=%s %s --cache=off" %(wget, local_conf, self.__plugin_conf_file))
+                    curl = utils.which("curl", True)
+                    if curl:
+                        print("curl: {}".format(curl))
+                        print("local_conf: {}".format(local_conf))
+                        print("self.__plugin_conf_file: {}".format(self.__plugin_conf_file))
+                        status, output = utils.run("%s --retry 3 --max-time=10 --output %s %s" %(curl, local_conf, self.__plugin_conf_file))
+                        print("status: {}".format(status))
+                        print("output: {}".format(output))
                         if status:
                             log.error("Plugin download failed with error code = %d" %status)
                             return status, url, check_sum
                     else:
-                        log.error("Please install wget package to download the plugin.")
+                        log.error("Please install curl package to download the plugin.")
                         return status, url, check_sum
             except IOError as e:
                 log.error("I/O Error: %s" % e.strerror)



curl: /usr/bin/curl
local_conf: /tmp/tmpy9c58vqk
self.__plugin_conf_file: http://hplip.sf.net/plugin.conf
< Here is invoked curl >
status: 2
output: curl: option --max-time=10: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

Comment 2 Mikhail 2023-10-08 14:50:28 UTC
Created attachment 1992949 [details]
screenshot

Comment 3 Mikhail 2023-10-08 14:51:00 UTC
❯ curl --retry 3 --max-time=10 --output /tmp/tmpy9c58vqk http://hplip.sf.net/plugin.conf
curl: option --max-time=10: is unknown
curl: try 'curl --help' or 'curl --manual' for more information
❯

Comment 4 Mikhail 2023-10-08 14:54:10 UTC
❯ curl --help all | grep time
     --connect-timeout <fractional seconds> Maximum time allowed for connection
     --expect100-timeout <seconds> How long to wait for 100-continue
     --happy-eyeballs-timeout-ms <milliseconds> Time for IPv6 before trying IPv4
     --keepalive-time <seconds> Interval time for keepalive probes
 -m, --max-time <fractional seconds> Maximum time allowed for transfer
 -R, --remote-time Set the remote file's time on the local output
     --retry-delay <seconds> Wait time between retries
     --retry-max-time <seconds> Retry only within this period
 -y, --speed-time <seconds> Trigger 'speed-limit' abort after this time
 -z, --time-cond <time> Transfer based on a time condition
     --trace-time  Add time stamps to trace/verbose output
❯ 
❯ 
❯ curl --retry 3 --max-time 10 --output /tmp/tmpy9c58vqk http://hplip.sf.net/plugin.conf
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

Comment 5 Mikhail 2023-10-08 21:52:02 UTC
And yet another problem is redirection:

❯ /usr/bin/curl http://hplip.sf.net/plugin.conf -v
*   Trying 104.18.34.154:80...
* Connected to hplip.sf.net (104.18.34.154) port 80
> GET /plugin.conf HTTP/1.1
> Host: hplip.sf.net
> User-Agent: curl/8.3.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Date: Sun, 08 Oct 2023 21:49:17 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: max-age=3600
< Expires: Sun, 08 Oct 2023 22:49:17 GMT
< Location: https://hplip.sf.net/plugin.conf
< Server: cloudflare
< CF-RAY: 813197c5ce9176b5-DME
< alt-svc: h3=":443"; ma=86400
< 
* Connection #0 to host hplip.sf.net left intact

For solving this issue we should add "--location" and the final command should look like this:
/usr/bin/curl --retry 3 --max-time 10 --output /tmp/tmp1wgn6pqh --location http://hplip.sf.net/plugin.conf

Comment 6 Mikhail 2023-10-08 22:30:38 UTC
I make PR which fix this both issues:
https://src.fedoraproject.org/rpms/hplip/pull-request/13

Comment 7 Zdenek Dohnal 2023-10-09 05:28:02 UTC
Hi,

thank you for the report and the PR! I'm sorry for the problems caused by my downstream patch.

I'll push the fix from your colleague and build a new version (there is a new upstream version too) today, but if time is the essence, you can use 'hp-plugin-download' - it downloads and installs the plugin as well.

Comment 8 Zdenek Dohnal 2023-10-09 05:28:22 UTC
*** Bug 2242723 has been marked as a duplicate of this bug. ***

Comment 9 Fedora Update System 2023-10-09 06:36:45 UTC
FEDORA-2023-da89e8c661 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-da89e8c661

Comment 10 Fedora Update System 2023-10-09 07:06:04 UTC
FEDORA-2023-ac032077c0 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-ac032077c0

Comment 11 Fedora Update System 2023-10-09 07:32:29 UTC
FEDORA-2023-f4604b9eb0 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-f4604b9eb0

Comment 12 Mikhail 2023-10-10 01:12:35 UTC
Zdenek, thanks for reviewing.
Do you know why module base/strings has it's own logging object instance (lines 341-342)?
```
from . import logger
log = logger.Logger('', logger.Logger.LOG_LEVEL_INFO, logger.Logger.LOG_TO_CONSOLE)
```
I wanna remove this instance for use global level logging brodaly.
Without it `log.dedug` in my PR no working even with `-g` option. https://src.fedoraproject.org/rpms/hplip/pull-request/13#_1__16

Comment 13 Mikhail 2023-10-10 01:47:57 UTC
Are you ok with such change?
https://src.fedoraproject.org/fork/mikhail/rpms/hplip/c/4e7529671df8ed31e500f1f3836cc72f4d86f56e?branch=rawhide

I tested, for me all working fine.

Comment 14 Fedora Update System 2023-10-10 01:48:24 UTC
FEDORA-2023-da89e8c661 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-da89e8c661`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-da89e8c661

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Fedora Update System 2023-10-10 02:37:04 UTC
FEDORA-2023-f4604b9eb0 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-f4604b9eb0`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f4604b9eb0

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Fedora Update System 2023-10-10 02:37:30 UTC
FEDORA-2023-ac032077c0 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-ac032077c0`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-ac032077c0

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 17 Fedora Update System 2023-10-12 01:45:13 UTC
FEDORA-2023-ac032077c0 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 18 Fedora Update System 2023-10-18 01:28:28 UTC
FEDORA-2023-f4604b9eb0 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 19 Mikhail 2023-10-18 09:57:48 UTC
Zdenek, excuse me for ping.
But can you answer me on comment 12 ?
https://bugzilla.redhat.com/show_bug.cgi?id=2242710#c12
Or ask upstream why they have several logger instances with different logging level?

Comment 20 Zdenek Dohnal 2023-10-19 15:17:50 UTC
Hi Mikhail,

I'm sorry for the delay - I was working on other things.

Upstream does not communicate often, so we won't get answer there - I've looked up into the code and saw there are several calls for 'log', so IMO we should include module g in strings.py, wdyt?

Comment 21 Zdenek Dohnal 2023-10-19 15:19:00 UTC
But I agree with removing the local logger in strings.py - but we should import the global one IMO, otherwise log. calls will traceback.

Comment 22 Fedora Update System 2023-11-03 18:33:02 UTC
FEDORA-2023-da89e8c661 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 23 Red Hat Bugzilla 2024-03-03 04:25:25 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


Note You need to log in before you can comment on or make changes to this bug.