* bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
@ 2018-05-18 17:42 Philipp Stephani
2019-10-09 21:57 ` Lars Ingebrigtsen
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Philipp Stephani @ 2018-05-18 17:42 UTC (permalink / raw)
To: 31497
Create a Mercurial repository owned by root and add a hgrc file, e.g.:
$ mkdir -p /tmp/hg
$ cd /tmp/hg
$ sudo -s
# hg init
# echo a > a.txt
# hg addremove
# hg commit -m 'commit message'
# touch .hg/hgrc
Then visit a.txt in Emacs as non-root:
$ emacs -Q a.txt
Instead of the revision number, the status line will show
"Hg-not trusting file /tmp/hg/.hg/hgrc ..."
This is because the status line runs something like
$ hg log -l 1 -r . -T '{rev}'
but that outputs
not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
on stderr, and Emacs merges stderr and stdout. Rather it should ignore
stderr in this case.
In GNU Emacs 27.0.50 (build 27, x86_64-pc-linux-gnu, GTK+ Version 3.22.24)
of 2018-05-18 built on localhost
Repository revision: f4d9fd3dd45f767eca33fbf1beee40da790fa74e
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Debian GNU/Linux buster/sid
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Configured using:
'configure --without-threads --enable-gcc-warnings=warn-only
--enable-gtk-deprecation-warnings --without-pop --with-mailutils
--enable-checking --enable-check-lisp-object-type --with-modules
'CFLAGS=-O0 -ggdb3''
Configured features:
XPM JPEG TIFF GIF PNG SOUND DBUS GSETTINGS NOTIFY GNUTLS FREETYPE XFT
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES JSON
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
easymenu mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date elec-pair
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 95054 11969)
(symbols 48 20166 1)
(miscs 40 40 122)
(strings 32 28302 2388)
(string-bytes 1 758914)
(vectors 16 14177)
(vector-slots 8 499094 14196)
(floats 8 48 69)
(intervals 56 222 0)
(buffers 992 12))
--
Google Germany GmbH
Erika-Mann-Straße 33
80636 München
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
If you received this communication by mistake, please don’t forward it to
anyone else (it may contain confidential or privileged information), please
erase all copies of it, including all attachments, and please let the sender
know it went to the wrong person. Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2018-05-18 17:42 bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output Philipp Stephani
@ 2019-10-09 21:57 ` Lars Ingebrigtsen
2019-10-10 7:30 ` Eli Zaretskii
2019-10-10 11:11 ` Andrii Kolomoiets
2019-10-14 23:54 ` bug#31497: [Andrii Kolomoiets] " Lars Ingebrigtsen
2 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-09 21:57 UTC (permalink / raw)
To: Philipp Stephani; +Cc: 31497
Philipp Stephani <p.stephani2@gmail.com> writes:
> Create a Mercurial repository owned by root and add a hgrc file, e.g.:
>
> $ mkdir -p /tmp/hg
> $ cd /tmp/hg
> $ sudo -s
> # hg init
> # echo a > a.txt
> # hg addremove
> # hg commit -m 'commit message'
> # touch .hg/hgrc
>
> Then visit a.txt in Emacs as non-root:
>
> $ emacs -Q a.txt
>
> Instead of the revision number, the status line will show
> "Hg-not trusting file /tmp/hg/.hg/hgrc ..."
>
> This is because the status line runs something like
>
> $ hg log -l 1 -r . -T '{rev}'
>
> but that outputs
>
> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>
> on stderr, and Emacs merges stderr and stdout. Rather it should ignore
> stderr in this case.
I can confirm that this bug is still present in Emacs 27. The command
is started from vc-doc-command, which uses start-file-process, which
uses start-process, which doesn't even allow separating stderr from
stdin.
(In general, Emacs stderr/stdin handling is very frustrating.)
Would it make sense to alter this function
(defun vc-hg--run-log (template rev path)
(ignore-errors
(with-output-to-string
(if path
(vc-hg-command
standard-output 0 nil
"log" "-f" "-l1" "--template" template path)
(vc-hg-command
standard-output 0 nil
"log" "-r" rev "-l1" "--template" template)))))
to filter out the "not trusting" lines, or is this just one of a
gazillion error messages that can be output here?
not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
4d872e
I though perhaps we could redirect the error output with "-E", but "hg
log" doesn't seem to support that.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2019-10-09 21:57 ` Lars Ingebrigtsen
@ 2019-10-10 7:30 ` Eli Zaretskii
2019-10-11 7:27 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2019-10-10 7:30 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: p.stephani2, 31497
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 09 Oct 2019 23:57:15 +0200
> Cc: 31497@debbugs.gnu.org
>
> I can confirm that this bug is still present in Emacs 27. The command
> is started from vc-doc-command, which uses start-file-process, which
> uses start-process, which doesn't even allow separating stderr from
> stdin.
>
> (In general, Emacs stderr/stdin handling is very frustrating.)
From the doc string of start-process:
If you want to separate standard output from standard error, use
‘make-process’ or invoke the command through a shell and redirect
one of them using the shell syntax.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2018-05-18 17:42 bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output Philipp Stephani
2019-10-09 21:57 ` Lars Ingebrigtsen
@ 2019-10-10 11:11 ` Andrii Kolomoiets
2019-10-14 23:54 ` bug#31497: [Andrii Kolomoiets] " Lars Ingebrigtsen
2 siblings, 0 replies; 9+ messages in thread
From: Andrii Kolomoiets @ 2019-10-10 11:11 UTC (permalink / raw)
To: larsi; +Cc: 31497
Lars Ingebrigtsen writes:
>> $ hg log -l 1 -r . -T '{rev}'
>>
>> but that outputs
>>
>> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>
> filter out the "not trusting" lines, or is this just one of a
> gazillion error messages that can be output here?
Other errors also printed to stderr, so filtering out stderr completely
can hide meaningful errors.
This particular warning is also present in log and annotate buffers and
completely messing up vc-dir buffer.
There are option 'ui.report_untrusted' in hg since this commit:
https://www.mercurial-scm.org/repo/hg/rev/97369f6a6bb6
It present in mercurial 2.6.2, the earliest version I found in pip.
To filter out just "not trusting" warning I can propose to run hg like
this:
hg log --config ui.report_untrusted=0 -l 1 -r . -T '{rev}'
or specify '--config ui.report_untrusted=0' as default value for
vc-hg-global-switches
I think 'pull' and 'push' are the only commands that must print this
warning.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2019-10-10 7:30 ` Eli Zaretskii
@ 2019-10-11 7:27 ` Lars Ingebrigtsen
0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-11 7:27 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: p.stephani2, 31497
Eli Zaretskii <eliz@gnu.org> writes:
>> I can confirm that this bug is still present in Emacs 27. The command
>> is started from vc-doc-command, which uses start-file-process, which
>> uses start-process, which doesn't even allow separating stderr from
>> stdin.
>>
>> (In general, Emacs stderr/stdin handling is very frustrating.)
>
>>From the doc string of start-process:
>
> If you want to separate standard output from standard error, use
> ‘make-process’ or invoke the command through a shell and redirect
> one of them using the shell syntax.
Yes, I think start-file-process and start-process should also provide
the same stderr capabilities as make-process. Those two functions are
handy, but lead to sloppy handling of stderr.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: [Andrii Kolomoiets] bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2018-05-18 17:42 bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output Philipp Stephani
2019-10-09 21:57 ` Lars Ingebrigtsen
2019-10-10 11:11 ` Andrii Kolomoiets
@ 2019-10-14 23:54 ` Lars Ingebrigtsen
2019-10-15 0:33 ` Lars Ingebrigtsen
2 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-14 23:54 UTC (permalink / raw)
To: 31497
-------------------- Start of forwarded message --------------------
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Subject: bug#31497: 27.0.50; vc-hg doesn't separate standard error from
standard output
Date: Thu, 10 Oct 2019 14:11:45 +0300
Cc: bug-gnu-emacs@gnu.org
To: larsi@gnus.org
Lars Ingebrigtsen writes:
>> $ hg log -l 1 -r . -T '{rev}'
>>
>> but that outputs
>>
>> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>
> filter out the "not trusting" lines, or is this just one of a
> gazillion error messages that can be output here?
Other errors also printed to stderr, so filtering out stderr completely
can hide meaningful errors.
This particular warning is also present in log and annotate buffers and
completely messing up vc-dir buffer.
There are option 'ui.report_untrusted' in hg since this commit:
https://www.mercurial-scm.org/repo/hg/rev/97369f6a6bb6
It present in mercurial 2.6.2, the earliest version I found in pip.
To filter out just "not trusting" warning I can propose to run hg like
this:
hg log --config ui.report_untrusted=0 -l 1 -r . -T '{rev}'
or specify '--config ui.report_untrusted=0' as default value for
vc-hg-global-switches
I think 'pull' and 'push' are the only commands that must print this
warning.
-------------------- End of forwarded message --------------------
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: [Andrii Kolomoiets] bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2019-10-14 23:54 ` bug#31497: [Andrii Kolomoiets] " Lars Ingebrigtsen
@ 2019-10-15 0:33 ` Lars Ingebrigtsen
2019-10-16 7:32 ` Andrii Kolomoiets
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-15 0:33 UTC (permalink / raw)
To: 31497; +Cc: Andrii Kolomoiets
(Please keep the debbugs address in the Cc list -- otherwise the bug
tracker won't get the message.)
>>> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>>> not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>>
>> filter out the "not trusting" lines, or is this just one of a
>> gazillion error messages that can be output here?
>
> Other errors also printed to stderr, so filtering out stderr completely
> can hide meaningful errors.
>
> This particular warning is also present in log and annotate buffers and
> completely messing up vc-dir buffer.
>
> There are option 'ui.report_untrusted' in hg since this commit:
> https://www.mercurial-scm.org/repo/hg/rev/97369f6a6bb6
So that's 2007, so it should presumably be safe to add that.
> It present in mercurial 2.6.2, the earliest version I found in pip.
>
> To filter out just "not trusting" warning I can propose to run hg like
> this:
> hg log --config ui.report_untrusted=0 -l 1 -r . -T '{rev}'
Could you propose a patch that adds this?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#31497: [Andrii Kolomoiets] bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2019-10-15 0:33 ` Lars Ingebrigtsen
@ 2019-10-16 7:32 ` Andrii Kolomoiets
2019-10-17 2:26 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Andrii Kolomoiets @ 2019-10-16 7:32 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 31497
[-- Attachment #1: Type: text/plain, Size: 831 bytes --]
On 15 Oct 2019, at 03:33, Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
> (Please keep the debbugs address in the Cc list -- otherwise the bug
> tracker won't get the message.)
My bad. I emailed with "reply via email to" button on "Mail Archives"
site (https://lists.gnu.org/archive/html/), didn't know what address
must be specified in Cc.
>> There are option 'ui.report_untrusted' in hg since this commit:
>> https://www.mercurial-scm.org/repo/hg/rev/97369f6a6bb6
>
> So that's 2007, so it should presumably be safe to add that.
>
>> It present in mercurial 2.6.2, the earliest version I found in pip.
>>
>> To filter out just "not trusting" warning I can propose to run hg like
>> this:
>> hg log --config ui.report_untrusted=0 -l 1 -r . -T '{rev}'
>
> Could you propose a patch that adds this?
Please see attached patch.
[-- Attachment #2: hg-untrusted.patch --]
[-- Type: application/octet-stream, Size: 1507 bytes --]
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 61d5ee1d3a..cc737b30b1 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -237,6 +237,7 @@ vc-hg-state-slow
process-environment)))
(process-file
vc-hg-program nil t nil
+ "--config" "ui.report_untrusted=0"
"--config" "alias.status=status"
"--config" "defaults.status="
"status" "-A" (file-relative-name file)))
@@ -1436,7 +1437,7 @@ vc-hg-merge-branch
(buffer (format "*vc-hg : %s*" (expand-file-name root)))
;; Disable pager.
(process-environment (cons "HGPLAIN=1" process-environment)))
- (apply 'vc-do-async-command buffer root vc-hg-program '("merge"))
+ (apply 'vc-do-async-command buffer root vc-hg-program '("--config" "ui.report_untrusted=0" "merge"))
(with-current-buffer buffer (vc-run-delayed (vc-compilation-mode 'hg)))
(vc-set-async-update buffer)))
@@ -1447,7 +1448,8 @@ vc-hg-command
This function differs from vc-do-command in that it invokes
`vc-hg-program', and passes `vc-hg-global-switches' to it before FLAGS."
;; Disable pager.
- (let ((process-environment (cons "HGPLAIN=1" process-environment)))
+ (let ((process-environment (cons "HGPLAIN=1" process-environment))
+ (flags (append '("--config" "ui.report_untrusted=0") flags)))
(apply 'vc-do-command (or buffer "*vc*") okstatus vc-hg-program file-or-list
(if (stringp vc-hg-global-switches)
(cons vc-hg-global-switches flags)
^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#31497: [Andrii Kolomoiets] bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
2019-10-16 7:32 ` Andrii Kolomoiets
@ 2019-10-17 2:26 ` Lars Ingebrigtsen
0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-17 2:26 UTC (permalink / raw)
To: Andrii Kolomoiets; +Cc: 31497
Andrii Kolomoiets <andreyk.mad@gmail.com> writes:
>> Could you propose a patch that adds this?
>
> Please see attached patch.
Thanks; applied to Emacs 27.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-10-17 2:26 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18 17:42 bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output Philipp Stephani
2019-10-09 21:57 ` Lars Ingebrigtsen
2019-10-10 7:30 ` Eli Zaretskii
2019-10-11 7:27 ` Lars Ingebrigtsen
2019-10-10 11:11 ` Andrii Kolomoiets
2019-10-14 23:54 ` bug#31497: [Andrii Kolomoiets] " Lars Ingebrigtsen
2019-10-15 0:33 ` Lars Ingebrigtsen
2019-10-16 7:32 ` Andrii Kolomoiets
2019-10-17 2:26 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).