oss-sec mailing list archives

Re: Re: Fw: Security risk of vim swap files


From: Florent Rougon <f.rougon () free fr>
Date: Wed, 01 Nov 2017 22:35:59 +0100

Michael Orlitzky <michael () orlitzky com> wrote:

This is what I used to do in emacs before I disabled the backups
completely. I was wondering if there were any problems with it. If there
aren't, it seems like a better default to me, for both emacs and vim.

On Emacs, this has been possible for a loooong time, and in a way that
prevents collisions due to the same basename:

  (setq backup-directory-alist '(("." . "/some/path")))

This saves backup files in /some/path with names such as
'!home!me!some-subdir!some-basename~'.

It's also possible to programmatically disable the backup feature for
specific files:

  ;; For `some',
  ;; cf. <http://stackoverflow.com/questions/5902847/how-do-i-apply-or-to-a-list-in-elisp>.
  (require 'cl)
  (defun my-backup-enable-predicate (fullpath)
    (and (not (some #'(lambda (file)
                         (string-equal fullpath (expand-file-name file)))
                    '("~/.zsh_history"
                      "~/.local/share/mc/history")))
         (normal-backup-enable-predicate fullpath)))

  (setq backup-enable-predicate 'my-backup-enable-predicate)

Finally, an easier but non-programmatic solution when you can afford to
write comments directly to the file: use “file variables”, e.g., with
this at the beginning of the file you want to never be backed up:

-*- make-backup-files: nil -*-

Regards

-- 
Florent


Current thread: