Allow uploading files even when permissions cannot be set.#1471
Open
alip wants to merge 2 commits intoRexOps:masterfrom
Open
Allow uploading files even when permissions cannot be set.#1471alip wants to merge 2 commits intoRexOps:masterfrom
alip wants to merge 2 commits intoRexOps:masterfrom
Conversation
By default, the "file" function uses sftp to upload the target file to the server. During the upload, the Net::SFTP::Foreign runs chmod unconditionally, failing if the target file is not owned by the ssh user, unless that user is a root. This commit changes that behavior by passing an optional "best_effort" flag that instructs sftp to continue even if setting permissions has failed. As a result, an unprivileged user will be able to use Rex scenarios that call the "file" function without getting permission denied errors.
This ensures the current behavior continues for ops but best effort for writeable files allows other teams to apply changes. Also began some initial POD for the OpenSSH module in functions touched.
ferki
requested changes
Feb 15, 2021
Member
ferki
left a comment
There was a problem hiding this comment.
I believe this would be best discussed in a feature request issue first.
If we are going to make it a feature, I think the best_effort functionality should be controlled via a config option in Rex::Config (whether the user explicitly want it or not), instead of basing it on the fact whether sudo is used or not (which could break for other privilege escalation methods).
And if it's going to be a first class config option, I believe it would be best to make it a generic one to pass arbitrary (Net::SFTP::Foreign?) options similarly to set_openssh_opt. That would avoid having to do further pull requests for each use case that might arise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By default, the "file" function uses sftp to upload the target file to
the server. During the upload, the Net::SFTP::Foreign runs chmod
unconditionally, failing if the target file is not owned by the ssh
user, unless that user is a root. This commit changes that behavior by
passing an optional "best_effort" flag that instructs sftp to continue
even if setting permissions has failed.
As a result, an unprivileged user will be able to use Rex scenarios that
call the "file" function without getting permission denied errors.
This PR is an attempt to fix # by .
Checklist