Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP authentication support in the cp module #5641

Closed
jlisee opened this issue Jun 19, 2013 · 3 comments
Closed

HTTP authentication support in the cp module #5641

jlisee opened this issue Jun 19, 2013 · 3 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Milestone

Comments

@jlisee
Copy link

jlisee commented Jun 19, 2013

I am trying to retrieve a file that is behind a web server with basic HTTP auth setup, if I run something like this:

salt-call --local cp.get_url https://username:password@ppa.mydomain.com:443/remote.key /tmp/local_file

I get this error:

Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module    
    salt_call()
  File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 76, in salt_call
    client.run()
  File "/usr/lib/pymodules/python2.7/salt/cli/__init__.py", line 257, in run
    caller.run()
  File "/usr/lib/pymodules/python2.7/salt/cli/caller.py", line 163, in run
    ret = self.call()
  File "/usr/lib/pymodules/python2.7/salt/cli/caller.py", line 76, in call
    ret['return'] = func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/salt/modules/cp.py", line 203, in get_url
    return __context__['cp.fileclient'].get_url(path, dest, False, env)
  File "/usr/lib/pymodules/python2.7/salt/fileclient.py", line 344, in get_url
    raise MinionError('Error reading {0}: {1}'.format(url, ex.reason))
salt.exceptions.MinionError: Error reading https://username:password@ppa.mydomain.com:443/remote.key [Errno -2] Name or service not known

I think this might be due to urllib2.urlopen not liking my URL, but I can't be sure. I am Salt 0.15.3 on Ubuntu 12.04.

Specially I am trying to use this as the key_url in the pkgrepo state. I think this might of worked before the fix for #3894.

@basepi
Copy link
Contributor

basepi commented Jun 19, 2013

Whether your URL is valid or not, we definitely don't like tracebacks. We'll look into it.

@jlisee
Copy link
Author

jlisee commented Jun 19, 2013

Thanks for the quick feedback. I should of mentioned that the URL itself works fine in other tools like wget and firefox.

@thatch45
Copy link
Contributor

Looks like this is a limitation in the python urllib libs, we will need to handle this case in a different way

kula added a commit to kula/salt that referenced this issue Jul 27, 2013
If you have a userinfo component in an RFC 3986 URI, the default
handling of the python urllibs is to complain about a non-numeric
port.

This fix handles the case where there is a userinfo component (e.g.
http://user:pass@server.name/path/to/file), parsing it out,
creating a basicauth handler, and passing url_open a url it can
understand.

FIXES Issue saltstack#5641
basepi pushed a commit that referenced this issue Jul 29, 2013
If you have a userinfo component in an RFC 3986 URI, the default
handling of the python urllibs is to complain about a non-numeric
port.

This fix handles the case where there is a userinfo component (e.g.
http://user:pass@server.name/path/to/file), parsing it out,
creating a basicauth handler, and passing url_open a url it can
understand.

FIXES Issue #5641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Projects
None yet
Development

No branches or pull requests

3 participants