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

[PATCH] Ensure that SSH runs in non-interactive mode

From
FTFredrik Tolf <fredrik@dolda2000.com>
Date
Jul 19, 2008, 17:06 UTC
Message-ID
<1216487215-6927-1-git-send-email-fredrik@dolda2000.com>

OpenSSH has the nice feature that it sets the IP TOS value of its connection depending on usage. When used in interactive mode, it is set to Minimize-Delay, and other wise to Maximize-Throughput. Its usage by Git is best served by Maximize-Throughput, for obvious reasons.

However, it seems to use a DWIM heuristic for detecting interactive mode. The current implementation enters interactive mode if either a PTY is allocated or X11 forwarding is enabled, and even though Git SSH:ing does not allocate a PTY, X11 forwarding is often turned on by default. By removing the DISPLAY env variable before forking, SSH can thus be forced into non-interactive mode, without any obvious ill effects.

Signed-off-by: Fredrik Tolf <fredrik@dolda2000.com>
---
 connect.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/connect.c b/connect.c
index 574f42f..54888d3 100644
--- a/connect.c
+++ b/connect.c
@@ -607,6 +607,13 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 			*arg++ = port;
 		}
 		*arg++ = host;
+		/* Remove the X11 DISPLAY from the environment, to
+		 * make SSH run non-interactively */
+		const char *env[] = {
+			"DISPLAY",
+			NULL
+		};
+		conn->env = env;
 	}
 	else {
 		/* remove these from the environment */
-- 
1.5.6.2
Next: Mike Hommey
Message 1 of 16 in “Ensure that SSH runs in non-interactive mode”
  1. Ensure that SSH runs in non-interactive modeFredrik Tolf, Jul 19, 2008
  2. Mike HommeyJul 19, 2008
  3. Keith PackardJul 19, 2008
  4. Fredrik TolfJul 19, 2008
  5. Johannes SchindelinJul 20, 2008
  6. Fredrik TolfJul 20, 2008
  7. Johannes SchindelinJul 20, 2008
  8. Fredrik TolfJul 20, 2008
  9. Junio C HamanoJul 20, 2008
  10. Johannes SchindelinJul 20, 2008
  11. Junio C HamanoJul 20, 2008
  12. Johannes SchindelinJul 20, 2008
  13. Steffen ProhaskaJul 21, 2008
  14. Jeff KingJul 21, 2008
  15. Mike HommeyJul 21, 2008
  16. Jeff KingJul 21, 2008

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.