TritonDataCenter / python-manta

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

if the client is run once via `sudo`, then a root-owned cache dir makes life unhappy #20

Closed trentm closed 10 years ago

trentm commented 10 years ago

E.g.:

ubuntu@0c769e1d-2147-48f2-c672-febdb1f8e229:~$ sudo -E mantash ls
...

Now we have a root-owned HTTP cache dir:

ubuntu@0c769e1d-2147-48f2-c672-febdb1f8e229:~$ ls -ld ~/.cache/python-manta
drwxr-xr-x 3 root root 4096 May 16 05:18 /home/ubuntu/.cache/python-manta

which breaks non-root usage:

ubuntu@0c769e1d-2147-48f2-c672-febdb1f8e229:~$ mantash ls
mantash: ERROR: [Errno 13] Permission denied: '/home/ubuntu/.cache/python-manta/http/us-east.manta.joyent.com,trent.mick,stor,336611998dc118d3ac26bd7e8ac1748b' (/usr/lib/python2.7/dist-packages/httplib2/__init__.py:714 in set)

Traceback (most recent call last):
  File "/usr/local/bin/mantash", line 1805, in <module>
    retval = main(sys.argv)
  File "/usr/local/bin/mantash", line 1799, in main
    return shell.main(argv, loop=cmdln.LOOP_IF_EMPTY)
  File "/usr/local/lib/python2.7/dist-packages/manta/cmdln.py", line 266, in main
    return self.cmd(args)
  File "/usr/local/lib/python2.7/dist-packages/manta/cmdln.py", line 284, in cmd
    retval = self.onecmd(argv)
  File "/usr/local/lib/python2.7/dist-packages/manta/cmdln.py", line 422, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/usr/local/lib/python2.7/dist-packages/manta/cmdln.py", line 1125, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/usr/local/bin/mantash", line 521, in do_ls
    to_print = self._ls_path(path, opts.dir)
  File "/usr/local/bin/mantash", line 408, in _ls_path
    dirents = self.client.ls(abspath)
  File "/usr/local/lib/python2.7/dist-packages/manta/client.py", line 683, in ls
    mdir, marker=marker)
  File "/usr/local/lib/python2.7/dist-packages/manta/client.py", line 244, in list_directory2
    res, content = self._request(mdir, "GET", query=query)
  File "/usr/local/lib/python2.7/dist-packages/manta/client.py", line 198, in _request
    return http.request(url, method, ubody, headers)
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1539, in request
    (response, new_content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/local/lib/python2.7/dist-packages/manta/client.py", line 96, in _request
    res, content = httplib2.Http._request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1374, in _request
    _updateCache(headers, response, content, self.cache, cachekey)
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 447, in _updateCache
    cache.set(cachekey, text)
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 714, in set
    f = file(cacheFullPath, "wb")
IOError: [Errno 13] Permission denied: '/home/ubuntu/.cache/python-manta/http/us-east.manta.joyent.com,trent.mick,stor,336611998dc118d3ac26bd7e8ac1748b'