FS#57772 - [vim-runtime] vim calls `/bin/bash -c '(install -dm 700 ~/.vim/swap) > XXX'` on each run

Attached to Project: Arch Linux
Opened by Alexander Meshcheryakov (Self-Perfection) - Friday, 09 March 2018, 16:48 GMT
Last edited by Levente Polyak (anthraxx) - Wednesday, 09 May 2018, 22:44 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Levente Polyak (anthraxx)
Architecture All
Severity Very Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Latest version of archlinux.vim contains following code:

" Move the swap file location to protect against CVE-2017-1000382
if ! isdirectory('~/.vim/swap/')
silent! call system('install -dm 700 ~/.vim/swap')
endif
set directory=~/.vim/swap/

However check for existing directory does not work and vim always calls install. This can be checked by running:
[ -d ~/.vim/swap ] && strace -ff -e trace=execve vim -c :q

Apparently vim checks for literal dir '~/.vim/swap' and does not replace ~ with $HOME. This can be fixed by replacing
isdirectory('~/.vim/swap/')
with
isdirectory(expand('~/.vim/swap/'))

Additional info:
* package version(s) - 8.0.1542-2
This task depends upon

Closed by  Levente Polyak (anthraxx)
Wednesday, 09 May 2018, 22:44 GMT
Reason for closing:  Fixed
Additional comments about closing:  8.0.1806-1
Comment by Alexander Meshcheryakov (Self-Perfection) - Friday, 09 March 2018, 17:02 GMT
Actually I'd say this fix should be implented this way:

let &directory='~/.vim/swap/'
if ! isdirectory(expand(&directory))
silent! call mkdir(expand(&directory), 'p', 0700)
endif

This avoids running shell and external tool to create swap directory.
Comment by Eli Schwartz (eschwartz) - Sunday, 11 March 2018, 01:21 GMT
See also  FS#57715 ,  FS#57682 

We are collecting bugreports like flies, but technically these are not duplicates as each one refers to a different issue with the wider change involved here.

Loading...