diff --git a/lib/train/extras/stat.rb b/lib/train/extras/stat.rb index e9b0693c..fa8bdc5e 100644 --- a/lib/train/extras/stat.rb +++ b/lib/train/extras/stat.rb @@ -48,7 +48,7 @@ def self.linux_stat(shell_escaped_path, backend) { type: find_type(tmask), - mode: tmask & 00777, + mode: tmask & 07777, owner: fields[2], group: fields[4], mtime: fields[7].to_i, @@ -85,7 +85,7 @@ def self.bsd_stat(shell_escaped_path, backend) { type: find_type(tmask), - mode: tmask & 00777, + mode: tmask & 07777, owner: fields[2], group: fields[4], mtime: fields[7].to_i, @@ -113,7 +113,7 @@ def self.aix_stat(shell_escaped_path, backend) { type: find_type(tmask), - mode: tmask & 00777, + mode: tmask & 07777, owner: fields[1], group: fields[2], mtime: fields[3].to_i, diff --git a/test/unit/extras/stat_test.rb b/test/unit/extras/stat_test.rb index 07517d46..d6b4c759 100644 --- a/test/unit/extras/stat_test.rb +++ b/test/unit/extras/stat_test.rb @@ -16,27 +16,27 @@ cls.find_type(00140755).must_equal :socket end - it 'detects sockets' do + it 'detects symlinks' do cls.find_type(00120755).must_equal :symlink end - it 'detects sockets' do + it 'detects files' do cls.find_type(00100755).must_equal :file end - it 'detects sockets' do + it 'detects block devices' do cls.find_type(00060755).must_equal :block_device end - it 'detects sockets' do + it 'detects directories' do cls.find_type(00040755).must_equal :directory end - it 'detects sockets' do + it 'detects character devices' do cls.find_type(00020755).must_equal :character_device end - it 'detects sockets' do + it 'detects pipes' do cls.find_type(00010755).must_equal :pipe end end @@ -53,11 +53,12 @@ it 'reads correct stat results' do res = Minitest::Mock.new + # 43ff is 41777; linux_stat strips the 4 res.expect :stdout, "360\n43ff\nroot\n0\nroot\n0\n1444520846\n1444522445\n?" backend.expect :run_command, res, [String] cls.linux_stat('/path', backend).must_equal({ type: :directory, - mode: 00777, + mode: 01777, owner: 'root', group: 'root', mtime: 1444522445, @@ -93,7 +94,7 @@ backend.expect :run_command, res, [String] cls.bsd_stat('/path', backend).must_equal({ type: :directory, - mode: 00777, + mode: 01777, owner: 'root', group: 'root', mtime: 1444522445,