rrsync: add -absolute argument to support calling rsync with absolute…#890
Open
SebMtn wants to merge 1 commit intoRsyncProject:masterfrom
Open
rrsync: add -absolute argument to support calling rsync with absolute…#890SebMtn wants to merge 1 commit intoRsyncProject:masterfrom
SebMtn wants to merge 1 commit intoRsyncProject:masterfrom
Conversation
… path Signed-off-by: SebMtn <102696928+SebMtn@users.noreply.github.com>
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.
I noticed unreachable code in
rrsync. Instead of just cleaning it up, I thought I would also add a nice new feature.Clean up
Line 305:
The last 2 lines are never called because
arg.lstrip('/')ensure the condition is never true (lstrip removes multiple instances if needed)New feature: motivation
rsync supports only relative path. This is good for security, it avoids shenanigans with symlinks or other prefix tricks. However, this is not convenient to the user, because the client needs to be aware of what the
DIRargument forrrsyncis. It means that in some senserrsyncmakes it not backward compatible.If I have all my client code running
rsync, and I decide later to addrrsyncto increase security, then I have to modify all my client code to change relative paths instead.If even later I decide to change
DIR, to a more or less restricted entry, then again I have to modify all my client code.This is not logical because the clients should only be aware of what they want to
rsync, they should not have to know what restrictions are imposed on themNew feature: implementation
I tried to minimize the number of lines of code, so you (mainteners) probably don't need too much of an explanation. I'll just mention that I tried to make sure my patch was as secure as possible. The main mechanism is that I am not changing the logic. Even when we pass an absolute path,
rrsyncstill passes the relative path torsync. So on the server I am NOT actually resolving the absolute path (it's still invoked exactly like in the current version). That makes it resistant to trying to escape therrsyncDIR, no symlink escape, no prefix trick.I also wanted to make sure this is 100% backward compatible. It would have been natural to just check if the given path is an absolute path. However, the current behaviour of rrsync is to append a given absolute path to the
DIR. I would argue absolute path should be respected, andrrsyncshould actually error out in that scenario. However, I suspect you might not want to change that behaviour, so I just added a new argument.New feature: usage
On the server:
ForceCommand rrsync -absolute /path/to/restricted/On the client
rsync user@host:/path/to/restricted/dir .Let me know what you think. Happy to make any change as you see fit, if that helps.
Testing
I tested on my end on OpenBSD and macOS, and it worked correctly.