Bug 305 - http_proxy value needs more checking for valid url syntax
: http_proxy value needs more checking for valid url syntax
Status: RESOLVED FIXINSOURCE
Product: pkg
transport
: unspecified
: ANY/Generic All
: P4 minor (vote)
: ---
Assigned To: johansen
: pkg/transport watcher
:
: needstestcase
:
:
:
  Show dependency treegraph
 
Reported: 2007-12-11 00:31 UTC by nouar38
Modified: 2009-07-01 16:40 UTC (History)
7 users (show)

See Also:


Attachments


Note

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


Description nouar38 2007-12-11 00:31:29 UTC
provide more checking for valid url syntax in http_proxy, and more
comprehensible output.

(build used: OpenSolaris Developer Preview snv_75a X86)

Example: miss-spelled http protocol
$ http_proxy=htpp://<fully qualified domain web cache>:8080
$ export http_proxy
$ pkg image-create -U -a sun.com://updates.sfbay.sun.com:10000 TEST_GF_V2
=> output

pkg:n

Example: ftp used instead of http in the URL, will get Traceback of calls
ftpwrapper(user, passwd, host, port, dirs) and in the end IOError: [Errno ftp
error]
Comment 1 nouar38 2007-12-11 02:11:48 UTC
added myself in cc
Comment 2 Stephen Hahn 2008-04-15 16:21:34 UTC
*** Bug 1214 has been marked as a duplicate of this bug. ***
Comment 3 Danek Duvall 2008-05-07 07:49:41 UTC
Bug 1214 specifically had a stack trace because the proxy was specified without
the leading "http://", and the stack was quite specific:

Traceback (most recent call last):
  File "/usr/bin/pkg", line 1440, in ?
    ret = main_func()
  File "/usr/bin/pkg", line 1406, in main_func
    return install(img, pargs)
  File "/usr/bin/pkg", line 469, in install
    img.imageplan.execute()
  File ".../pkg/client/imageplan.py", line 394, in execute
    p.preexecute()
  File ".../pkg/client/pkgplan.py", line 242, in preexecute
    flist.get_files()
  File ".../pkg/client/filelist.py", line 139, in get_files
    imgtype = self.image.type)
  File ".../pkg/misc.py", line 107, in versioned_urlopen
    c = url_opener(req)
  File "/usr/lib/python2.4/urllib2.py", line 358, in open
    response = self._open(req, data)
  File "/usr/lib/python2.4/urllib2.py", line 376, in _open
    '_open', req)
  File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.4/urllib2.py", line 573, in <lambda>
    lambda r, proxy=url, type=type, meth=self.proxy_open: \
  File "/usr/lib/python2.4/urllib2.py", line 580, in proxy_open  
    if '@' in host:
TypeError: iterable argument required
Comment 4 Karl 2008-10-06 10:47:15 UTC
(In reply to comment #3)
> Bug 1214 specifically had a stack trace because the proxy was specified without
> the leading "http://", and the stack was quite specific:
> 
> Traceback (most recent call last):
>   File "/usr/bin/pkg", line 1440, in ?
>     ret = main_func()
>   File "/usr/bin/pkg", line 1406, in main_func
>     return install(img, pargs)
>   File "/usr/bin/pkg", line 469, in install
>     img.imageplan.execute()
>   File ".../pkg/client/imageplan.py", line 394, in execute
>     p.preexecute()
>   File ".../pkg/client/pkgplan.py", line 242, in preexecute
>     flist.get_files()
>   File ".../pkg/client/filelist.py", line 139, in get_files
>     imgtype = self.image.type)
>   File ".../pkg/misc.py", line 107, in versioned_urlopen
>     c = url_opener(req)
>   File "/usr/lib/python2.4/urllib2.py", line 358, in open
>     response = self._open(req, data)
>   File "/usr/lib/python2.4/urllib2.py", line 376, in _open
>     '_open', req)
>   File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
>     result = func(*args)
>   File "/usr/lib/python2.4/urllib2.py", line 573, in <lambda>
>     lambda r, proxy=url, type=type, meth=self.proxy_open: \
>   File "/usr/lib/python2.4/urllib2.py", line 580, in proxy_open  
>     if '@' in host:
> TypeError: iterable argument required

I just wanted to confirm that I got the same thing.  I forgot the "http://" and
I got the same stack trace as Danek Duvall above.
Comment 5 Tom Mueller 2008-12-15 07:05:01 UTC
An update on the output.

The pkg command is now catching the exception, so the output is more succinct. 
However, the error message still doesn't give the user much information about
the value for the proxy being invalid.

Here's the new output:

export http_proxy=http/uc:uc@webcache.france.sun.com:8080
$ ./bin/pkg refresh
pkg: 0/1 catalogs successfully updated:
    Could not retrieve catalog from 'dev.sun.com'
Exception: str:iterable argument required repr:<exceptions.TypeError instance
at 0x6a66e8>
Comment 6 Danek Duvall 2009-02-06 22:13:23 UTC
*** Bug 6384 has been marked as a duplicate of this bug. ***
Comment 7 Danek Duvall 2009-03-12 06:55:17 UTC
*** Bug 7333 has been marked as a duplicate of this bug. ***
Comment 8 johansen 2009-06-23 13:31:43 UTC
This bug is being fixed as part of the transport re-design.  A preliminary
webrev is available from:

http://cr.opensolaris.org/~johansen/webrev-xport-1/
Comment 9 johansen 2009-07-01 16:40:08 UTC
Integrated 1Jul2009 as change set a48bee2a4b2e9c8345c29acea63116acf77dddb3