Subject: 24.5; TRAMP to superuser overwrites remote /dev/null eventually

From: Georgiy Tugai <[email-masked]>
Date: Sun, 18 Oct 2015 01:42:06 +1030

This bug is quite tricky to reproduce as it requires a significant
amount of TRAMP operations to occur during the same connection to a
machine (or localhost) as superuser.

Here are the commands to reproduce the issue from inside emacs -Q; I
have also attached a dribblefile.

WARNING! These commands will exercise your disk (and CPU) quite a bit by
saving a file via TRAMP 500 times.

C-x C-f /sudo:localhost:/root/temp.txt
RET F3 test F3 RET C-x C-s F4 C-u 500 F4 C-x C-c

I have tracked the issue down to the remote shell (sh) "atomically
overwriting" the HISTFILE (i.e. write to temporary name, copy over
original), thus replacing /dev/null with an ordinary file.

I have reproduced this outside of Emacs, by using the same set of
environment variables TRAMP sets on it's shells

$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Oct 18 01:21 /dev/null
$ su
# HISTSIZE=2 HISTFILE=/dev/null sh
# echo 1
1
# echo 2
2
# echo 3
3
# exit
# ls -l /dev/null
-rw------- 1 root root 14 Oct 18 01:15 /dev/null

--------------------------------------------------------------------------------

In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.10)
 of 2015-04-13 on andromeda.sabayon.org
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
Configured using:
 `configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --disable-dependency-tracking
 --disable-silent-rules --libdir=/usr/lib64 --program-suffix=-emacs-24
 --infodir=/usr/share/info/emacs-24 --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --with-gameuser=:gamestat --without-compress-install
 --with-file-notification=inotify --enable-acl --with-dbus --with-gnutls
 --with-gpm --without-hesiod --with-kerberos --with-kerberos5
 --without-xml2 --without-selinux --without-wide-int --with-zlib
 --with-sound=alsa --with-x --without-ns --without-gconf
 --without-gsettings --without-toolkit-scroll-bars --with-gif
 --with-jpeg --with-png --with-rsvg --with-tiff --with-xpm
 --without-imagemagick --with-xft --without-libotf --without-m17n-flt
 --with-x-toolkit=gtk3 GENTOO_PACKAGE=app-editors/emacs-24.5 'CFLAGS=-O2
 -march=x86-64 -pipe -nopie' CPPFLAGS= 'LDFLAGS=-Wl,-O1
 -Wl,--as-needed''

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-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
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Mark set
delete-forward-char: Text is read-only
Tramp: Opening connection for root@localhost using sudo...
Tramp: Sending command `exec env SHELL=/bin/sh sudo -u root -s -H -p Password:'
Tramp: Waiting for prompts from remote shell...
Tramp: Sending Password
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on `localhost'
Tramp: Opening connection for root@localhost using sudo...done
C-x C-g is undefined

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils apropos help-mode em-unix
em-term term disp-table easymenu ehelp em-script em-prompt em-ls em-hist
em-pred em-glob em-dirs em-cmpl em-basic em-banner em-alias esh-var
esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups eshell
esh-module esh-mode esh-util epa-file epa derived epg epg-config
tramp-cache dired tramp-sh tramp tramp-compat auth-source eieio byte-opt
bytecomp byte-compile cl-extra cl-loaddefs cl-lib cconv eieio-core
gnus-util mm-util mail-prsvr password-cache tramp-loaddefs trampver
shell pcomplete comint ansi-color ring format-spec advice help-fns
time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer 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 make-network-process dbusbind inotify dynamic-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 127965 10209)
 (symbols 48 22961 0)
 (miscs 40 54 165)
 (strings 32 28721 4697)
 (string-bytes 1 833507)
 (vectors 16 16789)
 (vector-slots 8 476975 5504)
 (floats 8 169 251)
 (intervals 56 2159 1090)
 (buffers 960 16)
 (heap 1024 50763 714))