csprotocol.txt 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. This is kind of informal and may be wrong, but it helped me. It's
  2. basically a summary of clientserver.c and authenticate.c.
  3. -- Martin Pool <mbp@samba.org>
  4. This is the protocol used for rsync --daemon; i.e. connections to port
  5. 873 rather than invocations over a remote shell.
  6. When the server accepts a connection, it prints a greeting
  7. @RSYNCD: <version>.<subprotocol>
  8. where <version> is the numeric version (see PROTOCOL_VERSION in rsync.h)
  9. '.' is a literal period, and <subprotocol> is the numeric subprotocol
  10. version (see SUBPROTOCOL_VERSION -- it will be 0 for final releases).
  11. Protocols prior to 30 only output <version> alone. The daemon expects
  12. to see a similar greeting back from the client. For protocols prior to
  13. 30, an absent ".<subprotocol>" value is assumed to be 0. For protocol
  14. 30, an absent value is a fatal error. The daemon then follows this line
  15. with a free-format text message-of-the-day (if any is defined).
  16. The server is now in the connected state. The client can either send
  17. the command
  18. #list
  19. to get a listing of modules, or the name of a module. After this, the
  20. connection is now bound to a particular module. Access per host for
  21. this module is now checked, as is per-module connection limits.
  22. If authentication is required to use this module, the server will say
  23. @RSYNCD: AUTHREQD <challenge>
  24. where <challenge> is a random string of base64 characters. The client
  25. must respond with
  26. <user> <response>
  27. where <user> is the username they claim to be, and <response> is the
  28. base64 form of the MD4 hash of challenge+password.
  29. At this point the server applies all remaining constraints before
  30. handing control to the client, including switching uid/gid, setting up
  31. include and exclude lists, moving to the root of the module, and doing
  32. chroot.
  33. If the login is acceptable, then the server will respond with
  34. @RSYNCD: OK
  35. The client now writes some rsync options, as if it were remotely
  36. executing the command. The server parses these arguments as if it had
  37. just been invoked with them, but they're added to the existing state.
  38. So if the client specifies a list of files to be included or excluded,
  39. they'll defer to existing limits specified in the server
  40. configuration.
  41. At this point the client and server both switch to using a
  42. multiplexing layer across the socket. The main point of this is to
  43. allow the server to asynchronously pass errors back, while still
  44. allowing streamed and pipelined data.
  45. Unfortunately, the multiplex protocol is not used at every stage. We
  46. start up in plain socket mode and then change over by calling
  47. io_start_buffering. Of course both the client and the server have to
  48. do this at the same point.
  49. The server then talks to the client as normal across the socket,
  50. passing checksums, file lists and so on. For documentation of that,
  51. stay tuned (or write it yourself!).
  52. ------------
  53. Protocol version changes
  54. 30 (2007-10-04, 3.0.0pre1)
  55. The use of a ".<subprotocol>" number was added to
  56. @RSYNCD: <version>.<subprotocol>
  57. 25 (2001-08-20, 2.4.7pre2)
  58. Send an explicit "@RSYNC EXIT" command at the end of the
  59. module listing. We never intentionally end the transmission
  60. by just closing the socket anymore.