From 0cecf9f121d66539be86fa76bdd7fb9221f54389 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 29 Apr 2019 19:58:53 -0400 Subject: vim-patch:8.0.1263: others can read the swap file if a user is careless Problem: Others can read the swap file if a user is careless with his primary group. Solution: If the group permission allows for reading but the world permissions doesn't, make sure the group is right. https://github.com/vim/vim/commit/5a73e0ca54c77e067c3b12ea6f35e3e8681e8cf8 --- src/nvim/testdir/test_swap.vim | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index 4dc8803a2a..a2efc8976e 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -51,6 +51,40 @@ func Test_swap_directory() call delete("Xtest.je", "rf") endfunc +func Test_swap_group() + if !has("unix") + return + endif + let groups = split(system('groups')) + if len(groups) <= 1 + throw 'Skipped: need at least two groups, got ' . groups + endif + + call delete('Xtest') + split Xtest + call setline(1, 'just some text') + wq + if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d' + throw 'Skipped: test file does not have the first group' + else + silent !chmod 640 Xtest + call system('chgrp ' . groups[1] . ' Xtest') + if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d' + throw 'Skipped: cannot set second group on test file' + else + split Xtest + let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g') + call assert_match('Xtest', swapname) + " Group of swapfile must now match original file. + call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname)) + + bwipe! + endif + endif + + call delete('Xtest') +endfunc + func Test_missing_dir() call mkdir('Xswapdir') exe 'set directory=' . getcwd() . '/Xswapdir' -- cgit From 3a8ebda10ae0acaf59c5af529e868db21282e025 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 29 Apr 2019 20:48:01 -0400 Subject: vim-patch:8.0.1265: swap test not skipped when there is one group Problem: Swap test not skipped when there is one group. Solution: Convert list to string for the message. https://github.com/vim/vim/commit/ad7dac85c3c90893e78e5463ca44b874082b482f --- src/nvim/testdir/test_swap.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index a2efc8976e..394771effd 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -57,7 +57,7 @@ func Test_swap_group() endif let groups = split(system('groups')) if len(groups) <= 1 - throw 'Skipped: need at least two groups, got ' . groups + throw 'Skipped: need at least two groups, got ' . string(groups) endif call delete('Xtest') -- cgit From c3edbf813a2a67d5d0889ff1420407dfb78847cb Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 29 Apr 2019 20:59:43 -0400 Subject: vim-patch:8.0.1267: Test_swap_group may leave file behind Problem: Test_swap_group may leave file behind. Solution: Add a try/finally. https://github.com/vim/vim/commit/5842a748be8039fd6d267f5557fe391c6c95399d --- src/nvim/testdir/test_swap.vim | 44 ++++++++++++++++++++++-------------------- src/nvim/testdir/test_undo.vim | 1 + 2 files changed, 24 insertions(+), 21 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index 394771effd..3db438cf4b 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -60,29 +60,31 @@ func Test_swap_group() throw 'Skipped: need at least two groups, got ' . string(groups) endif - call delete('Xtest') - split Xtest - call setline(1, 'just some text') - wq - if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d' - throw 'Skipped: test file does not have the first group' - else - silent !chmod 640 Xtest - call system('chgrp ' . groups[1] . ' Xtest') - if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d' - throw 'Skipped: cannot set second group on test file' + try + call delete('Xtest') + split Xtest + call setline(1, 'just some text') + wq + if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d' + throw 'Skipped: test file does not have the first group' else - split Xtest - let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g') - call assert_match('Xtest', swapname) - " Group of swapfile must now match original file. - call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname)) - - bwipe! + silent !chmod 640 Xtest + call system('chgrp ' . groups[1] . ' Xtest') + if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d' + throw 'Skipped: cannot set second group on test file' + else + split Xtest + let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g') + call assert_match('Xtest', swapname) + " Group of swapfile must now match original file. + call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname)) + + bwipe! + endif endif - endif - - call delete('Xtest') + finally + call delete('Xtest') + endtry endfunc func Test_missing_dir() diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim index 9729ca9f57..beb44f9699 100644 --- a/src/nvim/testdir/test_undo.vim +++ b/src/nvim/testdir/test_undo.vim @@ -242,6 +242,7 @@ func Test_undojoin() endfunc func Test_undo_write() + call delete('Xtest') split Xtest call feedkeys("ione one one\", 'xt') w! -- cgit