提交 e426ea52 编写于 作者: A antirez

Test: fix RDB test checking file permissions.

When the test is executed using the root account, setting the permission
to 222 does not work as expected, as root can read files with 222
permission.

Now we skip the test if root is detected.

This fixes issue #1034 and the duplicated #1040 issue.

Thanks to Jan-Erik Rediger (@badboy on Github) for finding a way to reproduce the issue.
上级 d0c9a2a7
...@@ -53,13 +53,24 @@ proc start_server_and_kill_it {overrides code} { ...@@ -53,13 +53,24 @@ proc start_server_and_kill_it {overrides code} {
# Make the RDB file unreadable # Make the RDB file unreadable
file attributes [file join $server_path dump.rdb] -permissions 0222 file attributes [file join $server_path dump.rdb] -permissions 0222
# Detect root account (it is able to read the file even with 002 perm)
set isroot 0
catch {
open [file join $server_path dump.rdb]
set isroot 1
}
# Now make sure the server aborted with an error # Now make sure the server aborted with an error
start_server_and_kill_it [list "dir" $server_path] { if {!$isroot} {
wait_for_condition 50 100 { start_server_and_kill_it [list "dir" $server_path] {
[string match {*Fatal error loading*} \ test {Server should not start if RDB file can't be open} {
[exec tail -n1 < [dict get $srv stdout]]] wait_for_condition 50 100 {
} else { [string match {*Fatal error loading*} \
fail "Server started even if RDB was unreadable!" [exec tail -n1 < [dict get $srv stdout]]]
} else {
fail "Server started even if RDB was unreadable!"
}
}
} }
} }
...@@ -76,10 +87,12 @@ close $fd ...@@ -76,10 +87,12 @@ close $fd
# Now make sure the server aborted with an error # Now make sure the server aborted with an error
start_server_and_kill_it [list "dir" $server_path] { start_server_and_kill_it [list "dir" $server_path] {
wait_for_condition 50 100 { test {Server should not start if RDB is corrupted} {
[string match {*RDB checksum*} \ wait_for_condition 50 100 {
[exec tail -n1 < [dict get $srv stdout]]] [string match {*RDB checksum*} \
} else { [exec tail -n1 < [dict get $srv stdout]]]
fail "Server started even if RDB was corrupted!" } else {
fail "Server started even if RDB was corrupted!"
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册