threads / patch / 25558

patchfetch-pack: make the ssh connection quiet

Subject: [PATCH] fetch-pack: make the ssh connection quiet

## tl;dr

5 messages between Oct 27, 2010 and Oct 28, 2010. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Jan Stępień· Oct 27, 2010, 14:27 UTC · lore

The --quiet option passed to fetch-pack did not affect the ssh child process. When an ssh server sent a motd it was displayed because the ssh client wasn't launched with the -q option. This patch makes ssh run quietly when fetch-pack is called with -q.

An analogous change should be made to other commands which accept --quiet and connect to remotes using ssh.

Signed-off-by: Jan Stępień <jstepien@users.sourceforge.net>
---
 builtin/fetch-pack.c |    3 ++-
 cache.h              |    1 +
 connect.c            |    2 ++
 3 files changed, 5 insertions(+), 1 deletions(-)
Show changes to 3 files +5 −1

builtin/fetch-pack.c, cache.h, connect.c

diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index dbd8b7b..ede1c34 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -876,7 +876,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 		fd[1] = 1;
 	} else {
 		conn = git_connect(fd, (char *)dest, args.uploadpack,
-				   args.verbose ? CONNECT_VERBOSE : 0);
+				   (args.verbose ? CONNECT_VERBOSE : 0) |
+				   (args.quiet ? CONNECT_QUIET : 0));
 	}
 
 	get_remote_heads(fd[0], &ref, 0, NULL, 0, NULL);
diff --git a/cache.h b/cache.h
index 33decd9..8622a78 100644
--- a/cache.h
+++ b/cache.h
@@ -938,6 +938,7 @@ struct ref {
 extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
 
 #define CONNECT_VERBOSE       (1u << 0)
+#define CONNECT_QUIET         (1u << 1)
 extern char *git_getpass(const char *prompt);
 extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
 extern int finish_connect(struct child_process *conn);
diff --git a/connect.c b/connect.c
index 57dc20c..709601e 100644
--- a/connect.c
+++ b/connect.c
@@ -585,6 +585,8 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 			*arg++ = putty ? "-P" : "-p";
 			*arg++ = port;
 		}
+		if (!putty && flags & CONNECT_QUIET)
+			*arg++ = "-q";
 		*arg++ = host;
 	}
 	else {
-- 
1.7.0.4
Drew Northup· Oct 27, 2010, 15:24 UTC · re: Jan Stępień · lore

Re: [PATCH] fetch-pack: make the ssh connection quiet

On Wed, 2010-10-27 at 16:27 +0200, Jan Stępień wrote:
Show 7 quoted lines
> The --quiet option passed to fetch-pack did not affect the ssh child
> process. When an ssh server sent a motd it was displayed because the ssh
> client wasn't launched with the -q option. This patch makes ssh run quietly
> when fetch-pack is called with -q.
> 
> An analogous change should be made to other commands which accept --quiet
> and connect to remotes using ssh.
I'm not so sure that's a good idea. Quoting from the (Open)SSH man page:
-q      Quiet mode.  Causes all warning and diagnostic messages to be suppressed.
Somehow I doubt that's what you intended or a good idea.
-- 
-Drew Northup N1XIM
   AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59
Jan Stępień· Oct 27, 2010, 18:40 UTC · re: Drew Northup · lore

Re: [PATCH] fetch-pack: make the ssh connection quiet

On Wed, 27 Oct 2010 11:24:29 -0400 Drew Northup <drew.northup@maine.edu> wrote:

Show 14 quoted lines
> On Wed, 2010-10-27 at 16:27 +0200, Jan Stępień wrote:
> > The --quiet option passed to fetch-pack did not affect the ssh child
> > process. When an ssh server sent a motd it was displayed because the ssh
> > client wasn't launched with the -q option. This patch makes ssh run quietly
> > when fetch-pack is called with -q.
> > 
> > An analogous change should be made to other commands which accept --quiet
> > and connect to remotes using ssh.
> 
> I'm not so sure that's a good idea. Quoting from the (Open)SSH man page:
> 
> -q      Quiet mode.  Causes all warning and diagnostic messages to be suppressed.
> 
> Somehow I doubt that's what you intended or a good idea.

That's right, but according to the same source all fatal error messages still get displayed. It's a question of how quiet should fetch-pack be when --quiet is enabled.

Thanks for the comment,
-- 
Jan Stępień <jan@stepien.cc>
Junio C Hamano· Oct 27, 2010, 22:35 UTC · re: Jan Stępień · lore

Re: [PATCH] fetch-pack: make the ssh connection quiet

Jan Stępień  <jstepien@users.sourceforge.net> writes:
> The --quiet option passed to fetch-pack did not affect the ssh child
> process. When an ssh server sent a motd it was displayed because the ssh
> client wasn't launched with the -q option.
This is curious for a couple of reasons:
1. "-q" option to "ssh" is not meant to supress "motd"; it is about
   warning and diagnostics.  From man ssh(1):
     -q Quiet mode.  Causes most warning and diagnostic messages to be
        suppressed.  Only fatal errors are displayed.  If a second -q is
        given then even fatal errors are suppressed, except for those
        produced due solely to bad argu‐ ments.
2. "PrintMotd" defaults to "yes" but it is to specify whether the daemon
   should print /etc/motd when a user logs in interactively.  I didn't
   think fetch-pack logged in interactively, so why should this matter?
Jan Stępień· Oct 28, 2010, 09:14 UTC · re: Junio C Hamano · lore

Re: [PATCH] fetch-pack: make the ssh connection quiet

On Wed, 27 Oct 2010 15:35:41 -0700 Junio C Hamano <gitster@pobox.com> wrote:

Show 19 quoted lines
> Jan Stępień  <jstepien@users.sourceforge.net> writes:
> > The --quiet option passed to fetch-pack did not affect the ssh child
> > process. When an ssh server sent a motd it was displayed because the ssh
> > client wasn't launched with the -q option.
> 
> This is curious for a couple of reasons:
> 
> 1. "-q" option to "ssh" is not meant to supress "motd"; it is about
>    warning and diagnostics.  From man ssh(1):
> 
>      -q Quiet mode.  Causes most warning and diagnostic messages to be
>         suppressed.  Only fatal errors are displayed.  If a second -q is
>         given then even fatal errors are suppressed, except for those
>         produced due solely to bad argu‐ ments.
> 
> 2. "PrintMotd" defaults to "yes" but it is to specify whether the daemon
>    should print /etc/motd when a user logs in interactively.  I didn't
>    think fetch-pack logged in interactively, so why should this matter?
> 

You're right, fetch-pack doesn't log in interactively so the actual motd is not displayed. I made some research and it turned out that what I described in the commit message as the "motd" was in fact the Banner. Quoting man sshd_config(5):

  Banner  The contents of the specified file are sent to the remote
          user before authentication is allowed.  If the argument is
          “none” then no banner is displayed.  This option is only
          available for protocol version 2.  By default, no banner
          is displayed.

From what I've read it seems that the Banner is generally used to display some legal information, such as "this system can be used by authorised personnel only, others will be prosecuted".

I'd say that suppressing such information along with diagnostic messages might be expected after adding the "-q" flag to fetch-pack and other similar commands. Fatal errors will be printed anyway. The question is whether "--quiet" should suppress warnings as well. From my point of view it is reasonable or at least acceptable. An alternative solution might be to add another level of verbosity, namely "--silent".

Thanks,
-- 
Jan Stępień <jan@stepien.cc>

← back to recent threads