unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Michael Albinus <michael.albinus@gmx.de>,
	Ted Zlatanov <tzz@lifelogs.com>,
	24478@debbugs.gnu.org
Subject: bug#24478: 25.1; Regression in 25.1: .tramp_history files are littered in non-$HOME working directories
Date: Mon, 10 Oct 2016 13:14:57 +0200	[thread overview]
Message-ID: <CACBZZX7Gb9cSbNCPdooMpupNLKhHAPyrR5ohcqAVt=wE8kUwJg@mail.gmail.com> (raw)
In-Reply-To: <83int0ebfz.fsf@gnu.org>

On Mon, Oct 10, 2016 at 12:38 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Michael Albinus <michael.albinus@gmx.de>
>> Date: Thu, 22 Sep 2016 20:02:59 +0200
>> Cc: Ævar Arnfjörð Bjarmason <avarab@gmail.com>,
>>  24478@debbugs.gnu.org
>>
>> Ævar Arnfjörð Bjarmason <avar@booking.com> writes:
>>
>> Hi,
>>
>> > There's a regression in 25.1 introduced by 1e04ea9 (although that seems
>> > to also have fixed an issue): Now tramp-histfile-override is set to
>> > ".tramp_history", which is good, but I would expect it to be created in
>> > $HOME on remote hosts.
>> >
>> > Instead when I e.g.:
>> >
>> >  1. C-x C-f //ssh:<hostname>:/usr/local/git_tree/sysadmin/
>> >  2. Run e.g. magit to make a commit
>> >  3. I end up with:
>> >
>> >     $ echo $PWD/.tramp_history
>> >     /usr/local/git_tree/sysadmin/.tramp_history
>> >     $ wc -l !$
>> >     wc -l $PWD/.tramp_history
>> >     34 /usr/local/git_tree/sysadmin/.tramp_history
>>
>> Most of the shells I know off use the home directory, when you specify
>> just the relative file name ".tramp_history".
>>
>> > From reading https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20446 and
>> > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19731#56 this seems like
>> > an unintended bug.
>> >
>> > Just setting:
>> >
>> >     (setq tramp-histfile-override "~/.tramp_history")
>> >
>> > Works for me. Now it's always created in ~.
>>
>> I have thought about this, when I was fixing bug#19731. Unfortunately,
>> there exist shells which cannot expand "~/". Other shells cannot expand
>> "$HOME/". So I really don't know a robust default we could offer.
>>
>> Maybe one should give this problem more emphasis in the Tramp
>> manual. But who reads manuals?
>
> Michael, does the above mean this bug should be closed as wontfix?  It
> currently blocks a release, so I'd like to resolve this some way soon.

I'm the reporter, so I obviously have a dog in this fight, but I don't
think that makes sense. This whole facility introduced in the emacs-25
series still seems really broken since its introduction, and the
various regressions reported have just resulted in other regressions
taking their place, the latest one being discussed in this ticket.

Here's a Git history showing the back & forth this has gone through:

    git log --reverse -p -Gtramp-histfile-override -- 'lisp/net/*tramp*.el'

I might have read those commits incorrectly, but it seems to me that:

 * In emacs-24 there was no way to have a Tramp history file, we'd
just specify a HISTFILE=/dev/null environment variable.

 * 9be1538 added an option to change that, so you could have a history
file as a file, defaulting to /dev/null, but they way it was
implemented caused it to unlink /dev/null, as reported in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19731

 * So Michael patched it to make 'unset an option, which was
implemented in 6f8372d, as far as I can tell at this point the
facility worked the way it did in emacs-24 again. I.e. no history by
default, but no regression with unlinking /dev/null

 * 'unset was made the default by Michael in 954ca0f, but just a few
hours later this was set to t instead in c10828b, which does the same
thing as 'unset according to the commit message. I.e. just an internal
refactoring. This was followed-up by 24fa4ff to refactor it some more.

* It was then changed from t to ".tramp_history" in 1e04ea9. The
commit message says to fix
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20446 but I don't see
how it could eat the bash history if it's set to not have any history
file by default.

* Now because it's ".tramp_history" and not "~/.tramp_history" it gets
created in random non-~ directories you open with tramp, but more
importantly, and I didn't realize this in my initial report, the shell
history *might be shared between multiple users*, which seems like a
bad security issue.

It seems to me that the best solution to this whole problem is to set
it to "t" again which would return to the non-history days of
emacs-24, since apparently using ~ can't be counted on.

In addition, depending on the bug with history potentially being
shared between users now that it's being dumped in random potentially
shared FS directories they open with tramp, changing this to
".tramp_history" might have caused a security issue worth of a CVE,
but I haven't investigated that, but we *certainly* went from no
history by default in emacs-24 to history littered in potentially
world readable directories in emacs-25.

The permissions on the file itself might have mitigated data leakage
in some cases, but in those cases it would have blocked other Emacs
users from recording their shell history. In addition not all remote
FSs tramp supports working with can be relied upon to obey HISTFILE
permissions.





  reply	other threads:[~2016-10-10 11:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 10:21 bug#24478: 25.1; Regression in 25.1: .tramp_history files are littered in non-$HOME working directories Ævar Arnfjörð Bjarmason
2016-09-22 18:02 ` Michael Albinus
2016-10-10 10:38   ` Eli Zaretskii
2016-10-10 11:14     ` Ævar Arnfjörð Bjarmason [this message]
2016-10-11 13:54       ` Michael Albinus
2016-10-11 14:34         ` Ævar Arnfjörð Bjarmason
2016-10-11 14:44           ` Michael Albinus
2016-10-11 14:47             ` Ævar Arnfjörð Bjarmason
2016-10-12 14:05               ` Michael Albinus
2016-10-13 14:51                 ` Michael Albinus
2016-10-13 15:18                   ` Ævar Arnfjörð Bjarmason
2016-10-13 16:30                     ` Michael Albinus
2016-10-15 10:38                       ` Michael Albinus
2016-10-22 16:55                         ` Michael Albinus
2016-10-23 23:29                           ` Glenn Morris
2016-10-24  7:09                             ` Michael Albinus
2016-10-24 13:10                       ` Michael Albinus
2016-10-24 13:54                         ` Ævar Arnfjörð Bjarmason
2016-10-24 14:32                           ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACBZZX7Gb9cSbNCPdooMpupNLKhHAPyrR5ohcqAVt=wE8kUwJg@mail.gmail.com' \
    --to=avarab@gmail.com \
    --cc=24478@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).