git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/8] ssh: 'simple' variant does not support -4/-6

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 20, 2017, 21:30 UTC
Message-ID
<20171120213030.ya5kxw7vldgid34g@aiede.mtv.corp.google.com>
In-Reply-To
<20171120212134.lh2l4drdzu6fh5g2@aiede.mtv.corp.google.com>

If the user passes -4/--ipv4 or -6/--ipv6 to "git fetch" or "git push" and the ssh command configured with GIT_SSH does not support such a setting, error out instead of ignoring the option and continuing.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Stefan Beller <sbeller@google.com>
---
As before.
 connect.c        | 25 ++++++++++++++++++++++---
 t/t5601-clone.sh | 12 ++++++------
 2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/connect.c b/connect.c
index 455c54a2ec..be106d1868 100644
--- a/connect.c
+++ b/connect.c
@@ -938,11 +938,30 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
 				 get_protocol_version_config());
 	}
 
-	if (variant != VARIANT_SIMPLE) {
-		if (flags & CONNECT_IPV4)
+	if (flags & CONNECT_IPV4) {
+		switch (variant) {
+		case VARIANT_AUTO:
+			BUG("VARIANT_AUTO passed to push_ssh_options");
+		case VARIANT_SIMPLE:
+			die("ssh variant 'simple' does not support -4");
+		case VARIANT_SSH:
+		case VARIANT_PLINK:
+		case VARIANT_PUTTY:
+		case VARIANT_TORTOISEPLINK:
 			argv_array_push(args, "-4");
-		else if (flags & CONNECT_IPV6)
+		}
+	} else if (flags & CONNECT_IPV6) {
+		switch (variant) {
+		case VARIANT_AUTO:
+			BUG("VARIANT_AUTO passed to push_ssh_options");
+		case VARIANT_SIMPLE:
+			die("ssh variant 'simple' does not support -6");
+		case VARIANT_SSH:
+		case VARIANT_PLINK:
+		case VARIANT_PUTTY:
+		case VARIANT_TORTOISEPLINK:
 			argv_array_push(args, "-6");
+		}
 	}
 
 	if (variant == VARIANT_TORTOISEPLINK)
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 209e2d5604..ad910ae9fa 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -364,9 +364,10 @@ test_expect_success 'OpenSSH variant passes -4' '
 	expect_ssh "-4 -p 123" myhost src
 '
 
-test_expect_success 'variant can be overriden' '
-	git -c ssh.variant=simple clone -4 "[myhost:123]:src" ssh-simple-clone &&
-	expect_ssh myhost src
+test_expect_success 'variant can be overridden' '
+	copy_ssh_wrapper_as "$TRASH_DIRECTORY/putty" &&
+	git -c ssh.variant=putty clone -4 "[myhost:123]:src" ssh-putty-clone &&
+	expect_ssh "-4 -P 123" myhost src
 '
 
 test_expect_success 'variant=auto picks based on basename' '
@@ -375,10 +376,9 @@ test_expect_success 'variant=auto picks based on basename' '
 	expect_ssh "-4 -P 123" myhost src
 '
 
-test_expect_success 'simple is treated as simple' '
+test_expect_success 'simple does not support -4/-6' '
 	copy_ssh_wrapper_as "$TRASH_DIRECTORY/simple" &&
-	git clone -4 "[myhost:123]:src" ssh-bracket-clone-simple &&
-	expect_ssh myhost src
+	test_must_fail git clone -4 "[myhost:123]:src" ssh-bracket-clone-simple
 '
 
 test_expect_success 'uplink is treated as simple' '
-- 
2.15.0.448.gf294e3d99a
Previous: Jonathan NiederNext: Jonathan Nieder
Message 23 of 27 in “Coping with unrecognized ssh wrapper scripts in GIT_SSH”
  1. 0/8 Coping with unrecognized ssh wrapper scripts in GIT_SSHJonathan Nieder, Nov 20, 2017
  2. 1/8 ssh test: make copy_ssh_wrapper_as clean up after itselfJonathan Nieder, Nov 20, 2017
  3. Brandon WilliamsNov 20, 2017
  4. Junio C HamanoNov 21, 2017
  5. 1/8 ssh test: make copy_ssh_wrapper_as clean up after itselfJonathan Nieder, Nov 21, 2017
  6. Stefan BellerNov 21, 2017
  7. 2/8 connect: move no_fork fallback to git_tcp_connectJonathan Nieder, Nov 20, 2017
  8. 3/8 connect: split git:// setup into a separate functionJonathan Nieder, Nov 20, 2017
  9. Brandon WilliamsNov 20, 2017
  10. Jonathan NiederNov 20, 2017
  11. Brandon WilliamsNov 20, 2017
  12. 4/8 connect: split ssh command line options into separate functionJonathan Nieder, Nov 20, 2017
  13. Brandon WilliamsNov 20, 2017
  14. Jonathan NiederNov 20, 2017
  15. Brandon WilliamsNov 20, 2017
  16. 4/8 connect: split ssh command line options into separate functionJonathan Nieder, Nov 20, 2017
  17. 5/8 connect: split ssh option computation to its own functionJonathan Nieder, Nov 20, 2017
  18. Junio C HamanoNov 21, 2017
  19. 6/8 ssh: 'auto' variant to select between 'ssh' and 'simple'Jonathan Nieder, Nov 20, 2017
  20. Brandon WilliamsNov 20, 2017
  21. Junio C HamanoNov 21, 2017
  22. Jonathan NiederNov 21, 2017
  23. 7/8 ssh: 'simple' variant does not support -4/-6Jonathan Nieder, Nov 20, 2017
  24. 8/8 ssh: 'simple' variant does not support --portJonathan Nieder, Nov 20, 2017
  25. Brandon WilliamsNov 20, 2017
  26. Stefan BellerNov 22, 2017
  27. Junio C HamanoNov 22, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.