git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Mark remote `gc --auto` error messages
@ 2016-06-02 19:05 Lukas Fleischer
  2016-06-02 19:33 ` Junio C Hamano
  2016-06-05  9:36 ` [PATCH] receive-pack: send auto-gc output over sideband 2 Lukas Fleischer
  0 siblings, 2 replies; 9+ messages in thread
From: Lukas Fleischer @ 2016-06-02 19:05 UTC (permalink / raw)
  To: git

When running `git push`, it might occur that error messages are
transferred from the server to the client. While most messages (those
explicitly sent on sideband 2) are prefixed with "remote:", it seems
that error messages printed during the automatic householding performed
by git-gc(1) are displayed without any additional decoration. Thus, such
messages can easily be misinterpreted as git-gc failing locally, see [1]
for an actual example of where that happened.

Do we want anything like the following patch (completely untested)?

-- 8< --
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index a744437..15c323a 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1775,9 +1775,20 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
                        const char *argv_gc_auto[] = {
                                "gc", "--auto", "--quiet", NULL,
                        };
-                       int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR;
+                       struct child_process proc = CHILD_PROCESS_INIT;
+
+                       proc.no_stdin = 1;
+                       proc.stdout_to_stderr = 1;
+                       proc.err = use_sideband ? -1 : 0;
+                       proc.git_cmd = 1;
+                       proc.argv = argv_gc_auto;
+
                        close_all_packs();
-                       run_command_v_opt(argv_gc_auto, opt);
+                       if (!start_command(&proc)) {
+                               if (use_sideband)
+                                       copy_to_sideband(proc.err, -1, NULL);
+                               finish_command(&proc);
+                       }
                }
                if (auto_update_server_info)
                        update_server_info(0);
-- 8< --

More generally, do we care about making *all* "remote" strings easily
distinguishable from "local" strings? Even though it is unlikely to use
this for an actual attack, it seems that a malicious server can
currently trick a user into performing an action by printing a message
that looks like something coming from "local" Git. Prefixing every
server message by "remote:" might look a bit ugly but maybe we can
simply use a different color instead and fall back to the prefix on
terminals without color support. Opinions?

[1] https://lists.archlinux.org/pipermail/aur-general/2016-June/032340.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-05  9:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02 19:05 Mark remote `gc --auto` error messages Lukas Fleischer
2016-06-02 19:33 ` Junio C Hamano
2016-06-02 20:06   ` Lukas Fleischer
2016-06-02 20:14     ` Junio C Hamano
2016-06-02 21:48       ` Jeff King
2016-06-02 21:59         ` Junio C Hamano
2016-06-02 22:04           ` Jeff King
2016-06-02 21:53       ` Jeff King
2016-06-05  9:36 ` [PATCH] receive-pack: send auto-gc output over sideband 2 Lukas Fleischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).