From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?=C3=86var_?= =?UTF-8?Q?Arnfj=C3=B6r=C3=B0?= Bjarmason Newsgroups: gmane.emacs.bugs Subject: bug#24478: 25.1; Regression in 25.1: .tramp_history files are littered in non-$HOME working directories Date: Tue, 11 Oct 2016 16:34:31 +0200 Message-ID: References: <8737kuan39.fsf@booking.com> <87zimzke24.fsf@gmx.de> <83int0ebfz.fsf@gnu.org> <87y41vm1nn.fsf@gmx.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1476196660 9295 195.159.176.226 (11 Oct 2016 14:37:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Oct 2016 14:37:40 +0000 (UTC) Cc: 24478@debbugs.gnu.org, Ted Zlatanov To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 11 16:37:29 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btyBK-0000kR-2N for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Oct 2016 16:37:26 +0200 Original-Received: from localhost ([::1]:56191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btyBI-0007gr-Iy for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Oct 2016 10:37:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btyA3-0006kv-AR for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 10:36:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bty9y-0003bh-5D for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 10:36:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bty9y-0003bZ-0V for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 10:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bty9x-0003U7-Ma for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 10:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C3=86var_?= =?UTF-8?Q?Arnfj=C3=B6r=C3=B0?= Bjarmason Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Oct 2016 14:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24478 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24478-submit@debbugs.gnu.org id=B24478.147619650213321 (code B ref 24478); Tue, 11 Oct 2016 14:36:01 +0000 Original-Received: (at 24478) by debbugs.gnu.org; 11 Oct 2016 14:35:02 +0000 Original-Received: from localhost ([127.0.0.1]:52276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bty8z-0003Sm-Ui for submit@debbugs.gnu.org; Tue, 11 Oct 2016 10:35:02 -0400 Original-Received: from mail-qt0-f180.google.com ([209.85.216.180]:36509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bty8y-0003SH-Nb for 24478@debbugs.gnu.org; Tue, 11 Oct 2016 10:35:01 -0400 Original-Received: by mail-qt0-f180.google.com with SMTP id m5so15500344qtb.3 for <24478@debbugs.gnu.org>; Tue, 11 Oct 2016 07:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=7wZHHBIFAaRHReoz50fRUSHKn+Xe5OFkt/ciV9Mc+QA=; b=MG4tqcNsmq4/2a5E1Oj8eaBdKjJYSIe88GI2rfd5Wt5FIHmBiwrZB1MZW8HkCFqAJx /m9P7HiI8W443TIcB843Y149RNqR574bNn9wi5fuy5gtSmh1k70ME+HjDZY8/m1MtyDX 0vo/s6Ixq85DePSqGGqB9iNfj5EdS/DQpkP2B6pXTY1YSK25A3aaMuJpxDyYjJvMtDUV TecJxsTRarFuwjRWparbZePe3Br1Vn1A+roU0yZvt333IsUjgNIOQtNGs7jBSN0RMeHp ZOylPkrLdOXaQT/zOQ7xypPL9XCFEjnNua7X3vFpcGKBv1DLp557ioO6rzABvudb2jCN FqLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7wZHHBIFAaRHReoz50fRUSHKn+Xe5OFkt/ciV9Mc+QA=; b=BxbZuBAc6LKHsgloSIe9kaHBKRbPB65Lt9gr5I0ApSuUzT5fTX4sX5b1fhKFKPVPT6 dPKqjb2IKynbJDXSTssyQdr3exHRiKA5Ow/gU9TgOp1+jYzHfXTZkPimzcTkCWxquPkZ quHt1qeVTSwxI9BvPpy3FKhNApzkqR1uNrDhJ8aGqlNopUuDWG8upWeeHedDcgbGj4pA XMVwJvkQ1Hueo3VseP/6NF+NEikCFrdd/YOIX1/Sk6+9GFfGR+hSuo7c7+OMLlOl36p4 rRaV7NS1O3sbiK6qxAXLHULtqE+F6WnOljgecImW38O9s3Cw0UAfR4APQpqFOxIj4o1S rVZg== X-Gm-Message-State: AA6/9RlJjmP5c3aBRtvdSurtPTRoa0ZK1++tBWyJUTzVm909KXhZUgh9M7dJuAIkIwq61smxMvZskAyX4xgBJA== X-Received: by 10.200.40.91 with SMTP id 27mr3610197qtr.135.1476196491515; Tue, 11 Oct 2016 07:34:51 -0700 (PDT) Original-Received: by 10.55.87.133 with HTTP; Tue, 11 Oct 2016 07:34:31 -0700 (PDT) In-Reply-To: <87y41vm1nn.fsf@gmx.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:124334 Archived-At: On Tue, Oct 11, 2016 at 3:54 PM, Michael Albinus w= rote: > =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason writes: > > Hi =C3=86var, > >> 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. > > I'm also unhappy about this story. I really would like to use a proper > and robust default value for this. But there isn't one so far. > >> * In emacs-24 there was no way to have a Tramp history file, we'd >> just specify a HISTFILE=3D/dev/null environment variable. > > This was introduced back in 2014. Before this change, HISFILE was unset > somewhere else in the initialization hand-shake, but at a later > point. It didn't work properly then. > >> * 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=3D19731 > > Bug#19371 has reported, that there is a bash bug > which ha= s > this effect. It is no Tramp error, and I would regard this setting still > be the best one if possible. But due to this bash bug, this setting > would damage the remote system. So we cannot use "/dev/null" as default, > even if the bash bug has been fixed. There will still be system in the > wild with this bug. > >> * 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. > > Yes. > >> * 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=3D20446 but I don't see >> how it could eat the bash history if it's set to not have any history >> file by default. > > Glenn did report, that in his use case unsetting HISTFILE has changed > his ~/.bash_history to a zero size. Not acceptable, and again a special > behaviour of bash :-( > > So the only solution I could thing about is setting this variable to a > Tramp specific value. > >> * 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. > > "~/.tramp_history" would be the obvious choice, but "~/" is not > guaranteed to exist. An example is hydra, were the tests failed with > this setting. > >> 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. > > How do you want explain it to bash users like Glenn? Their history file > will get lost, again. Thanks for all the follow-up details. I mainly included all of that to get all this straight in my head, but I was apparently wrong about it being viable to revert to the old behavior vis-a-vis unlinking /dev/null on those old systems. >> 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. > > I still don't understand why the ".tramp_history" file is spread over > the file system. This setting is apllied immediately after connecting to > the remote host. I would assume that one lands in the home directory > there; ".tramp_history" should be expanded relatively to that directory. > > Could you show hot it happens to you that it is expanded to another > place? Pls run Tramp from scratch, after increasing the debug level by > > (setq tramp-verbose 6) > > There will be a Tramp debug buffer, which might tell us what happens. > > Best regards, Michael. All I'm doing is e.g.: 1. C-x C-f //ssh:puppet-staging:/etc/puppet/environment/aearnfjord/puppet R= ET 2. Run some command e.g. M-x grep 3. This results in: $ wc -l $PWD/.tramp_history 39 /etc/puppet/environments/aearnfjord/puppet/.tramp_history I've snipped away the parts I think are irrelevant because it's very verbose, but this hopefully the relevant tramp-verbose=3D6 output: [I don't have an existing tramp connection at this point, so it connects] 16:24:08.497153 tramp-process-one-action (5) # Looking for regexp "\(^[^#$%= > ]*[#$%>] *\)\'" from remote shell 16:24:08.497248 tramp-process-one-action (5) # Call =E2=80=98tramp-action-s= ucceed=E2=80=99 16:24:08.497369 tramp-process-actions (6) # nohup: redirecting stderr to stdout Last login: Tue Oct 11 16:03:15 2016 from ^M [...] ^[[1;31mPROD^[[m puppet-staging ~ (DUMMY) $ 16:24:08.497762 tramp-process-actions (3) # Waiting for prompts from remote shell...done 16:24:08.498117 tramp-maybe-open-connection (3) # Found remote shell prompt on =E2=80=98puppet-staging=E2=80=99 16:24:08.498251 tramp-open-shell (5) # Opening remote shell =E2=80=98/bin/s= h=E2=80=99... 16:24:08.498387 tramp-send-command (6) # exec env ENV=3D'' HISTFILE=3D.tramp_history PROMPT_COMMAND=3D'' PS1=3D\#\$\ PS2=3D'' PS3=3D'= ' /bin/sh 16:24:08.522855 tramp-wait-for-regexp (6) # #$ 16:24:08.522995 tramp-open-shell (5) # Opening remote shell =E2=80=98/bin/s= h=E2=80=99...done 16:24:08.523075 tramp-open-connection-setup-interactive-shell (5) # Setting up remote shell environment 16:24:08.523157 tramp-send-command (6) # stty tab0 -inlcr -onlcr -echo kill '^U' erase '^H' 16:24:08.543347 tramp-wait-for-regexp (6) # [...] Then this and all subsequent commands end up in my non-~ .tramp_history: $ head -n 2 /etc/puppet/environments/aearnfjord/puppet/.tramp_history #1476195869 stty tab0 -inlcr -onlcr -echo kill '^U' erase '^H' If this isn't the relevant output or you'd like to me to try something else I'd be happy to provide more details.