← Back to context

Comment by Panino

1 day ago

I've been using openrsync here and there since it was announced and it's definitely improved over time. I'm looking forward to when I can use it exclusively.

The one place in my usage where it doesn't match Samba rsync is with the following:

openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

I would expect openrsync to create a remote file /tmp/services, but instead it creates /tmp/services/services.

Normal directory mirroring as in -av -e ssh /path/to/src/ example.com:/path/to/dst/ works as it does with Samba rsync.

> The one place in my usage where it doesn't match Samba rsync is with the following:

> openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

This appears to match "normal" `rsync` behavior as well. I think you need a trailing slash after `services` to sync only the contents.

EDIT: actually my "normal" rsync is openrsync on macOS...

  • Nonetheless, this matches vanilla rsync.

    • No, it doesn't.

      I think some people may not be reading closely. On Unix, "/etc/services" is a file, not a directory:

        $ file /etc/services                                                                                                                         
        /etc/services: ASCII text
      

      Here are two OpenBSD 7.9 endpoints running Samba rsync:

      rsync -av -e ssh /etc/services example.com:/tmp/services

      The above command creates a mirror of the local file /etc/services in a remote file called /tmp/services. The outcome is exactly the same as if I had run "scp /etc/services example.com:/tmp/services"

        client$ sha256 -q /etc/services                                                                                                                    
        469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a
      
        server$ sha256 -q /tmp/services                                                                                                          
        469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a
      

      openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

      The above command creates a mirror of the local file /etc/services in a remote file called /tmp/services/services. The outcome is NOT the same as if I had run "scp /etc/services example.com:/tmp/services"

      Please note that "/tmp/services" and "/tmp/services/services" are different.

        client$ sha256 -q /etc/services                                                                
        469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a
      
        server$ sha256 -q /tmp/services  
        sha256: /tmp/services: read error: Is a directory
        server$ sha256 -q /tmp/services/services                                                                                                 
        469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a
      

      Here's an OpenBSD 7.9 client and Ubuntu server both running Samba rsync:

      rsync -av -e ssh /etc/services example.com:/tmp/services

      The above command creates a mirror of the local file /etc/services in a remote file called /tmp/services. The outcome is exactly the same as if I had run "scp /etc/services example.com:/tmp/services"

      If you disagree, please state what operating systems you're using and copy/paste the output of the following commands on each side:

        uname -a
        rsync -V
        openrsync -V
      

      I get

        $ rsync -V
        rsync  version 3.4.3  protocol version 32
        (snipped)
      
        $ openrsync -V
        openrsync 0.1 (protocol version 27)
      

      Then please run the commands I ran above, in particular

      openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

      And then type "file /tmp/services" on the remote server.

Was there already a /tmp/services directory on the dest?

One of the biggest points of confusion with rsync is how directories and trailing slashes are handled.

  • I hear that a lot, but I familiarized myself with it once and ever since it makes a lot of sense to me.

    Source ending in “/“: You want what’s inside. Source not ending in “/“: You want the thing (i.e. directory itself). For the destination, it does not matter whether it ends in “/“ or not, but for consistency I like adding a “/“ anyway (I want to put thing inside the directory).

    • Yes, the nice thing about dest having a trailing "/" is that if it exists and is NOT a directory, you are alerted right away.

  • It's a big source of confusion with cp. One of the UI reasons to use rsync (for mundane non-remote copying) is that it doesn't do different things based on what's present on the target.

  • > Was there already a /tmp/services directory on the dest?

    No. And just to make sure, I ran a quick 'rm -rf /tmp/services' on the remote host, then re-ran openrsync on the client. Same result. This is OpenBSD 7.9 on both sides.

    And I 100% agree about trailing slashes.

If you use a trailing slash on the source it copies from the directory, if you omit the trailing slash it copies the directory itself. AFAIK this is pretty standard across POSIX tools

  • It's not, for example cp -R doesn't change behavior on the basis of a trailing slash on directory names.

    • I was implementing something recently and stumbled across that cp difference. ugh.

      the trailing slash is pretty convenient.

> I would expect openrsync to create a remote file /tmp/services, but instead it creates /tmp/services/services.

As someone who has also suffered uncountable years of abuse from rsync, I understand the impulse, but I think it makes a lot more sense (and is a safer default) to create a second ”services”.

If we have a chance to change rsync defaults to something less insane and save future generations from this mess I think we should.

  • We don't, since we're not implementing a UI from scratch, we're matching something else.

    Of the two possible worlds where in one this reimplementation matches what some see as annoyances in the interface or in another they mostly match the interface except for a few cases where the purposefully diverge (for no good technical reason), IMO the latter is far worse and causes more enexpected behavior.

    At most, add a special flag to opt into different default behavior so nobody is surprised by running the same command on different systems and getting different behavior.

    • To be absolutely clear, since on reading this later it may come across as me masquerading as part of the OpenBSD project, I am not affiliated with them. My "We don't" was in response to "If we have a chance to change rsync defaults" which we, as the general public and users (and very likely also any reimplementors) don't have that chance, because rsync has a solid UI that people and tools have integrated for over a decade, and that's not something you can just change.

      1 reply →