From d028748c3481008a3696b11aec130a025cbdfcd4 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sun, 10 Jul 2016 20:30:05 +0200 Subject: [PATCH] bugfix: higher mode bits on local connection --- lib/train/transports/local_file.rb | 2 +- test/integration/bootstrap.sh | 3 +++ test/integration/cookbooks/test/recipes/prep_files.rb | 7 +++++++ test/integration/tests/path_file_test.rb | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/train/transports/local_file.rb b/lib/train/transports/local_file.rb index 386a8184..387015ec 100644 --- a/lib/train/transports/local_file.rb +++ b/lib/train/transports/local_file.rb @@ -69,7 +69,7 @@ def stat @stat = { type: Train::Extras::Stat.find_type(file_stat.mode), - mode: file_stat.mode & 00777, + mode: file_stat.mode & 07777, mtime: file_stat.mtime.to_i, size: file_stat.size, owner: pw_username(file_stat.uid), diff --git a/test/integration/bootstrap.sh b/test/integration/bootstrap.sh index ae48eea3..dfcf7f5d 100644 --- a/test/integration/bootstrap.sh +++ b/test/integration/bootstrap.sh @@ -9,6 +9,9 @@ test ! -e /tmp/symlink && \ chmod 0777 /tmp/symlink chmod 0765 /tmp/file +echo -n 'hello suid/sgid/sticky' > /tmp/sfile +chmod 7765 /tmp/sfile + test ! -e /tmp/pipe && \ mkfifo /tmp/pipe diff --git a/test/integration/cookbooks/test/recipes/prep_files.rb b/test/integration/cookbooks/test/recipes/prep_files.rb index aa004222..4ed857a6 100644 --- a/test/integration/cookbooks/test/recipes/prep_files.rb +++ b/test/integration/cookbooks/test/recipes/prep_files.rb @@ -16,6 +16,13 @@ content 'hello world' end +file '/tmp/sfile' do + mode '7765' + owner 'root' + group gid + content 'hello suid/sgid/sticky' +end + directory '/tmp/folder' do mode '0567' owner 'root' diff --git a/test/integration/tests/path_file_test.rb b/test/integration/tests/path_file_test.rb index f5ac8851..db073380 100644 --- a/test/integration/tests/path_file_test.rb +++ b/test/integration/tests/path_file_test.rb @@ -82,4 +82,11 @@ j['type'].must_equal :file end end + + describe 'regular file' do + let(:file) { backend.file('/tmp/sfile') } + it 'has mode 7765' do + file.mode.must_equal(07765) + end + end end