TritonDataCenter / python-manta

Python SDK for Manta (community maintained)
MIT License
25 stars 18 forks source link

`load_ssh_key` blows up if there is a "~/.ssh/*.pub" file that is a broken symlink #43

Closed trentm closed 8 years ago

trentm commented 8 years ago

Example:

$ mantash -v ls /nightly/stor
manta.client: DEBUG: ListDirectory '/nightly/stor'
mantash: ERROR: [Errno 2] No such file or directory: '/Users/trentm/.ssh/id_rsa.pub' (/Users/trentm/joy/python-manta/manta/auth.py:137 in load_ssh_key)

Traceback (most recent call last):
  File "/Users/trentm/joy/python-manta/bin/mantash", line 2153, in <module>
    retval = main(sys.argv)
  File "/Users/trentm/joy/python-manta/bin/mantash", line 2147, in main
    return shell.main(argv, loop=cmdln.LOOP_IF_EMPTY)
  File "/Users/trentm/joy/python-manta/manta/cmdln.py", line 266, in main
    return self.cmd(args)
  File "/Users/trentm/joy/python-manta/manta/cmdln.py", line 284, in cmd
    retval = self.onecmd(argv)
  File "/Users/trentm/joy/python-manta/manta/cmdln.py", line 422, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/Users/trentm/joy/python-manta/manta/cmdln.py", line 1125, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/Users/trentm/joy/python-manta/bin/mantash", line 602, in do_ls
    to_print = self._ls_path(path, opts.dir)
  File "/Users/trentm/joy/python-manta/bin/mantash", line 426, in _ls_path
    dirents = self.client.ls(abspath)
  File "/Users/trentm/joy/python-manta/manta/client.py", line 702, in ls
    mdir, marker=marker)
  File "/Users/trentm/joy/python-manta/manta/client.py", line 256, in list_directory2
    res, content = self._request(mdir, "GET", query=query)
  File "/Users/trentm/joy/python-manta/manta/client.py", line 201, in _request
    algorithm, fingerprint, signature = self.signer.sign(sigstr)
  File "/Users/trentm/joy/python-manta/manta/auth.py", line 413, in sign
    key_info = self._get_key_info()
  File "/Users/trentm/joy/python-manta/manta/auth.py", line 399, in _get_key_info
    key_info = ssh_key_info_from_key_data(self.key_id)
  File "/Users/trentm/joy/python-manta/manta/auth.py", line 206, in ssh_key_info_from_key_data
    key_info = load_ssh_key(key_id)
  File "/Users/trentm/joy/python-manta/manta/auth.py", line 137, in load_ssh_key
    f = open(pub_key_path)
IOError: [Errno 2] No such file or directory: '/Users/trentm/.ssh/id_rsa.pub'

Where that is a broken symlink:

$ ls -al ~/.ssh/id_rsa.pub
lrwxr-xr-x  1 trentm  staff    21B Nov  7 16:22 /Users/trentm/.ssh/id_rsa.pub -> doesnotexist.id_rsa.pub