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
'Permission denied' on get with use_sudo=True #1226
Comments
I remember a very similar issue with
|
Use `chown` to ensure the user maintains access to the file, even if it is owned by a different user. Setting permissions 0404/0400 blocks the user from accessing the file.
On my first attempt, I could not reproduce this error, however it was reproducible on a fresh Ubuntu 14.04 server install for certain files. When a user
Even with the correct permissions of I've attached a patch, just in case. Debug Info:(on a new Ubuntu 14.04 VM)
While iterating through the files, the first 'permission denied' error is raised with dmesg.0:
The next file was
In the second instance (fsck), the traceback was: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Fabric-1.10.0-py2.7.egg/fabric/operations.py", line 574, in get
result = ftp.get_dir(remote_path, local_path, use_sudo, temp_dir)
File "/usr/local/lib/python2.7/dist-packages/Fabric-1.10.0-py2.7.egg/fabric/sftp.py", line 228, in get_dir
result.append(self.get(rpath, lpath, use_sudo, True, rremote, temp_dir))
File "/usr/local/lib/python2.7/dist-packages/Fabric-1.10.0-py2.7.egg/fabric/sftp.py", line 181, in get
getter(remote_path, local_path)
File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 676, in get
size = self.getfo(remotepath, fl, callback)
File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 639, in getfo
fr = self.file(remotepath, 'rb')
File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 245, in open
t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 689, in _request
return self._read_response(num)
File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 736, in _read_response
self._convert_status(msg)
File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 764, in _convert_status
raise IOError(errno.EACCES, text)
IOError: [Errno 13] Permission denied |
…ng permissions so that only the owner can read it.
Github doesn't parse refs in headers so just noting that #1235 is the PR for this. |
Re: your PR, my only worry is that if you/we (I can't keep all this stuff straight anymore XD) are incorrect about the scope of the One of us needs to go find the PR that added this to see if there's more info about how to replicate that use case - presumably whoever added it found that it did function correctly in some situation(s). |
Here's the commit I found, and it looks like it was added as part of the overall task. I might be wrong here, so I'll explain my thinking in case anyone sees a problem: Setting 0404 simply bypasses the intent of "only root and the user" accessing the file. It's readable by user and world, which doesn't do what the comment says. Being more permissive with the permissions makes me wonder if it was a typo, or if there are instances where
With ownership |
That commit seems to have come out of the original #700 which doesn't really list anything interesting besides "make it work". I guess that's something. Your analysis looks sound to me, I was simply being paranoid about somebody going "hi yes this only works if I make the file world readable". But barring that I agree it's most secure (and consistent) to use 0400. I'm gonna try whipping up an integration test for some of these cases (all we seem to have is the ones for put()) and test out the PR with those in place. |
I've identified one problem with the fix, not all usernames are necessarily reflected as groups, that's just happenstance on some systems. E.g. when testing against a work-related VM, where users do not have their own groups, I get an error when the PR's code tries to do I don't see a huge benefit to chowning the group as well, honestly (just user should be sufficient to work around the original problem reported by @OddBloke), and not doing so would skip this problem, so I'll try tweaking it that way. |
With that change in, the test I wrote which failed prior to merging #1235, passes \o/ |
Couple of non-integration tests for same functionality fail, updated them to account for new sub-call (honestly...not a fan of this kind of test and clearly I didn't add them...but not worth removing now) and things look good on my end. Merging to 1.10 and letting travis have a crack. |
Awesome! Yeah, I guess the group isn't relevant with 400 permissions..d'oh! Third time's a charm, they say... |
I am using Fabric against a fresh Ubuntu host, and trying to pull down /var/log in its entirety. I am hitting a 'Permission denied' error when calling
get('/var/log', '...', use_sudo=True)
because of a slightly convoluted Unix permissions problem./var/log/syslog
is owned by syslog:adm, and has permissions of 640. Whenget
copies it to its temporary location, it changes its permissions to 404 (but doesn't change ownership at all).When a file has permissions of 404 (-r-----r--), it seems that being in the group that owns the file but not the user that owns the file means that you can't read the file (even though "others" can). (Presumably each permission is checked in turn, "group can't read" must result in a "permission denied" without even looking at the "others" permission). I have fabric paused in a debugger here and am looking at the actual temporary file:
I reckon this could be fixed by either (a) making the temporary files group-readable, or (b) changing the ownership of the temporary files to the user performing the operation.
The text was updated successfully, but these errors were encountered: