fetch-pack: make the ssh connection quiet
PATCH 1/1 fetch-pack: make the ssh connection quiet
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.
--- builtin/fetch-pack.c | 3 ++- cache.h | 1 + connect.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletions(-)
builtin/fetch-pack.c +2 -1
@@ -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 );
cache.h +1 -0
@@ -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);
connect.c +2 -0
@@ -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 {
Signature · 1 line
1.7.0.4
Quoted 7 lines · Jan Stępień
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.
Signature · 5 lines
-Drew Northup N1XIM AKA RvnPhnx on OPN ________________________________________________ "As opposed to vegetable or mineral error?" -John Pescatore, SANS NewsBites Vol. 12 Num. 59
Quoted 6 lines · On Wed, 27 Oct 2010 11:24:29 -0400 Drew Northup <[email protected]> wrote:
Quoted 5 lines · Jan Stępień
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.
Quoted 8 lines
Quoted 2 lines
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,
Signature · 1 line
Jan Stępień <[email protected]>
Quoted 3 lines · Jan Stępień
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?
Quoted 10 lines · On Wed, 27 Oct 2010 15:35:41 -0700 Junio C Hamano <[email protected]> wrote:
Quoted 3 lines · Jan Stępień
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):
Quoted 9 lines
-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/motdwhen 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,
Signature · 1 line
Jan Stępień <[email protected]>