{"thread":{"id":"824","subject":"[PATCH] ssh-protocol version, command types, response code","startedAt":"2005-06-03T21:43:52Z","lastAt":"2005-06-03T22:49:29Z","messageCount":2,"participants":["Daniel Barkalow","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4511","messageId":"Pine.LNX.4.21.0506031740020.30848-100000@iabervon.org","threadId":"824","inReplyTo":null,"subject":"[PATCH] ssh-protocol version, command types, response code","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-06-03T21:43:52Z","receivedAt":"2005-06-03T21:43:52Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"This patch makes an incompatible change to the protocol used by\nrpull/rpush which will let it be extended in the future without\nincompatible changes. \n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\nIndex: rpull.c\n===================================================================\n--- 33942306faa3093107cc7105dff046de5c981d2e/rpull.c  (mode:100644 sha1:36e49f799a6ac300a00f8d09d9dc9e6636b3d8e0)\n+++ 1f3a64b193531d17cafb7db8aae4a08d92be3132/rpull.c  (mode:100644 sha1:a3d13595d3db6c26d4d55fe7ef516efd5c8f6a0c)\n@@ -6,16 +6,39 @@\n static int fd_in;\n static int fd_out;\n \n+static unsigned char remote_version = 0;\n+static unsigned char local_version = 1;\n+\n int fetch(unsigned char *sha1)\n {\n \tint ret;\n+\tsigned char remote;\n+\tchar type = 'o';\n+\tif (has_sha1_file(sha1))\n+\t\treturn 0;\n+\twrite(fd_out, &type, 1);\n \twrite(fd_out, sha1, 20);\n+\tif (read(fd_in, &remote, 1) < 1)\n+\t\treturn -1;\n+\tif (remote < 0)\n+\t\treturn remote;\n \tret = write_sha1_from_fd(sha1, fd_in);\n \tif (!ret)\n \t\tpull_say(\"got %s\\n\", sha1_to_hex(sha1));\n \treturn ret;\n }\n \n+int get_version(void)\n+{\n+\tchar type = 'v';\n+\twrite(fd_out, &type, 1);\n+\twrite(fd_out, &local_version, 1);\n+\tif (read(fd_in, &remote_version, 1) < 1) {\n+\t\treturn error(\"Couldn't read version from remote end\");\n+\t}\n+\treturn 0;\n+}\n+\n int main(int argc, char **argv)\n {\n \tchar *commit_id;\n@@ -46,6 +69,9 @@\n \tif (setup_connection(&fd_in, &fd_out, \"git-rpush\", url, arg, argv + 1))\n \t\treturn 1;\n \n+\tif (get_version())\n+\t\treturn 1;\n+\n \tif (pull(commit_id))\n \t\treturn 1;\n \nIndex: rpush.c\n===================================================================\n--- 33942306faa3093107cc7105dff046de5c981d2e/rpush.c  (mode:100644 sha1:17d5ab8a60ab2ec7fa3a7dc927351e8a34de3a89)\n+++ 1f3a64b193531d17cafb7db8aae4a08d92be3132/rpush.c  (mode:100644 sha1:bd381ac9d1787dc979b1eba5bd72c1fd644a094b)\n@@ -3,46 +3,81 @@\n #include <sys/socket.h>\n #include <errno.h>\n \n-static void service(int fd_in, int fd_out) {\n+unsigned char local_version = 1;\n+unsigned char remote_version = 0;\n+\n+int serve_object(int fd_in, int fd_out) {\n \tssize_t size;\n-\tint posn;\n-\tchar unsigned sha1[20];\n+\tint posn = 0;\n+\tchar sha1[20];\n \tunsigned long objsize;\n \tvoid *buf;\n+\tsigned char remote;\n+\tdo {\n+\t\tsize = read(fd_in, sha1 + posn, 20 - posn);\n+\t\tif (size < 0) {\n+\t\t\tperror(\"git-rpush: read \");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tif (!size)\n+\t\t\treturn -1;\n+\t\tposn += size;\n+\t} while (posn < 20);\n+\t\n+\t/* fprintf(stderr, \"Serving %s\\n\", sha1_to_hex(sha1)); */\n+\tremote = 0;\n+\t\n+\tbuf = map_sha1_file(sha1, &objsize);\n+\t\n+\tif (!buf) {\n+\t\tfprintf(stderr, \"git-rpush: could not find %s\\n\", \n+\t\t\tsha1_to_hex(sha1));\n+\t\tremote = -1;\n+\t}\n+\t\n+\twrite(fd_out, &remote, 1);\n+\t\n+\tif (remote < 0)\n+\t\treturn 0;\n+\t\n+\tposn = 0;\n \tdo {\n-\t\tposn = 0;\n-\t\tdo {\n-\t\t\tsize = read(fd_in, sha1 + posn, 20 - posn);\n-\t\t\tif (size < 0) {\n-\t\t\t\tperror(\"git-rpush: read \");\n-\t\t\t\treturn;\n+\t\tsize = write(fd_out, buf + posn, objsize - posn);\n+\t\tif (size <= 0) {\n+\t\t\tif (!size) {\n+\t\t\t\tfprintf(stderr, \"git-rpush: write closed\");\n+\t\t\t} else {\n+\t\t\t\tperror(\"git-rpush: write \");\n \t\t\t}\n-\t\t\tif (!size)\n-\t\t\t\treturn;\n-\t\t\tposn += size;\n-\t\t} while (posn < 20);\n-\n-\t\t/* fprintf(stderr, \"Serving %s\\n\", sha1_to_hex(sha1)); */\n-\n-\t\tbuf = map_sha1_file(sha1, &objsize);\n-\t\tif (!buf) {\n-\t\t\tfprintf(stderr, \"git-rpush: could not find %s\\n\", \n-\t\t\t\tsha1_to_hex(sha1));\n+\t\t\treturn -1;\n+\t\t}\n+\t\tposn += size;\n+\t} while (posn < objsize);\n+\treturn 0;\n+}\n+\n+int serve_version(int fd_in, int fd_out)\n+{\n+\tif (read(fd_in, &remote_version, 1) < 1)\n+\t\treturn -1;\n+\twrite(fd_out, &local_version, 1);\n+\treturn 0;\n+}\n+\n+void service(int fd_in, int fd_out) {\n+\tchar type;\n+\tint retval;\n+\tdo {\n+\t\tretval = read(fd_in, &type, 1);\n+\t\tif (retval < 1) {\n+\t\t\tif (retval < 0)\n+\t\t\t\tperror(\"rpush: read \");\n \t\t\treturn;\n \t\t}\n-\t\tposn = 0;\n-\t\tdo {\n-\t\t\tsize = write(fd_out, buf + posn, objsize - posn);\n-\t\t\tif (size <= 0) {\n-\t\t\t\tif (!size) {\n-\t\t\t\t\tfprintf(stderr, \"git-rpush: write closed\");\n-\t\t\t\t} else {\n-\t\t\t\t\tperror(\"git-rpush: write \");\n-\t\t\t\t}\n-\t\t\t\treturn;\n-\t\t\t}\n-\t\t\tposn += size;\n-\t\t} while (posn < objsize);\n+\t\tif (type == 'v' && serve_version(fd_in, fd_out))\n+\t\t\treturn;\n+\t\tif (type == 'o' && serve_object(fd_in, fd_out))\n+\t\t\treturn;\n \t} while (1);\n }\n \n@@ -56,7 +91,7 @@\n                 arg++;\n         }\n         if (argc < arg + 2) {\n-                usage(\"git-rpush [-c] [-t] [-a] commit-id url\");\n+\t\tusage(\"git-rpush [-c] [-t] [-a] commit-id url\");\n                 return 1;\n         }\n \tcommit_id = argv[arg];\n\n"},{"id":"4517","messageId":"20050603224928.GB13093@pasky.ji.cz","threadId":"824","inReplyTo":"Pine.LNX.4.21.0506031740020.30848-100000@iabervon.org","subject":"Re: [PATCH] ssh-protocol version, command types, response code","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-06-03T22:49:29Z","receivedAt":"2005-06-03T22:49:29Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Jun 03, 2005 at 11:43:52PM CEST, I got a letter\nwhere Daniel Barkalow <barkalow@iabervon.org> told me that...\n> This patch makes an incompatible change to the protocol used by\n> rpull/rpush which will let it be extended in the future without\n> incompatible changes. \n> \n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n\nIt looks fine by me. Linus? (I would really like to see this in.)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"}]}